From 783e5c43a53fb34b93f9e490d7739461aca2cf14 Mon Sep 17 00:00:00 2001 From: PrefacedCorg <1876568293@qq.com> Date: Sat, 27 Dec 2025 12:05:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/Helpers/GlobalHotkeyManager.cs | 4 +-- Ink Canvas/Helpers/MultiTouchInput.cs | 20 +++++------ Ink Canvas/Helpers/PPTManager.cs | 4 +-- Ink Canvas/MainWindow.xaml.cs | 2 +- .../MainWindow_cs/MW_FloatingBarIcons.cs | 34 ++++++++++++------- Ink Canvas/MainWindow_cs/MW_Settings.cs | 10 +++--- Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs | 8 ++--- Ink Canvas/Windows/NewStyleRollCallWindow.cs | 10 +++--- Ink Canvas/Windows/RandWindow.xaml.cs | 7 ++-- 9 files changed, 53 insertions(+), 46 deletions(-) diff --git a/Ink Canvas/Helpers/GlobalHotkeyManager.cs b/Ink Canvas/Helpers/GlobalHotkeyManager.cs index d36b4aaf..e9bfcd97 100644 --- a/Ink Canvas/Helpers/GlobalHotkeyManager.cs +++ b/Ink Canvas/Helpers/GlobalHotkeyManager.cs @@ -454,7 +454,7 @@ namespace Ink_Canvas.Helpers { // 如果设置允许,则在鼠标模式下也启用快捷键 EnableHotkeyRegistration(); - + if (_hotkeysShouldBeRegistered && _registeredHotkeys.Count == 0) { LoadHotkeysFromSettings(); @@ -470,7 +470,7 @@ namespace Ink_Canvas.Helpers { // 非鼠标模式下启用快捷键 EnableHotkeyRegistration(); - + if (_hotkeysShouldBeRegistered && _registeredHotkeys.Count == 0) { LoadHotkeysFromSettings(); diff --git a/Ink Canvas/Helpers/MultiTouchInput.cs b/Ink Canvas/Helpers/MultiTouchInput.cs index 0a986344..7b89b243 100644 --- a/Ink Canvas/Helpers/MultiTouchInput.cs +++ b/Ink Canvas/Helpers/MultiTouchInput.cs @@ -23,10 +23,10 @@ namespace Ink_Canvas.Helpers public VisualCanvas() { CacheMode = new BitmapCache(); - - RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.HighQuality); - RenderOptions.SetEdgeMode(this, EdgeMode.Aliased); - RenderOptions.SetCachingHint(this, CachingHint.Cache); + + RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.HighQuality); + RenderOptions.SetEdgeMode(this, EdgeMode.Aliased); + RenderOptions.SetCachingHint(this, CachingHint.Cache); } public void AddVisual(DrawingVisual visual) @@ -52,9 +52,9 @@ namespace Ink_Canvas.Helpers /// public class StrokeVisual { - private int _lastDrawnPointCount = 0; - private const int INCREMENTAL_DRAW_THRESHOLD = 2; - private VisualCanvas _visualCanvas; + private int _lastDrawnPointCount = 0; + private const int INCREMENTAL_DRAW_THRESHOLD = 2; + private VisualCanvas _visualCanvas; /// /// 创建显示笔迹的类 @@ -118,10 +118,10 @@ namespace Ink_Canvas.Helpers var points = Stroke.StylusPoints; var drawingAttributes = Stroke.DrawingAttributes; - + // 创建新的DrawingVisual用于绘制这个点段 var segmentVisual = new DrawingVisual(); - + RenderOptions.SetBitmapScalingMode(segmentVisual, BitmapScalingMode.HighQuality); RenderOptions.SetEdgeMode(segmentVisual, EdgeMode.Aliased); RenderOptions.SetCachingHint(segmentVisual, CachingHint.Cache); @@ -149,7 +149,7 @@ namespace Ink_Canvas.Helpers // 只有一个点,绘制圆点 var brush = new SolidColorBrush(drawingAttributes.Color); var point = points[startIndex]; - dc.DrawEllipse(brush, null, new Point(point.X, point.Y), + dc.DrawEllipse(brush, null, new Point(point.X, point.Y), drawingAttributes.Width / 2, drawingAttributes.Height / 2); } } diff --git a/Ink Canvas/Helpers/PPTManager.cs b/Ink Canvas/Helpers/PPTManager.cs index b4f1198b..fd9686e5 100644 --- a/Ink Canvas/Helpers/PPTManager.cs +++ b/Ink Canvas/Helpers/PPTManager.cs @@ -1,5 +1,5 @@ -using Microsoft.Office.Interop.PowerPoint; -using Microsoft.Office.Core; +using Microsoft.Office.Core; +using Microsoft.Office.Interop.PowerPoint; using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/Ink Canvas/MainWindow.xaml.cs b/Ink Canvas/MainWindow.xaml.cs index f60406c3..f5ae8694 100644 --- a/Ink Canvas/MainWindow.xaml.cs +++ b/Ink Canvas/MainWindow.xaml.cs @@ -977,7 +977,7 @@ namespace Ink_Canvas if (DateTime.Now < pauseUntilDate) { LogHelper.WriteLogToFile($"AutoUpdate | 自动更新已暂停,直到 {pauseUntilDate:yyyy-MM-dd}"); - return; + return; } else { diff --git a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs index ef8cf1c0..6a31739c 100644 --- a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs +++ b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs @@ -73,35 +73,40 @@ namespace Ink_Canvas /// /// 用於更新浮動工具欄的"手勢"按鈕和白板工具欄的"手勢"按鈕的樣式(開啟和關閉狀態) /// - private void CheckEnableTwoFingerGestureBtnColorPrompt() { + private void CheckEnableTwoFingerGestureBtnColorPrompt() + { // 根据主题选择手势图标和颜色 bool isDarkTheme = Settings.Appearance.Theme == 1 || (Settings.Appearance.Theme == 2 && !IsSystemThemeLight()); bool isLightTheme = !isDarkTheme; string gestureIconPath = isLightTheme ? "/Resources/new-icons/gesture.png" : "/Resources/new-icons/gesture_white.png"; - + // 根据主题设置白板模式下的颜色 Color boardBgColor, boardIconColor, boardTextColor, boardBorderColor; - if (isLightTheme) { + if (isLightTheme) + { // 浅色主题 boardBgColor = Color.FromRgb(244, 244, 245); boardIconColor = Color.FromRgb(24, 24, 27); boardTextColor = Color.FromRgb(24, 24, 27); boardBorderColor = Color.FromRgb(161, 161, 170); - } else { + } + else + { // 深色主题 boardBgColor = Color.FromRgb(39, 39, 42); boardIconColor = Color.FromRgb(244, 244, 245); boardTextColor = Color.FromRgb(244, 244, 245); boardBorderColor = Color.FromRgb(113, 113, 122); } - - if (ToggleSwitchEnableMultiTouchMode.IsOn) { + + if (ToggleSwitchEnableMultiTouchMode.IsOn) + { TwoFingerGestureSimpleStackPanel.Opacity = 0.5; TwoFingerGestureSimpleStackPanel.IsHitTestVisible = false; EnableTwoFingerGestureBtn.Source = new BitmapImage(new Uri(gestureIconPath, UriKind.Relative)); - + BoardGesture.Background = new SolidColorBrush(boardBgColor); BoardGestureGeometry.Brush = new SolidColorBrush(boardIconColor); BoardGestureGeometry2.Brush = new SolidColorBrush(boardIconColor); @@ -110,25 +115,28 @@ namespace Ink_Canvas BoardGestureGeometry.Geometry = Geometry.Parse(XamlGraphicsIconGeometries.DisabledGestureIcon); BoardGestureGeometry2.Geometry = Geometry.Parse("F0 M24,24z M0,0z"); } - else { + else + { TwoFingerGestureSimpleStackPanel.Opacity = 1; TwoFingerGestureSimpleStackPanel.IsHitTestVisible = true; - if (Settings.Gesture.IsEnableTwoFingerGesture) { + if (Settings.Gesture.IsEnableTwoFingerGesture) + { EnableTwoFingerGestureBtn.Source = new BitmapImage(new Uri("/Resources/new-icons/gesture-enabled.png", UriKind.Relative)); - + BoardGesture.Background = new SolidColorBrush(Color.FromRgb(37, 99, 235)); BoardGestureGeometry.Brush = new SolidColorBrush(Colors.GhostWhite); BoardGestureGeometry2.Brush = new SolidColorBrush(Colors.GhostWhite); BoardGestureLabel.Foreground = new SolidColorBrush(Colors.GhostWhite); BoardGesture.BorderBrush = new SolidColorBrush(Color.FromRgb(37, 99, 235)); BoardGestureGeometry.Geometry = Geometry.Parse(XamlGraphicsIconGeometries.EnabledGestureIcon); - BoardGestureGeometry2.Geometry = Geometry.Parse("F0 M24,24z M0,0z "+XamlGraphicsIconGeometries.EnabledGestureIconBadgeCheck); + BoardGestureGeometry2.Geometry = Geometry.Parse("F0 M24,24z M0,0z " + XamlGraphicsIconGeometries.EnabledGestureIconBadgeCheck); } - else { + else + { EnableTwoFingerGestureBtn.Source = new BitmapImage(new Uri(gestureIconPath, UriKind.Relative)); - + BoardGesture.Background = new SolidColorBrush(boardBgColor); BoardGestureGeometry.Brush = new SolidColorBrush(boardIconColor); BoardGestureGeometry2.Brush = new SolidColorBrush(boardIconColor); diff --git a/Ink Canvas/MainWindow_cs/MW_Settings.cs b/Ink Canvas/MainWindow_cs/MW_Settings.cs index d8b688b4..e251e5f3 100644 --- a/Ink Canvas/MainWindow_cs/MW_Settings.cs +++ b/Ink Canvas/MainWindow_cs/MW_Settings.cs @@ -5,8 +5,8 @@ using OSVersionExtension; using System; using System.Diagnostics; using System.IO; -using System.Threading.Tasks; using System.Net.Http; +using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Forms; @@ -1031,7 +1031,7 @@ namespace Ink_Canvas bool isHalfOpacity = (bool)((CheckBox)sender).IsChecked; c[1] = isHalfOpacity ? '2' : '1'; Settings.PowerPointSettings.PPTSButtonsOption = int.Parse(new string(c)); - + // 如果开启半透明选项,设置默认透明度为0.5;否则为1.0 if (isHalfOpacity) { @@ -1051,7 +1051,7 @@ namespace Ink_Canvas PPTLSButtonOpacityValueSlider.Value = Settings.PowerPointSettings.PPTLSButtonOpacity; PPTRSButtonOpacityValueSlider.Value = Settings.PowerPointSettings.PPTRSButtonOpacity; } - + SaveSettingsToFile(); // 更新PPT UI管理器设置 if (_pptUIManager != null && BtnPPTSlideShowEnd.Visibility == Visibility.Visible) @@ -1106,7 +1106,7 @@ namespace Ink_Canvas bool isHalfOpacity = (bool)((CheckBox)sender).IsChecked; c[1] = isHalfOpacity ? '2' : '1'; Settings.PowerPointSettings.PPTBButtonsOption = int.Parse(new string(c)); - + // 如果开启半透明选项,设置默认透明度为0.5;否则为1.0 if (isHalfOpacity) { @@ -1126,7 +1126,7 @@ namespace Ink_Canvas PPTLBButtonOpacityValueSlider.Value = Settings.PowerPointSettings.PPTLBButtonOpacity; PPTRBButtonOpacityValueSlider.Value = Settings.PowerPointSettings.PPTRBButtonOpacity; } - + SaveSettingsToFile(); UpdatePPTUIManagerSettings(); UpdatePPTBtnPreview(); diff --git a/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs b/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs index 669226ae..55ee9522 100644 --- a/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs +++ b/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs @@ -557,12 +557,12 @@ namespace Ink_Canvas // 重用之前定义的sopsc和bopsc变量 bool isSideHalfOpacity = sopsc.Length >= 2 && sopsc[1] == '2'; // 如果透明度为0或未设置,根据半透明选项设置默认值 - if (Settings.PowerPointSettings.PPTLSButtonOpacity == 0.0 || + if (Settings.PowerPointSettings.PPTLSButtonOpacity == 0.0 || (Settings.PowerPointSettings.PPTLSButtonOpacity == 1.0 && isSideHalfOpacity)) { Settings.PowerPointSettings.PPTLSButtonOpacity = isSideHalfOpacity ? 0.5 : 1.0; } - if (Settings.PowerPointSettings.PPTRSButtonOpacity == 0.0 || + if (Settings.PowerPointSettings.PPTRSButtonOpacity == 0.0 || (Settings.PowerPointSettings.PPTRSButtonOpacity == 1.0 && isSideHalfOpacity)) { Settings.PowerPointSettings.PPTRSButtonOpacity = isSideHalfOpacity ? 0.5 : 1.0; @@ -572,12 +572,12 @@ namespace Ink_Canvas bool isBottomHalfOpacity = bopsc.Length >= 2 && bopsc[1] == '2'; // 如果透明度为0或未设置,根据半透明选项设置默认值 - if (Settings.PowerPointSettings.PPTLBButtonOpacity == 0.0 || + if (Settings.PowerPointSettings.PPTLBButtonOpacity == 0.0 || (Settings.PowerPointSettings.PPTLBButtonOpacity == 1.0 && isBottomHalfOpacity)) { Settings.PowerPointSettings.PPTLBButtonOpacity = isBottomHalfOpacity ? 0.5 : 1.0; } - if (Settings.PowerPointSettings.PPTRBButtonOpacity == 0.0 || + if (Settings.PowerPointSettings.PPTRBButtonOpacity == 0.0 || (Settings.PowerPointSettings.PPTRBButtonOpacity == 1.0 && isBottomHalfOpacity)) { Settings.PowerPointSettings.PPTRBButtonOpacity = isBottomHalfOpacity ? 0.5 : 1.0; diff --git a/Ink Canvas/Windows/NewStyleRollCallWindow.cs b/Ink Canvas/Windows/NewStyleRollCallWindow.cs index f0803e54..86f16a7e 100644 --- a/Ink Canvas/Windows/NewStyleRollCallWindow.cs +++ b/Ink Canvas/Windows/NewStyleRollCallWindow.cs @@ -591,9 +591,9 @@ namespace Ink_Canvas for (int i = 0; i < count && candidatePool.Count > 0; i++) { int randomIndex = random.Next(0, candidatePool.Count); - + selectedNames.Add(candidatePool[randomIndex]); - + int lastIndex = candidatePool.Count - 1; if (randomIndex != lastIndex) { @@ -1258,17 +1258,17 @@ namespace Ink_Canvas // 清空名单 nameList.Clear(); UpdateListCountDisplay(); - + // 清空点名历史记录 lock (historyLock) { // 重置历史记录数据 historyData = new RollCallHistoryData(); - + // 保存到文件 SaveRollCallHistory(); } - + UpdateStatusDisplay("名单和历史记录已清空"); } catch (Exception ex) diff --git a/Ink Canvas/Windows/RandWindow.xaml.cs b/Ink Canvas/Windows/RandWindow.xaml.cs index baf58235..894edba0 100644 --- a/Ink Canvas/Windows/RandWindow.xaml.cs +++ b/Ink Canvas/Windows/RandWindow.xaml.cs @@ -107,8 +107,7 @@ namespace Ink_Canvas if (settings.RandSettings.SelectedBackgroundIndex <= 0) { // 没有自定义背景时,使用主题背景色 - var backgroundBrush = Application.Current.FindResource("RandWindowBackground") as SolidColorBrush; - if (backgroundBrush != null) + if (Application.Current.FindResource("RandWindowBackground") is SolidColorBrush backgroundBrush) { MainBorder.Background = backgroundBrush; } @@ -238,7 +237,7 @@ namespace Ink_Canvas int randomIndex = random.Next(0, animationPool.Count); int selectedNumber = animationPool[randomIndex]; - + int lastIndex = animationPool.Count - 1; if (randomIndex != lastIndex) { @@ -273,7 +272,7 @@ namespace Ink_Canvas { int randomIndex = random.Next(0, candidatePool.Count); int selectedNumber = candidatePool[randomIndex]; - + int lastIndex = candidatePool.Count - 1; if (randomIndex != lastIndex) {