From d608a23eac9d986adb0f70cc1ec85207c92610d3 Mon Sep 17 00:00:00 2001 From: "zhengxuan.zhang" Date: Fri, 24 Apr 2026 14:19:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AE=9E=E6=97=B6=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XplorePlane/Controls/AnimatedSwitch.cs | 95 +++++++++++++ XplorePlane/Properties/AssemblyInfo.cs | 4 + XplorePlane/Themes/Generic.xaml | 125 ++++++++++++++++++ XplorePlane/Views/Main/MainWindow.xaml | 89 +++++++------ XplorePlane/Views/Main/ViewportPanelView.xaml | 8 +- 5 files changed, 273 insertions(+), 48 deletions(-) create mode 100644 XplorePlane/Controls/AnimatedSwitch.cs create mode 100644 XplorePlane/Themes/Generic.xaml diff --git a/XplorePlane/Controls/AnimatedSwitch.cs b/XplorePlane/Controls/AnimatedSwitch.cs new file mode 100644 index 0000000..0a5c029 --- /dev/null +++ b/XplorePlane/Controls/AnimatedSwitch.cs @@ -0,0 +1,95 @@ +using System.Windows; +using System.Windows.Controls.Primitives; +using System.Windows.Input; +using System.Windows.Media; + +namespace XplorePlane.Controls +{ + public class AnimatedSwitch : ToggleButton + { + static AnimatedSwitch() + { + DefaultStyleKeyProperty.OverrideMetadata( + typeof(AnimatedSwitch), + new FrameworkPropertyMetadata(typeof(AnimatedSwitch))); + } + + public static readonly DependencyProperty OnBrushProperty = + DependencyProperty.Register( + nameof(OnBrush), + typeof(Brush), + typeof(AnimatedSwitch), + new PropertyMetadata(new SolidColorBrush(Color.FromRgb(45, 204, 112)))); + + public static readonly DependencyProperty OffBrushProperty = + DependencyProperty.Register( + nameof(OffBrush), + typeof(Brush), + typeof(AnimatedSwitch), + new PropertyMetadata(new SolidColorBrush(Color.FromRgb(205, 212, 218)))); + + public static readonly DependencyProperty ThumbBrushProperty = + DependencyProperty.Register( + nameof(ThumbBrush), + typeof(Brush), + typeof(AnimatedSwitch), + new PropertyMetadata(Brushes.White)); + + public static readonly DependencyProperty SwitchWidthProperty = + DependencyProperty.Register( + nameof(SwitchWidth), + typeof(double), + typeof(AnimatedSwitch), + new PropertyMetadata(44d)); + + public static readonly DependencyProperty SwitchHeightProperty = + DependencyProperty.Register( + nameof(SwitchHeight), + typeof(double), + typeof(AnimatedSwitch), + new PropertyMetadata(24d)); + + public Brush OnBrush + { + get => (Brush)GetValue(OnBrushProperty); + set => SetValue(OnBrushProperty, value); + } + + public Brush OffBrush + { + get => (Brush)GetValue(OffBrushProperty); + set => SetValue(OffBrushProperty, value); + } + + public Brush ThumbBrush + { + get => (Brush)GetValue(ThumbBrushProperty); + set => SetValue(ThumbBrushProperty, value); + } + + public double SwitchWidth + { + get => (double)GetValue(SwitchWidthProperty); + set => SetValue(SwitchWidthProperty, value); + } + + public double SwitchHeight + { + get => (double)GetValue(SwitchHeightProperty); + set => SetValue(SwitchHeightProperty, value); + } + + protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e) + { + if (!IsEnabled) + { + base.OnPreviewMouseLeftButtonDown(e); + return; + } + + e.Handled = true; + Focus(); + OnClick(); + } + } +} diff --git a/XplorePlane/Properties/AssemblyInfo.cs b/XplorePlane/Properties/AssemblyInfo.cs index f2bf64e..2ae47d0 100644 --- a/XplorePlane/Properties/AssemblyInfo.cs +++ b/XplorePlane/Properties/AssemblyInfo.cs @@ -1,3 +1,7 @@ +using System.Windows; using System.Runtime.CompilerServices; +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, + ResourceDictionaryLocation.SourceAssembly)] [assembly: InternalsVisibleTo("XplorePlane.Tests")] diff --git a/XplorePlane/Themes/Generic.xaml b/XplorePlane/Themes/Generic.xaml new file mode 100644 index 0000000..055be1d --- /dev/null +++ b/XplorePlane/Themes/Generic.xaml @@ -0,0 +1,125 @@ + + + + diff --git a/XplorePlane/Views/Main/MainWindow.xaml b/XplorePlane/Views/Main/MainWindow.xaml index dfb230e..cecb243 100644 --- a/XplorePlane/Views/Main/MainWindow.xaml +++ b/XplorePlane/Views/Main/MainWindow.xaml @@ -4,6 +4,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:controls="clr-namespace:XplorePlane.Controls" xmlns:spreadsheet="clr-namespace:Telerik.Windows.Controls.Spreadsheet;assembly=Telerik.Windows.Controls.Spreadsheet" xmlns:spreadsheetControls="clr-namespace:Telerik.Windows.Controls.Spreadsheet.Controls;assembly=Telerik.Windows.Controls.Spreadsheet" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" @@ -117,13 +118,20 @@ SmallImage="/Assets/Icons/stop.png" Text="停止" /> - - + + @@ -318,7 +326,7 @@ SmallImage="/Assets/Icons/spiral.png" /> - + + + + + + + + + + - - - - - - - - - - - - - + Size="Large" + SmallImage="/Assets/Icons/message.png" + Command="{Binding OpenUserManualCommand}" + Text="帮助文档" /> + + + diff --git a/XplorePlane/Views/Main/ViewportPanelView.xaml b/XplorePlane/Views/Main/ViewportPanelView.xaml index a0b398f..2ab5ff5 100644 --- a/XplorePlane/Views/Main/ViewportPanelView.xaml +++ b/XplorePlane/Views/Main/ViewportPanelView.xaml @@ -32,12 +32,6 @@ Background="White" ImageSource="{Binding ImageSource}" /> - - - +