From caf4d13d506a6b85f0d5ed1aac08c5ebb60b1293 Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 18 Nov 2022 20:52:15 +0900 Subject: [PATCH 01/31] Add Time Formats --- Flow.Launcher/ViewModel/SettingWindowViewModel.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 65321e6ba..e7ef4da11 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -463,7 +463,10 @@ namespace Flow.Launcher.ViewModel "dd'/'MM", "ddd MM'/'dd", "dddd MM'/'dd", - "dddd" + "dddd", + "ddd dd'/MM'", + "dddd dd'/MM'" + }; public double WindowWidthSize From ddb5f898d39387ff2ea68d3860c1a6f87b61d2f4 Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 18 Nov 2022 21:08:39 +0900 Subject: [PATCH 02/31] Add timeformats --- Flow.Launcher/ViewModel/SettingWindowViewModel.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index e7ef4da11..aa79248b8 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -464,8 +464,11 @@ namespace Flow.Launcher.ViewModel "ddd MM'/'dd", "dddd MM'/'dd", "dddd", - "ddd dd'/MM'", - "dddd dd'/MM'" + "ddd dd'/'MM", + "dddd dd'/'MM", + "dddd dd', 'MMMM", + "dddd DDDD', 'MMMM", + "dd', 'MMMM" }; From 9e8bf456c0cc4a9f611c5907625013fe70bef137 Mon Sep 17 00:00:00 2001 From: DB p Date: Fri, 18 Nov 2022 21:11:27 +0900 Subject: [PATCH 03/31] Formatting --- Flow.Launcher/ViewModel/SettingWindowViewModel.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index aa79248b8..e6df8e4fd 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -467,9 +467,7 @@ namespace Flow.Launcher.ViewModel "ddd dd'/'MM", "dddd dd'/'MM", "dddd dd', 'MMMM", - "dddd DDDD', 'MMMM", "dd', 'MMMM" - }; public double WindowWidthSize From 7270c9f35d392e8f26bf2b3f53df810e48da9324 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 00:47:04 +0800 Subject: [PATCH 04/31] Display current time in time/date format combobox --- Flow.Launcher/SettingWindow.xaml | 8 ++-- Flow.Launcher/SettingWindow.xaml.cs | 11 +++++ .../ViewModel/SettingWindowViewModel.cs | 44 ++++++++++++++++++- 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 5584983a9..6e2aa590c 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -2169,8 +2169,8 @@ Margin="0,0,18,0" VerticalAlignment="Center" FontSize="14" - ItemsSource="{Binding TimeFormatList}" - SelectedValue="{Binding Settings.TimeFormat}" + ItemsSource="{Binding TimeFormatDisplayList}" + SelectedIndex="{Binding TimeFormatIndex, Mode=OneTime}" SelectionChanged="PreviewClockAndDate" /> x.Equals(Settings.TimeFormat))) >= 0 ? tmp : 0; + DateFormatIndex = (tmp = DateFormatList.FindIndex(x => x.Equals(Settings.DateFormat))) >= 0 ? tmp : 0; + + 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; } @@ -422,8 +430,6 @@ namespace Flow.Launcher.ViewModel } } - - public class SearchWindowPosition { public string Display { get; set; } @@ -470,6 +476,40 @@ namespace Flow.Launcher.ViewModel "dd', 'MMMM" }; + public int TimeFormatIndex { get; set; } = 0; + + public int DateFormatIndex { get; set; } = 0; + + public List TimeFormatDisplayList { get; set; } = null; + + public List DateFormatDisplayList { get; set; } = null; + + public void UpdateSettingsDateTimeFormat() + { + Settings.DateFormat = DateFormatList[DateFormatIndex]; + Settings.TimeFormat = TimeFormatList[TimeFormatIndex]; + } + + public void UpdateDateTimeDisplayList(int dateIndex, int timeIndex) + { + if (dateIndex == -1 || timeIndex == -1) + return; + DateFormatIndex = dateIndex; + TimeFormatIndex = timeIndex; + + 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); + } + + UpdateSettingsDateTimeFormat(); + } + public double WindowWidthSize { get => Settings.WindowSize; From a70b9fcb2dc1ebb9f71940cc23e363551865835f Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 01:43:20 +0800 Subject: [PATCH 05/31] Try to avoid recurion and comment --- Flow.Launcher/SettingWindow.xaml.cs | 4 ++++ Flow.Launcher/ViewModel/SettingWindowViewModel.cs | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index 7e029910f..bdc858527 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -519,6 +519,10 @@ namespace Flow.Launcher { if (DateFormat != null && TimeFormat != null) { + if (DateFormat.SelectedIndex == -1 || TimeFormat.SelectedIndex == -1) + { + return; + } viewModel.UpdateDateTimeDisplayList(DateFormat.SelectedIndex, TimeFormat.SelectedIndex); DateFormat.Items.Refresh(); TimeFormat.Items.Refresh(); // selected = -1 diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 302310e43..5066d0ca6 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -52,7 +52,7 @@ namespace Flow.Launcher.ViewModel int tmp = 0; TimeFormatIndex = (tmp = TimeFormatList.FindIndex(x => 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 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 @@ -492,8 +492,6 @@ namespace Flow.Launcher.ViewModel public void UpdateDateTimeDisplayList(int dateIndex, int timeIndex) { - if (dateIndex == -1 || timeIndex == -1) - return; DateFormatIndex = dateIndex; TimeFormatIndex = timeIndex; From 8159b6edf1b101609e02ee6a80f372e04778fa7b Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 12:25:46 +0800 Subject: [PATCH 06/31] auto update value string in index setter --- .../ViewModel/SettingWindowViewModel.cs | 48 +++++++++++++------ 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 5066d0ca6..1d78ca1aa 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -55,7 +55,7 @@ namespace Flow.Launcher.ViewModel // TODO: CurrentCulture may 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 + //UpdateSettingsDateTimeFormat(); // just in case something wrong } public Settings Settings { get; set; } @@ -64,7 +64,7 @@ namespace Flow.Launcher.ViewModel { await _updater.UpdateAppAsync(App.API, false); } - + public bool AutoUpdates { get => Settings.AutoUpdates; @@ -310,11 +310,11 @@ namespace Flow.Launcher.ViewModel } } - private IList LabelMaker(IList list) + private IList LabelMaker(IList list) { - return list.Select(p=>new PluginStoreItemViewModel(p)) + return list.Select(p => new PluginStoreItemViewModel(p)) .OrderByDescending(p => p.Category == PluginStoreItemViewModel.NewRelease) - .ThenByDescending(p=>p.Category == PluginStoreItemViewModel.RecentlyUpdated) + .ThenByDescending(p => p.Category == PluginStoreItemViewModel.RecentlyUpdated) .ThenByDescending(p => p.Category == PluginStoreItemViewModel.None) .ThenByDescending(p => p.Category == PluginStoreItemViewModel.Installed) .ToList(); @@ -348,10 +348,10 @@ namespace Flow.Launcher.ViewModel internal void DisplayPluginQuery(string queryToDisplay, PluginPair plugin, int actionKeywordPosition = 0) { - var actionKeyword = plugin.Metadata.ActionKeywords.Count == 0 - ? string.Empty + var actionKeyword = plugin.Metadata.ActionKeywords.Count == 0 + ? string.Empty : plugin.Metadata.ActionKeywords[actionKeywordPosition]; - + App.API.ChangeQuery($"{actionKeyword} {queryToDisplay}"); App.API.ShowMainWindow(); } @@ -476,9 +476,27 @@ namespace Flow.Launcher.ViewModel "dd', 'MMMM" }; - public int TimeFormatIndex { get; set; } = 0; + private int timeFormatIndex = 0; + public int TimeFormatIndex + { + get => timeFormatIndex; + set + { + timeFormatIndex = value; + Settings.TimeFormat = TimeFormatList[TimeFormatIndex]; + } + } - public int DateFormatIndex { get; set; } = 0; + private int dateFormatIndex = 0; + public int DateFormatIndex + { + get => dateFormatIndex; + set + { + dateFormatIndex = value; + Settings.DateFormat = DateFormatList[DateFormatIndex]; + } + } public List TimeFormatDisplayList { get; set; } = null; @@ -505,7 +523,7 @@ namespace Flow.Launcher.ViewModel DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture); } - UpdateSettingsDateTimeFormat(); + //UpdateSettingsDateTimeFormat(); } public double WindowWidthSize @@ -815,15 +833,15 @@ namespace Flow.Launcher.ViewModel } } public string ActivatedTimes => string.Format(_translater.GetTranslation("about_activate_times"), Settings.ActivateTimes); - + public string CheckLogFolder { - get + get { var dirInfo = new DirectoryInfo(Path.Combine(DataLocation.DataDirectory(), Constant.Logs, Constant.Version)); long size = dirInfo.EnumerateFiles("*", SearchOption.AllDirectories).Sum(file => file.Length); - - return _translater.GetTranslation("clearlogfolder") + " (" + FormatBytes(size) + ")" ; + + return _translater.GetTranslation("clearlogfolder") + " (" + FormatBytes(size) + ")"; } } From 673e8c8e9dd2ec44525cadb13225bcefad95b5d3 Mon Sep 17 00:00:00 2001 From: DB p Date: Sat, 19 Nov 2022 14:33:27 +0900 Subject: [PATCH 07/31] Add Datetimeformat --- .../ViewModel/SettingWindowViewModel.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 5066d0ca6..d48e64380 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -455,9 +455,13 @@ namespace Flow.Launcher.ViewModel public List TimeFormatList { get; set; } = new List() { + "h:mm", "hh:mm", + "H:mm", "HH:mm", + "tt h:mm", "tt hh:mm", + "h:mm tt", "hh:mm tt" }; @@ -466,7 +470,10 @@ namespace Flow.Launcher.ViewModel "MM'/'dd dddd", "MM'/'dd ddd", "MM'/'dd", + "MM'-'dd", + "MMMM', 'dd", "dd'/'MM", + "dd'-'MM", "ddd MM'/'dd", "dddd MM'/'dd", "dddd", @@ -500,6 +507,15 @@ namespace Flow.Launcher.ViewModel TimeFormatDisplayList[i] = DateTime.Now.ToString(TimeFormatList[i], CultureInfo.CurrentCulture); } + TimeFormatDisplayList[0] = DateTime.Now.ToString(TimeFormatList[0], CultureInfo.CurrentCulture) + " (h:mm)"; + TimeFormatDisplayList[1] = DateTime.Now.ToString(TimeFormatList[1], CultureInfo.CurrentCulture) + " (hh:mm)"; + TimeFormatDisplayList[2] = DateTime.Now.ToString(TimeFormatList[2], CultureInfo.CurrentCulture) + " (H:mm)"; + TimeFormatDisplayList[3] = DateTime.Now.ToString(TimeFormatList[3], CultureInfo.CurrentCulture) + " (HH:mm)"; + TimeFormatDisplayList[4] = DateTime.Now.ToString(TimeFormatList[4], CultureInfo.CurrentCulture) + " (tt h:mm)"; + TimeFormatDisplayList[5] = DateTime.Now.ToString(TimeFormatList[5], CultureInfo.CurrentCulture) + " (tt hh:mm)"; + TimeFormatDisplayList[6] = DateTime.Now.ToString(TimeFormatList[6], CultureInfo.CurrentCulture) + " (h:mm tt)"; + TimeFormatDisplayList[7] = DateTime.Now.ToString(TimeFormatList[6], CultureInfo.CurrentCulture) + " (hh:mm tt)"; + for (int i = 0; i < DateFormatList.Count; ++i) { DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture); From 32c7ca8ade8123067ccfccf75c369e040b227072 Mon Sep 17 00:00:00 2001 From: DB p Date: Sat, 19 Nov 2022 14:35:56 +0900 Subject: [PATCH 08/31] Remove Timeformat info --- Flow.Launcher/ViewModel/SettingWindowViewModel.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index d48e64380..24229e9da 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -507,15 +507,6 @@ namespace Flow.Launcher.ViewModel TimeFormatDisplayList[i] = DateTime.Now.ToString(TimeFormatList[i], CultureInfo.CurrentCulture); } - TimeFormatDisplayList[0] = DateTime.Now.ToString(TimeFormatList[0], CultureInfo.CurrentCulture) + " (h:mm)"; - TimeFormatDisplayList[1] = DateTime.Now.ToString(TimeFormatList[1], CultureInfo.CurrentCulture) + " (hh:mm)"; - TimeFormatDisplayList[2] = DateTime.Now.ToString(TimeFormatList[2], CultureInfo.CurrentCulture) + " (H:mm)"; - TimeFormatDisplayList[3] = DateTime.Now.ToString(TimeFormatList[3], CultureInfo.CurrentCulture) + " (HH:mm)"; - TimeFormatDisplayList[4] = DateTime.Now.ToString(TimeFormatList[4], CultureInfo.CurrentCulture) + " (tt h:mm)"; - TimeFormatDisplayList[5] = DateTime.Now.ToString(TimeFormatList[5], CultureInfo.CurrentCulture) + " (tt hh:mm)"; - TimeFormatDisplayList[6] = DateTime.Now.ToString(TimeFormatList[6], CultureInfo.CurrentCulture) + " (h:mm tt)"; - TimeFormatDisplayList[7] = DateTime.Now.ToString(TimeFormatList[6], CultureInfo.CurrentCulture) + " (hh:mm tt)"; - for (int i = 0; i < DateFormatList.Count; ++i) { DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture); 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 09/31] 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 From bde471afa87748490267f81ea72136f876d0f272 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 16:03:44 +0800 Subject: [PATCH 10/31] Use binding for date time preview --- Flow.Launcher/SettingWindow.xaml | 27 ++++++++++-------- Flow.Launcher/SettingWindow.xaml.cs | 28 ------------------- .../ViewModel/SettingWindowViewModel.cs | 9 ++++++ 3 files changed, 25 insertions(+), 39 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 3eb2c21bb..e08ce7c40 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -39,6 +39,7 @@ + @@ -1820,9 +1821,17 @@ Style="{DynamicResource QueryBoxStyle}" Text="{DynamicResource hiThere}" /> - - - + + + + DropDownOpened="RefreshDateTimeList"/> + Style="{DynamicResource SideToggleSwitch}"/>  @@ -2211,14 +2218,12 @@ FontSize="14" ItemsSource="{Binding DateFormatDisplayList}" SelectedIndex="{Binding DateFormatIndex, Mode=OneWayToSource}" - DropDownOpened="RefreshDateTimeList" - SelectionChanged="PreviewClockAndDate" /> + DropDownOpened="RefreshDateTimeList"/> + Style="{DynamicResource SideToggleSwitch}"/>  diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index 97493ca5c..8a80ed680 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -517,34 +517,6 @@ namespace Flow.Launcher } } - private void PreviewClockAndDate(object sender, RoutedEventArgs e) - { - ClockDisplay(); - } - - public void ClockDisplay() - { - if (settings.UseClock) - { - ClockBox.Visibility = Visibility.Visible; - ClockBox.Text = DateTime.Now.ToString(settings.TimeFormat); - } - else - { - ClockBox.Visibility = Visibility.Collapsed; - } - - if (settings.UseDate) - { - DateBox.Visibility = Visibility.Visible; - DateBox.Text = DateTime.Now.ToString(settings.DateFormat); - } - else - { - DateBox.Visibility = Visibility.Collapsed; - } - } - public void InitializePosition() { if (settings.SettingWindowTop >= 0 && settings.SettingWindowLeft >= 0) diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 8f02a7083..4a4cf9404 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -486,6 +486,7 @@ namespace Flow.Launcher.ViewModel { timeFormatIndex = value; Settings.TimeFormat = TimeFormatList[value]; + ClockText = DateTime.Now.ToString(Settings.TimeFormat, CultureInfo.CurrentCulture); } } } @@ -500,10 +501,15 @@ namespace Flow.Launcher.ViewModel { dateFormatIndex = value; Settings.DateFormat = DateFormatList[value]; + DateText = DateTime.Now.ToString(Settings.DateFormat, CultureInfo.CurrentCulture); } } } + public string ClockText { get; private set; } + + public string DateText { get; private set; } + public List TimeFormatDisplayList { get; set; } = null; public List DateFormatDisplayList { get; set; } = null; @@ -519,6 +525,9 @@ namespace Flow.Launcher.ViewModel { DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture); } + + ClockText = DateTime.Now.ToString(Settings.TimeFormat, CultureInfo.CurrentCulture); + DateText = DateTime.Now.ToString(Settings.DateFormat, CultureInfo.CurrentCulture); } public double WindowWidthSize 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 11/31] 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 From f1889a950d0e4fbd992f00028546ca3c6df2fffb Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 16:36:27 +0800 Subject: [PATCH 12/31] Remov unused imports --- Flow.Launcher/SettingWindow.xaml.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index ae84cdad2..a3cb85b41 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -7,21 +7,17 @@ using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; using Flow.Launcher.Plugin.SharedCommands; using Flow.Launcher.ViewModel; -using Microsoft.VisualBasic; using ModernWpf; using ModernWpf.Controls; using System; -using System.Drawing.Printing; using System.IO; using System.Windows; -using System.Windows.Controls.Primitives; using System.Windows.Data; using System.Windows.Forms; using System.Windows.Input; using System.Windows.Interop; using System.Windows.Media; using System.Windows.Navigation; -using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window; using Button = System.Windows.Controls.Button; using Control = System.Windows.Controls.Control; using KeyEventArgs = System.Windows.Input.KeyEventArgs; From e2fcd9120297b4f7c0fc507d772eaf5e0f9ead8c Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 17:54:34 +0800 Subject: [PATCH 13/31] Fix ClockText type --- Flow.Launcher/ViewModel/MainViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 73be0bbed..dc8121c5a 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -323,7 +323,7 @@ namespace Flow.Launcher.ViewModel #region ViewModel Properties public Settings Settings { get; } - public object ClockText { get; private set; } + public string ClockText { get; private set; } public string DateText { get; private set; } private async Task RegisterClockAndDateUpdateAsync() From dbfb0393173a56cf6d691df2f54c21296d2395d3 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 18:03:25 +0800 Subject: [PATCH 14/31] Remove null check for selected shortcut --- Flow.Launcher/ViewModel/SettingWindowViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index f3538e02d..cfc53a370 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -783,7 +783,7 @@ namespace Flow.Launcher.ViewModel string deleteWarning = string.Format( InternationalizationManager.Instance.GetTranslation("deleteCustomShortcutWarning"), - item?.Key, item?.Value); + item.Key, item.Value); if (MessageBox.Show(deleteWarning, InternationalizationManager.Instance.GetTranslation("delete"), MessageBoxButton.YesNo) == MessageBoxResult.Yes) { From 28a26644f255bb4c25dc94ef8e068a466f227944 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 19 Nov 2022 18:10:21 +0800 Subject: [PATCH 15/31] fix indent --- Flow.Launcher/SettingWindow.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 996c30542..bc0ff1ce4 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -1822,8 +1822,8 @@ Text="{DynamicResource hiThere}" /> + x:Name="ClockPanel" + Style="{DynamicResource ClockPanel}"> Date: Sat, 19 Nov 2022 16:09:39 -0600 Subject: [PATCH 16/31] Use Converter to transform format to actual display --- .../DateTimeFormatToNowConverter.cs | 19 + Flow.Launcher/SettingWindow.xaml | 1666 +++++++++-------- Flow.Launcher/SettingWindow.xaml.cs | 24 - .../ViewModel/SettingWindowViewModel.cs | 99 +- 4 files changed, 920 insertions(+), 888 deletions(-) create mode 100644 Flow.Launcher/Converters/DateTimeFormatToNowConverter.cs diff --git a/Flow.Launcher/Converters/DateTimeFormatToNowConverter.cs b/Flow.Launcher/Converters/DateTimeFormatToNowConverter.cs new file mode 100644 index 000000000..3c46fd01a --- /dev/null +++ b/Flow.Launcher/Converters/DateTimeFormatToNowConverter.cs @@ -0,0 +1,19 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace Flow.Launcher.Converters +{ + public class DateTimeFormatToNowConverter : IValueConverter + { + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return value is not string format ? null : DateTime.Now.ToString(format); + } + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index bc0ff1ce4..5b841978f 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -1,5 +1,4 @@ - - + - + - + @@ -44,12 +47,15 @@ - + + - + @@ -59,127 +65,172 @@ - - - - - - - - - - - - - - - - - - - - - + @@ -606,13 +717,11 @@ - - - + @@ -628,25 +738,24 @@ - + - - - - + - + - @@ -672,10 +781,10 @@ - + - @@ -685,13 +794,14 @@ - + - + - @@ -702,24 +812,26 @@ - - + + - - + - + - - - + + - @@ -752,14 +865,16 @@ - + - - + + - - + - + - @@ -789,11 +905,12 @@ - - + + - @@ -803,52 +920,46 @@ - - - - + - - - - - + - - - - - + - - + - - + - - - - - - - + @@ -717,11 +606,13 @@ - - - + @@ -738,24 +628,25 @@ - + - - - - + - + - @@ -781,10 +672,10 @@ - + - @@ -794,14 +685,13 @@ - + - + - @@ -812,26 +702,24 @@ - - + + - - + - + - - - + + - @@ -865,16 +752,14 @@ - + - - + + - - + - + - @@ -905,12 +789,11 @@ - - + + - @@ -920,46 +803,52 @@ - - - - + - - - - - + - - - - - + - - + - - + - -