From e60635608d9a336020153b8e66d2fbf784e45582 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 16:22:46 +0800 Subject: [PATCH] Separate date/time format list refresh --- Flow.Launcher/SettingWindow.xaml | 4 +-- Flow.Launcher/SettingWindow.xaml.cs | 26 +++++++++++++------ .../ViewModel/SettingWindowViewModel.cs | 25 +++++++++++------- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index e08ce7c40..996c30542 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -2181,7 +2181,7 @@ FontSize="14" ItemsSource="{Binding TimeFormatDisplayList}" SelectedIndex="{Binding TimeFormatIndex, Mode=OneWayToSource}" - DropDownOpened="RefreshDateTimeList"/> + DropDownOpened="RefreshTimeList"/> + DropDownOpened="RefreshDateList"/> x.Equals(Settings.TimeFormat))) >= 0 ? tmp : 0; DateFormatIndex = (tmp = DateFormatList.FindIndex(x => x.Equals(Settings.DateFormat))) >= 0 ? tmp : 0; - // TODO: CurrentCulture may equal to settings.language when this is constructed + // TODO: CurrentCulture may not equal to settings.language when this is constructed TimeFormatDisplayList = TimeFormatList.Select(x => DateTime.Now.ToString(x, CultureInfo.CurrentCulture)).ToList(); DateFormatDisplayList = DateFormatList.Select(x => DateTime.Now.ToString(x, CultureInfo.CurrentCulture)).ToList(); - //UpdateSettingsDateTimeFormat(); // just in case something wrong } public Settings Settings { get; set; } @@ -514,20 +513,26 @@ namespace Flow.Launcher.ViewModel public List DateFormatDisplayList { get; set; } = null; - public void UpdateDateTimeDisplayList() + public void UpdateDateDisplayList() + { + for (int i = 0; i < DateFormatList.Count; ++i) + { + DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture); + } + // TODO: CurrentCulture may not equal to settings.language + // Cross thread issue? + DateText = DateTime.Now.ToString(Settings.DateFormat, CultureInfo.CurrentCulture); + } + + public void UpdateTimeDisplayList() { for (int i = 0; i < TimeFormatList.Count; ++i) { TimeFormatDisplayList[i] = DateTime.Now.ToString(TimeFormatList[i], CultureInfo.CurrentCulture); } - - for (int i = 0; i < DateFormatList.Count; ++i) - { - DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture); - } - + // TODO: CurrentCulture may not equal to settings.language + // Cross thread issue? ClockText = DateTime.Now.ToString(Settings.TimeFormat, CultureInfo.CurrentCulture); - DateText = DateTime.Now.ToString(Settings.DateFormat, CultureInfo.CurrentCulture); } public double WindowWidthSize