From 7ae6f2ac7dbfd15d9685b66f0bdb653b89853720 Mon Sep 17 00:00:00 2001 From: DB p Date: Mon, 5 Sep 2022 15:48:10 +0900 Subject: [PATCH] - Add Timeformat to changable list --- .../UserSettings/Settings.cs | 2 ++ Flow.Launcher/MainWindow.xaml.cs | 23 ++------------- Flow.Launcher/SettingWindow.xaml | 29 +++++++------------ .../ViewModel/SettingWindowViewModel.cs | 19 ++++++++++++ 4 files changed, 35 insertions(+), 38 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 6b783a210..26b89be86 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -43,6 +43,8 @@ namespace Flow.Launcher.Infrastructure.UserSettings public bool UseSound { get; set; } = true; public bool UseClock { get; set; } = true; public bool UseDate { get; set; } = false; + public string TimeFormat { get; set; } = "hh:mm tt "; + public string DateFormat { get; set; } = "MM'/'dd ddd"; public bool FirstLaunch { get; set; } = true; public int CustomExplorerIndex { get; set; } = 0; diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 080486c5e..bc18d8dbc 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -63,24 +63,7 @@ namespace Flow.Launcher } private void Timer_Tick(object sender, EventArgs e) { - if (_settings.UseClock == true) - { - ClockBox.Text = System.DateTime.Now.ToString("tt hh:mm"); - } - else if(_settings.UseClock == false) - { - ClockBox.Visibility = Visibility.Collapsed; - } - if (_settings.UseDate == true) - { - DateBox.Text = System.DateTime.Now.ToString("MM/dd ddd"); - } - else if (_settings.UseDate == false) - { - DateBox.Visibility = Visibility.Collapsed; - } - - + ClockDisplay(); } public void ClockDisplay() @@ -88,7 +71,7 @@ namespace Flow.Launcher if (_settings.UseClock == true) { ClockBox.Visibility = Visibility.Visible; - ClockBox.Text = System.DateTime.Now.ToString("tt hh:mm"); + ClockBox.Text = System.DateTime.Now.ToString(_settings.TimeFormat); } else if (_settings.UseClock == false) { @@ -97,7 +80,7 @@ namespace Flow.Launcher if (_settings.UseDate == true) { DateBox.Visibility = Visibility.Visible; - DateBox.Text = System.DateTime.Now.ToString("MM/dd ddd"); + DateBox.Text = System.DateTime.Now.ToString(_settings.DateFormat); } else if (_settings.UseDate == false) { diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index ca310fce8..0c92f073f 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -1,17 +1,16 @@ + ItemsSource="{Binding TimeFormatList}" + SelectedValue="{Binding Settings.TimeFormat}"/> + ItemsSource="{Binding DateFormatList}" + SelectedValue="{Binding Settings.DateFormat}" + /> TimeFormatList { get; set; } = new List() + { + "hh:mm", + "HH:mm", + "tt hh:mm", + "hh:mm tt" + }; + + public List DateFormatList { get; set; } = new List() + { + "MM'/'dd dddd", + "MM'/'dd ddd", + "MM'/'dd", + "dd'/'MM", + "ddd MM'/'dd", + "dddd MM'/'dd", + "dddd" + }; + public double WindowWidthSize { get => Settings.WindowSize;