From 71859842012b76fee17768443a230206d6fa4c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaro=20Mart=C3=ADnez?= Date: Mon, 30 Dec 2024 23:05:31 -0500 Subject: [PATCH 01/13] Add clock click action settings --- RetroBar/Controls/Clock.xaml.cs | 43 +++---- RetroBar/Languages/English.xaml | 7 ++ RetroBar/PropertiesWindow.xaml | 10 ++ RetroBar/PropertiesWindow.xaml.cs | 32 +++++ RetroBar/Utilities/ClockFlyoutLauncher.cs | 147 ++++++++++++++++++++++ RetroBar/Utilities/Settings.cs | 15 +++ 6 files changed, 230 insertions(+), 24 deletions(-) create mode 100644 RetroBar/Utilities/ClockFlyoutLauncher.cs diff --git a/RetroBar/Controls/Clock.xaml.cs b/RetroBar/Controls/Clock.xaml.cs index 2f969bb0..2caf09cc 100644 --- a/RetroBar/Controls/Clock.xaml.cs +++ b/RetroBar/Controls/Clock.xaml.cs @@ -27,7 +27,6 @@ public DateTime Now } private readonly DispatcherTimer clock = new DispatcherTimer(DispatcherPriority.Background); - private readonly DispatcherTimer singleClick = new DispatcherTimer(DispatcherPriority.Input); private bool _isLoaded; @@ -38,9 +37,6 @@ public Clock() clock.Interval = TimeSpan.FromMilliseconds(200); clock.Tick += Clock_Tick; - - singleClick.Interval = TimeSpan.FromMilliseconds(System.Windows.Forms.SystemInformation.DoubleClickTime); - singleClick.Tick += SingleClick_Tick; } private void Initialize() @@ -65,7 +61,7 @@ private void StartClock() SetTime(); clock.Start(); - + Visibility = Visibility.Visible; } @@ -96,22 +92,6 @@ private void Clock_Tick(object sender, EventArgs args) SetTime(); } - private void SingleClick_Tick(object sender, EventArgs args) - { - // Windows 10-11 single-click action - // A double-click will cancel the timer so that this doesn't run - - singleClick.Stop(); - if (EnvironmentHelper.IsWindows11OrBetter) - { - ShellHelper.ShowNotificationCenter(); - } - else - { - ShellHelper.ShowActionCenter(); - } - } - private void TimeChanged(object sender, EventArgs e) { TimeZoneInfo.ClearCachedData(); @@ -181,15 +161,30 @@ private void SetTime() private void Clock_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { - if (EnvironmentHelper.IsWindows10OrBetter) + switch (Settings.Instance.ClockClickAction) { - singleClick.Start(); + case ClockClickOption.OpenModernCalendar: + ClockFlyoutLauncher.ShowClockFlyout(); + break; + case ClockClickOption.OpenAeroClockFlyout: + IntPtr hWnd = (PresentationSource.FromVisual(this) as System.Windows.Interop.HwndSource).Handle; + ClockFlyoutLauncher.ShowAeroClockFlyout(hWnd); + break; + case ClockClickOption.OpenActionCenter: + if (EnvironmentHelper.IsWindows11OrBetter) + { + ShellHelper.ShowNotificationCenter(); + } + else if (EnvironmentHelper.IsWindows10OrBetter) + { + ShellHelper.ShowActionCenter(); + } + break; } } private void Clock_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) { - singleClick.Stop(); ShellHelper.StartProcess("timedate.cpl"); e.Handled = true; diff --git a/RetroBar/Languages/English.xaml b/RetroBar/Languages/English.xaml index b7f832b9..c86aff48 100644 --- a/RetroBar/Languages/English.xaml +++ b/RetroBar/Languages/English.xaml @@ -57,6 +57,13 @@ Open a new instance Close the task + _Clock click action: + + Do nothing + Open Aero clock flyout + Open Action Center/Notification Center + Open Modern calendar + Version {0} Visit RetroBar on GitHub Taskbar scale diff --git a/RetroBar/PropertiesWindow.xaml b/RetroBar/PropertiesWindow.xaml index 3644078d..b3a3b3da 100644 --- a/RetroBar/PropertiesWindow.xaml +++ b/RetroBar/PropertiesWindow.xaml @@ -362,6 +362,16 @@ SelectedIndex="{Binding Source={x:Static Settings:Settings.Instance}, Path=TaskMiddleClickAction, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource enumConverter}}" SelectionChanged="cboMiddleMouseAction_SelectionChanged" /> + + + +