From 45e9a430601cd070c4ee798ba4ff9b5c710a6ceb Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 15:44:51 +0800 Subject: [PATCH] reorganize logic for date/time dropdown --- Flow.Launcher/SettingWindow.xaml | 7 ++-- Flow.Launcher/SettingWindow.xaml.cs | 33 +++++++++++-------- .../ViewModel/SettingWindowViewModel.cs | 27 +++++++-------- 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 6e2aa590c..3eb2c21bb 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -1815,6 +1815,7 @@ @@ -2170,7 +2171,8 @@ VerticalAlignment="Center" FontSize="14" ItemsSource="{Binding TimeFormatDisplayList}" - SelectedIndex="{Binding TimeFormatIndex, Mode=OneTime}" + SelectedIndex="{Binding TimeFormatIndex, Mode=OneWayToSource}" + DropDownOpened="RefreshDateTimeList" SelectionChanged="PreviewClockAndDate" /> timeFormatIndex; set { - timeFormatIndex = value; - Settings.TimeFormat = TimeFormatList[TimeFormatIndex]; + if (value != -1) + { + timeFormatIndex = value; + Settings.TimeFormat = TimeFormatList[value]; + } } } @@ -493,8 +496,11 @@ namespace Flow.Launcher.ViewModel get => dateFormatIndex; set { - dateFormatIndex = value; - Settings.DateFormat = DateFormatList[DateFormatIndex]; + if (value != -1) + { + dateFormatIndex = value; + Settings.DateFormat = DateFormatList[value]; + } } } @@ -502,17 +508,8 @@ namespace Flow.Launcher.ViewModel public List DateFormatDisplayList { get; set; } = null; - public void UpdateSettingsDateTimeFormat() + public void UpdateDateTimeDisplayList() { - Settings.DateFormat = DateFormatList[DateFormatIndex]; - Settings.TimeFormat = TimeFormatList[TimeFormatIndex]; - } - - public void UpdateDateTimeDisplayList(int dateIndex, int timeIndex) - { - DateFormatIndex = dateIndex; - TimeFormatIndex = timeIndex; - for (int i = 0; i < TimeFormatList.Count; ++i) { TimeFormatDisplayList[i] = DateTime.Now.ToString(TimeFormatList[i], CultureInfo.CurrentCulture); @@ -522,8 +519,6 @@ namespace Flow.Launcher.ViewModel { DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture); } - - //UpdateSettingsDateTimeFormat(); } public double WindowWidthSize