diff --git a/Ink Canvas/App.xaml.cs b/Ink Canvas/App.xaml.cs index 0bfdd393..2e4f8e12 100644 --- a/Ink Canvas/App.xaml.cs +++ b/Ink Canvas/App.xaml.cs @@ -35,7 +35,7 @@ namespace Ink_Canvas public static string RootPath = Environment.GetEnvironmentVariable("APPDATA") + "\\Ink Canvas\\"; // 新增:标记是否通过--board参数启动 - public static bool StartWithBoardMode; + public static bool StartWithBoardMode = false; // 新增:保存看门狗进程对象 private static Process watchdogProcess; // 新增:标记是否为软件内主动退出 diff --git a/Ink Canvas/Helpers/FloatingWindowInterceptor.cs b/Ink Canvas/Helpers/FloatingWindowInterceptor.cs index e6a63c31..665099e2 100644 --- a/Ink Canvas/Helpers/FloatingWindowInterceptor.cs +++ b/Ink Canvas/Helpers/FloatingWindowInterceptor.cs @@ -229,7 +229,7 @@ namespace Ink_Canvas.Helpers private readonly Dictionary _lastScanTime = new Dictionary(); private readonly HashSet _knownWindows = new HashSet(); private readonly Dictionary _processLastScanTime = new Dictionary(); - private int _consecutiveEmptyScans; + private int _consecutiveEmptyScans = 0; private DateTime _lastSuccessfulScan = DateTime.Now; private readonly object _scanLock = new object(); diff --git a/Ink Canvas/Helpers/GlobalHotkeyManager.cs b/Ink Canvas/Helpers/GlobalHotkeyManager.cs index ffd2a48b..917ee3f8 100644 --- a/Ink Canvas/Helpers/GlobalHotkeyManager.cs +++ b/Ink Canvas/Helpers/GlobalHotkeyManager.cs @@ -24,12 +24,12 @@ namespace Ink_Canvas.Helpers // 多屏幕支持相关字段 private Screen _currentScreen; - private bool _isMultiScreenMode; + private bool _isMultiScreenMode = false; private bool _enableScreenSpecificHotkeys = true; // 是否启用基于屏幕的热键注册 // 智能热键管理相关字段 - private bool _isWindowFocused; - private bool _isMouseOverWindow; + private bool _isWindowFocused = false; + private bool _isMouseOverWindow = false; private System.Windows.Threading.DispatcherTimer _mousePositionTimer; // 配置文件路径 diff --git a/Ink Canvas/Helpers/MultiTouchInput.cs b/Ink Canvas/Helpers/MultiTouchInput.cs index 4cc6f680..9764d2ca 100644 --- a/Ink Canvas/Helpers/MultiTouchInput.cs +++ b/Ink Canvas/Helpers/MultiTouchInput.cs @@ -30,7 +30,7 @@ namespace Ink_Canvas.Helpers public class StrokeVisual : DrawingVisual { private bool _needsRedraw = true; - private int _lastPointCount; + private int _lastPointCount = 0; private const int REDRAW_THRESHOLD = 3; /// diff --git a/Ink Canvas/Helpers/PPTInkManager.cs b/Ink Canvas/Helpers/PPTInkManager.cs index 57aa05b5..2fee446c 100644 --- a/Ink Canvas/Helpers/PPTInkManager.cs +++ b/Ink Canvas/Helpers/PPTInkManager.cs @@ -37,7 +37,7 @@ namespace Ink_Canvas.Helpers private const int MinSwitchIntervalMs = 100; // 最小切换间隔100毫秒 // 内存管理相关字段 - private long _totalMemoryUsage; + private long _totalMemoryUsage = 0; private const long MaxMemoryUsageBytes = 100 * 1024 * 1024; // 100MB限制 private DateTime _lastMemoryCleanup = DateTime.MinValue; private const int MemoryCleanupIntervalMinutes = 5; // 5分钟清理一次 diff --git a/Ink Canvas/MainWindow.xaml b/Ink Canvas/MainWindow.xaml index e9512fcb..49b07dd6 100644 --- a/Ink Canvas/MainWindow.xaml +++ b/Ink Canvas/MainWindow.xaml @@ -3242,39 +3242,6 @@ FontFamily="Consolas" Text="{Binding ElementName=RandWindowOnceMaxStudentsSlider, Path=Value, Converter={StaticResource IntNumberToString}}" /> - - - - - - - - - - - - - - /// 保存画布上的非笔画元素(如图片、媒体元素等) diff --git a/Ink Canvas/Resources/Settings.cs b/Ink Canvas/Resources/Settings.cs index 690e657c..5b62785b 100644 --- a/Ink Canvas/Resources/Settings.cs +++ b/Ink Canvas/Resources/Settings.cs @@ -91,7 +91,7 @@ namespace Ink_Canvas [JsonProperty("enablePalmEraser")] public bool EnablePalmEraser { get; set; } = true; [JsonProperty("palmEraserSensitivity")] - public int PalmEraserSensitivity { get; set; } // 0-低敏感度, 1-中敏感度, 2-高敏感度 + public int PalmEraserSensitivity { get; set; } = 0; // 0-低敏感度, 1-中敏感度, 2-高敏感度 [JsonProperty("clearCanvasAlsoClearImages")] public bool ClearCanvasAlsoClearImages { get; set; } = true; [JsonProperty("showCircleCenter")] @@ -99,7 +99,7 @@ namespace Ink_Canvas // 墨迹渐隐功能设置 [JsonProperty("enableInkFade")] - public bool EnableInkFade { get; set; } + public bool EnableInkFade { get; set; } = false; [JsonProperty("inkFadeTime")] public int InkFadeTime { get; set; } = 3000; // 墨迹渐隐时间(毫秒) @@ -236,7 +236,7 @@ namespace Ink_Canvas public int QuickColorPaletteDisplayMode { get; set; } = 1; [JsonProperty("enableHotkeysInMouseMode")] - public bool EnableHotkeysInMouseMode { get; set; } + public bool EnableHotkeysInMouseMode { get; set; } = false; } @@ -310,9 +310,9 @@ namespace Ink_Canvas [JsonProperty("isAlwaysGoToFirstPageOnReenter")] public bool IsAlwaysGoToFirstPageOnReenter { get; set; } [JsonProperty("enablePowerPointEnhancement")] - public bool EnablePowerPointEnhancement { get; set; } + public bool EnablePowerPointEnhancement { get; set; } = false; [JsonProperty("showGestureButtonInSlideShow")] - public bool ShowGestureButtonInSlideShow { get; set; } + public bool ShowGestureButtonInSlideShow { get; set; } = false; } public class Automation @@ -452,7 +452,7 @@ namespace Ink_Canvas public int AutoDelSavedFilesDaysThreshold = 15; [JsonProperty("keepFoldAfterSoftwareExit")] - public bool KeepFoldAfterSoftwareExit { get; set; } + public bool KeepFoldAfterSoftwareExit { get; set; } = false; [JsonProperty("isSaveFullPageStrokes")] public bool IsSaveFullPageStrokes; @@ -467,13 +467,13 @@ namespace Ink_Canvas public class FloatingWindowInterceptorSettings { [JsonProperty("isEnabled")] - public bool IsEnabled { get; set; } + public bool IsEnabled { get; set; } = false; [JsonProperty("scanIntervalMs")] public int ScanIntervalMs { get; set; } = 5000; [JsonProperty("autoStart")] - public bool AutoStart { get; set; } + public bool AutoStart { get; set; } = false; [JsonProperty("showNotifications")] public bool ShowNotifications { get; set; } = true; @@ -622,17 +622,11 @@ namespace Ink_Canvas [JsonProperty("directCallCiRand")] public bool DirectCallCiRand { get; set; } [JsonProperty("externalCallerType")] - public int ExternalCallerType { get; set; } + public int ExternalCallerType { get; set; } = 0; [JsonProperty("selectedBackgroundIndex")] public int SelectedBackgroundIndex { get; set; } [JsonProperty("customPickNameBackgrounds")] public List CustomPickNameBackgrounds { get; set; } = new List(); - [JsonProperty("useLegacyTimerUI")] - public bool UseLegacyTimerUI { get; set; } - [JsonProperty("timerVolume")] - public double TimerVolume { get; set; } = 1.0; - [JsonProperty("customTimerSoundPath")] - public string CustomTimerSoundPath { get; set; } = ""; } public class CustomPickNameBackground @@ -674,6 +668,6 @@ namespace Ink_Canvas public class ModeSettings { [JsonProperty("isPPTOnlyMode")] - public bool IsPPTOnlyMode { get; set; } // 是否为仅PPT模式,默认为false(正常模式) + public bool IsPPTOnlyMode { get; set; } = false; // 是否为仅PPT模式,默认为false(正常模式) } } diff --git a/Ink Canvas/Windows/CountdownTimerWindow.xaml b/Ink Canvas/Windows/CountdownTimerWindow.xaml index 0f820a2d..6fed4d88 100644 --- a/Ink Canvas/Windows/CountdownTimerWindow.xaml +++ b/Ink Canvas/Windows/CountdownTimerWindow.xaml @@ -44,18 +44,18 @@ @@ -91,18 +91,18 @@ diff --git a/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs b/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs index 588af4b9..a90e6b1d 100644 --- a/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs +++ b/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs @@ -1,5 +1,4 @@ using Ink_Canvas.Helpers; -using Ink_Canvas.Resources; using System; using System.Media; using System.Timers; @@ -7,7 +6,6 @@ using System.Windows; using System.Windows.Input; using System.Windows.Interop; using System.Windows.Media; -using System.Windows.Media.Imaging; namespace Ink_Canvas { @@ -23,7 +21,6 @@ namespace Ink_Canvas timer.Elapsed += Timer_Elapsed; timer.Interval = 50; - InitializeUI(); } private void Timer_Elapsed(object sender, ElapsedEventArgs e) @@ -65,25 +62,24 @@ namespace Ink_Canvas Application.Current.Dispatcher.Invoke(() => { //Play sound - PlayTimerSound(); + player.Stream = Properties.Resources.TimerDownNotice; + player.Play(); }); } } SoundPlayer player = new SoundPlayer(); - MediaPlayer mediaPlayer = new MediaPlayer(); - int hour; + int hour = 0; int minute = 1; - int second; + int second = 0; int totalSeconds = 60; DateTime startTime = DateTime.Now; DateTime pauseTime = DateTime.Now; - bool isTimerRunning; - bool isPaused; - bool useLegacyUI; + bool isTimerRunning = false; + bool isPaused = false; Timer timer = new Timer(); @@ -338,97 +334,6 @@ namespace Ink_Canvas } } - private void InitializeUI() - { - // 从设置中读取配置 - if (MainWindow.Settings.RandSettings != null) - { - useLegacyUI = MainWindow.Settings.RandSettings.UseLegacyTimerUI; - UpdateButtonTexts(); - } - } - - public void RefreshUI() - { - InitializeUI(); - } - - private void UpdateButtonTexts() - { - if (useLegacyUI) - { - // 老版UI:使用+5, +1, -1, -5 - HourPlus5Text.Text = "+5"; - HourPlus1Text.Text = "+1"; - HourMinus1Text.Text = "-1"; - HourMinus5Text.Text = "-5"; - - MinutePlus5Text.Text = "+5"; - MinutePlus1Text.Text = "+1"; - MinuteMinus1Text.Text = "-1"; - MinuteMinus5Text.Text = "-5"; - - SecondPlus5Text.Text = "+5"; - SecondPlus1Text.Text = "+1"; - SecondMinus1Text.Text = "-1"; - SecondMinus5Text.Text = "-5"; - } - else - { - // 新版UI:使用箭头符号 - HourPlus5Text.Text = "∧∧"; - HourPlus1Text.Text = "∧"; - HourMinus1Text.Text = "∨"; - HourMinus5Text.Text = "∨∨"; - - MinutePlus5Text.Text = "∧∧"; - MinutePlus1Text.Text = "∧"; - MinuteMinus1Text.Text = "∨"; - MinuteMinus5Text.Text = "∨∨"; - - SecondPlus5Text.Text = "∧∧"; - SecondPlus1Text.Text = "∧"; - SecondMinus1Text.Text = "∨"; - SecondMinus5Text.Text = "∨∨"; - } - } - - private void PlayTimerSound() - { - try - { - double volume = MainWindow.Settings.RandSettings?.TimerVolume ?? 1.0; - mediaPlayer.Volume = volume; - - if (!string.IsNullOrEmpty(MainWindow.Settings.RandSettings?.CustomTimerSoundPath) && - System.IO.File.Exists(MainWindow.Settings.RandSettings.CustomTimerSoundPath)) - { - // 播放自定义铃声 - mediaPlayer.Open(new Uri(MainWindow.Settings.RandSettings.CustomTimerSoundPath)); - } - else - { - // 播放默认铃声 - string tempPath = System.IO.Path.GetTempFileName() + ".wav"; - using (var stream = Properties.Resources.TimerDownNotice) - { - using (var fileStream = new System.IO.FileStream(tempPath, System.IO.FileMode.Create)) - { - stream.CopyTo(fileStream); - } - } - mediaPlayer.Open(new Uri(tempPath)); - } - - mediaPlayer.Play(); - } - catch (Exception ex) - { - // 如果播放失败,静默处理 - System.Diagnostics.Debug.WriteLine($"播放计时器铃声失败: {ex.Message}"); - } - } - private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { isTimerRunning = false; @@ -439,7 +344,7 @@ namespace Ink_Canvas Close(); } - private bool _isInCompact; + private bool _isInCompact = false; private void BtnMinimal_OnMouseUp(object sender, MouseButtonEventArgs e) { diff --git a/Ink Canvas/Windows/SettingsViews/SettingsWindow.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsWindow.xaml.cs index 2b9f621b..583f1021 100644 --- a/Ink Canvas/Windows/SettingsViews/SettingsWindow.xaml.cs +++ b/Ink Canvas/Windows/SettingsViews/SettingsWindow.xaml.cs @@ -398,7 +398,7 @@ namespace Ink_Canvas.Windows ((Border)border).Background = new SolidColorBrush(Color.FromRgb(138, 138, 138)); } - private Border _sidebarItemMouseDownBorder; + private Border _sidebarItemMouseDownBorder = null; private void SidebarItem_MouseDown(object sender, MouseButtonEventArgs e) { @@ -999,7 +999,7 @@ namespace Ink_Canvas.Windows public Image ThumbImage { get; set; } public Border TrackBorder { get; set; } public Border ValueBorder { get; set; } - public bool IsTouchCaptured { get; set; } + public bool IsTouchCaptured { get; set; } = false; } #endregion