From 276d287d223bb77c464f9f09a8e3a3b833cab333 Mon Sep 17 00:00:00 2001 From: STBBRD <62409850+STBBRD@users.noreply.github.com> Date: Sat, 21 Sep 2024 10:00:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=AE=80=E7=BA=A6=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E8=B0=83=E6=95=B4=E7=95=8C=E9=9D=A2=E7=BC=A9?= =?UTF-8?q?=E6=94=BE=E4=BC=9A=E5=AF=BC=E8=87=B4=E9=BB=91=E6=9D=BF=E8=B4=B4?= =?UTF-8?q?=E5=AE=BD=E5=BA=A6=E5=8F=98=E5=8C=96=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20#33?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controls/Cards/SliderCard.xaml | 3 +- .../Controls/Cards/SliderCard.xaml.cs | 30 +++++++++++++++++++ .../MainWindow.xaml.cs | 16 +++++----- .../Pages/SettingsPages/LookSettingsPage.xaml | 8 +++-- .../SettingsPages/LookSettingsPage.xaml.cs | 15 ++++++++-- .../Pages/WelcomePages/WelcomePage2.xaml.cs | 2 +- 6 files changed, 61 insertions(+), 13 deletions(-) diff --git a/ZongziTEK_Blackboard_Sticker/Controls/Cards/SliderCard.xaml b/ZongziTEK_Blackboard_Sticker/Controls/Cards/SliderCard.xaml index 6e78fde..a153e1a 100644 --- a/ZongziTEK_Blackboard_Sticker/Controls/Cards/SliderCard.xaml +++ b/ZongziTEK_Blackboard_Sticker/Controls/Cards/SliderCard.xaml @@ -29,7 +29,8 @@ - + diff --git a/ZongziTEK_Blackboard_Sticker/Controls/Cards/SliderCard.xaml.cs b/ZongziTEK_Blackboard_Sticker/Controls/Cards/SliderCard.xaml.cs index facf244..bd1b4a6 100644 --- a/ZongziTEK_Blackboard_Sticker/Controls/Cards/SliderCard.xaml.cs +++ b/ZongziTEK_Blackboard_Sticker/Controls/Cards/SliderCard.xaml.cs @@ -134,5 +134,35 @@ private void MainSlider_ValueChanged(object sender, RoutedPropertyChangedEventAr RoutedEventArgs routedEventArgs = new RoutedEventArgs(ValueChangedEvent, this); RaiseEvent(routedEventArgs); } + + // ValueChangeStart Event + public static readonly RoutedEvent ValueChangeStartEvent = EventManager.RegisterRoutedEvent("ValueChangeStart", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(SliderCard)); + + public event RoutedEventHandler ValueChangeStart + { + add { AddHandler(ValueChangeStartEvent, value); } + remove { RemoveHandler(ValueChangeStartEvent, value); } + } + + private void MainSlider_PreviewMouseDown(object sender, MouseButtonEventArgs e) + { + RoutedEventArgs routedEventArgs = new RoutedEventArgs(ValueChangeStartEvent, this); + RaiseEvent(routedEventArgs); + } + + // ValueChangeEnd Event + public static readonly RoutedEvent ValueChangeEndEvent = EventManager.RegisterRoutedEvent("ValueChangeEnd", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(SliderCard)); + + public event RoutedEventHandler ValueChangeEnd + { + add { AddHandler(ValueChangeEndEvent, value); } + remove { RemoveHandler(ValueChangeEndEvent, value); } + } + + private void MainSlider_PreviewMouseUp(object sender, MouseButtonEventArgs e) + { + RoutedEventArgs routedEventArgs = new RoutedEventArgs(ValueChangeEndEvent, this); + RaiseEvent(routedEventArgs); + } } } diff --git a/ZongziTEK_Blackboard_Sticker/MainWindow.xaml.cs b/ZongziTEK_Blackboard_Sticker/MainWindow.xaml.cs index 84d0c2e..701faa7 100644 --- a/ZongziTEK_Blackboard_Sticker/MainWindow.xaml.cs +++ b/ZongziTEK_Blackboard_Sticker/MainWindow.xaml.cs @@ -127,7 +127,7 @@ private void window_StateChanged(object sender, EventArgs e) private void window_Loaded(object sender, RoutedEventArgs e) { - SwitchLookMode(); + SwitchLookMode(Settings.Look.LookMode); if (Settings.Look.IsAnimationEnhanced) { @@ -1232,7 +1232,7 @@ private void CheckTimetable(object sender, EventArgs e) { lastDay = DateTime.Now.DayOfWeek; - timetableToShow_index = (int)DateTime.Now.DayOfWeek; + timetableToShow_index = (int)DateTime.Now.DayOfWeek; LoadTimetable(); } @@ -1948,8 +1948,10 @@ public static string GetDataPath() public static void SetWindowScaleTransform(double Multiplier) { - (Application.Current.MainWindow as MainWindow).windowScale.ScaleX = Multiplier; - (Application.Current.MainWindow as MainWindow).windowScale.ScaleY = Multiplier; + MainWindow window = Application.Current.MainWindow as MainWindow; + + window.windowScale.ScaleX = Multiplier; + window.windowScale.ScaleY = Multiplier; } public static void SetTheme() @@ -2054,11 +2056,11 @@ public static bool StartAutomaticallyDel(string exeName) return null; }*/ - public static void SwitchLookMode() + public static void SwitchLookMode(int mode) { MainWindow window = Application.Current.MainWindow as MainWindow; - switch (Settings.Look.LookMode) + switch (mode) { case 0: // 默认 window.BorderMain.ClearValue(WidthProperty); @@ -2083,7 +2085,7 @@ public static void SwitchLookMode() window.ColumnClock.Width = new GridLength(1, GridUnitType.Star); window.frameInfoNavigationTimer.Stop(); - window.FrameInfo.Navigate(window.frameInfoPages[0]); //切换到日期页面防止继续调用天气 API + if (window.frameInfoPages.Count > 0) window.FrameInfo.Navigate(window.frameInfoPages[0]); //切换到日期页面防止继续调用天气 API break; case 2: // 简约(顶部为看板) diff --git a/ZongziTEK_Blackboard_Sticker/Pages/SettingsPages/LookSettingsPage.xaml b/ZongziTEK_Blackboard_Sticker/Pages/SettingsPages/LookSettingsPage.xaml index ab29997..128a0a6 100644 --- a/ZongziTEK_Blackboard_Sticker/Pages/SettingsPages/LookSettingsPage.xaml +++ b/ZongziTEK_Blackboard_Sticker/Pages/SettingsPages/LookSettingsPage.xaml @@ -14,8 +14,12 @@