This commit is contained in:
2025-10-01 00:49:12 +08:00
parent 46b064b0a8
commit 07a62d2f78
18 changed files with 229 additions and 52 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ namespace Ink_Canvas
public static string RootPath = Environment.GetEnvironmentVariable("APPDATA") + "\\Ink Canvas\\"; public static string RootPath = Environment.GetEnvironmentVariable("APPDATA") + "\\Ink Canvas\\";
// 新增:标记是否通过--board参数启动 // 新增:标记是否通过--board参数启动
public static bool StartWithBoardMode = false; public static bool StartWithBoardMode;
// 新增:保存看门狗进程对象 // 新增:保存看门狗进程对象
private static Process watchdogProcess; private static Process watchdogProcess;
// 新增:标记是否为软件内主动退出 // 新增:标记是否为软件内主动退出
@@ -229,7 +229,7 @@ namespace Ink_Canvas.Helpers
private readonly Dictionary<IntPtr, DateTime> _lastScanTime = new Dictionary<IntPtr, DateTime>(); private readonly Dictionary<IntPtr, DateTime> _lastScanTime = new Dictionary<IntPtr, DateTime>();
private readonly HashSet<IntPtr> _knownWindows = new HashSet<IntPtr>(); private readonly HashSet<IntPtr> _knownWindows = new HashSet<IntPtr>();
private readonly Dictionary<string, DateTime> _processLastScanTime = new Dictionary<string, DateTime>(); private readonly Dictionary<string, DateTime> _processLastScanTime = new Dictionary<string, DateTime>();
private int _consecutiveEmptyScans = 0; private int _consecutiveEmptyScans;
private DateTime _lastSuccessfulScan = DateTime.Now; private DateTime _lastSuccessfulScan = DateTime.Now;
private readonly object _scanLock = new object(); private readonly object _scanLock = new object();
+3 -3
View File
@@ -24,12 +24,12 @@ namespace Ink_Canvas.Helpers
// 多屏幕支持相关字段 // 多屏幕支持相关字段
private Screen _currentScreen; private Screen _currentScreen;
private bool _isMultiScreenMode = false; private bool _isMultiScreenMode;
private bool _enableScreenSpecificHotkeys = true; // 是否启用基于屏幕的热键注册 private bool _enableScreenSpecificHotkeys = true; // 是否启用基于屏幕的热键注册
// 智能热键管理相关字段 // 智能热键管理相关字段
private bool _isWindowFocused = false; private bool _isWindowFocused;
private bool _isMouseOverWindow = false; private bool _isMouseOverWindow;
private System.Windows.Threading.DispatcherTimer _mousePositionTimer; private System.Windows.Threading.DispatcherTimer _mousePositionTimer;
// 配置文件路径 // 配置文件路径
+1 -1
View File
@@ -30,7 +30,7 @@ namespace Ink_Canvas.Helpers
public class StrokeVisual : DrawingVisual public class StrokeVisual : DrawingVisual
{ {
private bool _needsRedraw = true; private bool _needsRedraw = true;
private int _lastPointCount = 0; private int _lastPointCount;
private const int REDRAW_THRESHOLD = 3; private const int REDRAW_THRESHOLD = 3;
/// <summary> /// <summary>
+1 -1
View File
@@ -37,7 +37,7 @@ namespace Ink_Canvas.Helpers
private const int MinSwitchIntervalMs = 100; // 最小切换间隔100毫秒 private const int MinSwitchIntervalMs = 100; // 最小切换间隔100毫秒
// 内存管理相关字段 // 内存管理相关字段
private long _totalMemoryUsage = 0; private long _totalMemoryUsage;
private const long MaxMemoryUsageBytes = 100 * 1024 * 1024; // 100MB限制 private const long MaxMemoryUsageBytes = 100 * 1024 * 1024; // 100MB限制
private DateTime _lastMemoryCleanup = DateTime.MinValue; private DateTime _lastMemoryCleanup = DateTime.MinValue;
private const int MemoryCleanupIntervalMinutes = 5; // 5分钟清理一次 private const int MemoryCleanupIntervalMinutes = 5; // 5分钟清理一次
+33
View File
@@ -3242,6 +3242,39 @@
FontFamily="Consolas" FontFamily="Consolas"
Text="{Binding ElementName=RandWindowOnceMaxStudentsSlider, Path=Value, Converter={StaticResource IntNumberToString}}" /> Text="{Binding ElementName=RandWindowOnceMaxStudentsSlider, Path=Value, Converter={StaticResource IntNumberToString}}" />
</ui:SimpleStackPanel> </ui:SimpleStackPanel>
<Line HorizontalAlignment="Center" X1="0" Y1="0" X2="400" Y2="0"
Stroke="#3f3f46" StrokeThickness="1" Margin="0,4,0,4" />
<TextBlock Foreground="#fafafa" Text="计时器设置"
FontSize="16" FontWeight="Bold" Margin="0,10,0,5" />
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock Foreground="#fafafa" Text="使用老版计时器按钮UI"
VerticalAlignment="Center" FontSize="14" Margin="0,0,16,0" />
<ui:ToggleSwitch OnContent="" OffContent=""
Name="ToggleSwitchUseLegacyTimerUI"
IsOn="False" FontFamily="Microsoft YaHei UI"
FontWeight="Bold"
Toggled="ToggleSwitchUseLegacyTimerUI_Toggled" />
</ui:SimpleStackPanel>
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock Foreground="#fafafa" Text="计时器提醒音量" VerticalAlignment="Center"
FontSize="14" Margin="0,0,16,0" />
<Slider x:Name="TimerVolumeSlider" Minimum="0"
Maximum="1" Width="168" FontFamily="Microsoft YaHei UI"
ValueChanged="TimerVolumeSlider_ValueChanged"
FontSize="20" IsSnapToTickEnabled="True" Value="1" TickFrequency="0.1"
TickPlacement="None" AutoToolTipPlacement="None" />
<TextBlock VerticalAlignment="Center" Margin="12,0,16,0" FontSize="14"
FontFamily="Consolas"
Text="{Binding ElementName=TimerVolumeSlider, Path=Value, StringFormat={}{0:P0}}" />
</ui:SimpleStackPanel>
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,5,0,0">
<TextBlock Foreground="#fafafa" Text="自定义提醒铃声:" VerticalAlignment="Center"
FontSize="14" Margin="0,0,16,0" />
<Button Name="ButtonSelectCustomTimerSound" Content="选择文件" FontFamily="Microsoft YaHei UI"
Click="ButtonSelectCustomTimerSound_Click" Padding="10,3"/>
<Button Name="ButtonResetTimerSound" Content="重置" FontFamily="Microsoft YaHei UI"
Click="ButtonResetTimerSound_Click" Padding="10,3" Margin="5,0,0,0"/>
</ui:SimpleStackPanel>
</ui:SimpleStackPanel> </ui:SimpleStackPanel>
</GroupBox> </GroupBox>
<GroupBox> <GroupBox>
@@ -1493,7 +1493,7 @@ namespace Ink_Canvas
#region Image Resize Handles #region Image Resize Handles
// 图片缩放选择点相关变量 // 图片缩放选择点相关变量
private bool isResizingImage = false; private bool isResizingImage;
private Point imageResizeStartPoint; private Point imageResizeStartPoint;
private string activeResizeHandle = ""; private string activeResizeHandle = "";
+5 -5
View File
@@ -13,14 +13,14 @@ namespace Ink_Canvas
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
// 橡皮擦系统核心变量 // 橡皮擦系统核心变量
public bool isUsingGeometryEraser = false; public bool isUsingGeometryEraser;
private IncrementalStrokeHitTester hitTester = null; private IncrementalStrokeHitTester hitTester;
public double eraserWidth = 64; public double eraserWidth = 64;
public bool isEraserCircleShape = false; public bool isEraserCircleShape;
public bool isUsingStrokesEraser = false; public bool isUsingStrokesEraser;
private Matrix scaleMatrix = new Matrix(); private Matrix scaleMatrix;
// 橡皮擦覆盖层相关控件 // 橡皮擦覆盖层相关控件
private System.Windows.Controls.Canvas eraserOverlayCanvas; private System.Windows.Controls.Canvas eraserOverlayCanvas;
+2 -2
View File
@@ -91,8 +91,8 @@ namespace Ink_Canvas
private const int ProcessMonitorInterval = 1000; // 应用程序监控间隔(毫秒) private const int ProcessMonitorInterval = 1000; // 应用程序监控间隔(毫秒)
// 上次播放位置相关字段 // 上次播放位置相关字段
private int _lastPlaybackPage = 0; private int _lastPlaybackPage;
private bool _shouldNavigateToLastPage = false; private bool _shouldNavigateToLastPage;
// 页面切换防抖机制 // 页面切换防抖机制
private DateTime _lastSlideSwitchTime = DateTime.MinValue; private DateTime _lastSlideSwitchTime = DateTime.MinValue;
@@ -255,12 +255,12 @@ namespace Ink_Canvas
#endregion #endregion
private bool isGridInkCanvasSelectionCoverMouseDown; private bool isGridInkCanvasSelectionCoverMouseDown;
private bool isStrokeDragging = false; private bool isStrokeDragging;
private Point strokeDragStartPoint; private Point strokeDragStartPoint;
private StrokeCollection StrokesSelectionClone = new StrokeCollection(); private StrokeCollection StrokesSelectionClone = new StrokeCollection();
// 选择框和选择点相关变量 // 选择框和选择点相关变量
private bool isResizing = false; private bool isResizing;
private string currentResizeHandle = ""; private string currentResizeHandle = "";
private Point resizeStartPoint; private Point resizeStartPoint;
private Rect originalSelectionBounds; private Rect originalSelectionBounds;
+38
View File
@@ -2516,6 +2516,44 @@ namespace Ink_Canvas
SaveSettingsToFile(); SaveSettingsToFile();
} }
private void ToggleSwitchUseLegacyTimerUI_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.RandSettings.UseLegacyTimerUI = ToggleSwitchUseLegacyTimerUI.IsOn;
SaveSettingsToFile();
}
private void TimerVolumeSlider_ValueChanged(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.RandSettings.TimerVolume = TimerVolumeSlider.Value;
SaveSettingsToFile();
}
private void ButtonSelectCustomTimerSound_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog
{
Title = "选择计时器提醒铃声",
Filter = "音频文件 (*.wav)|*.wav|所有文件 (*.*)|*.*",
DefaultExt = "wav"
};
if (openFileDialog.ShowDialog() == true)
{
Settings.RandSettings.CustomTimerSoundPath = openFileDialog.FileName;
SaveSettingsToFile();
MessageBox.Show("自定义铃声设置成功!", "设置成功", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
private void ButtonResetTimerSound_Click(object sender, RoutedEventArgs e)
{
Settings.RandSettings.CustomTimerSoundPath = "";
SaveSettingsToFile();
MessageBox.Show("已重置为默认铃声!", "重置成功", MessageBoxButton.OK, MessageBoxImage.Information);
}
private void ToggleSwitchShowRandomAndSingleDraw_Toggled(object sender, RoutedEventArgs e) private void ToggleSwitchShowRandomAndSingleDraw_Toggled(object sender, RoutedEventArgs e)
{ {
if (!isLoaded) return; if (!isLoaded) return;
@@ -856,6 +856,10 @@ namespace Ink_Canvas
RandomDrawPanel.Visibility = Settings.RandSettings.ShowRandomAndSingleDraw ? Visibility.Visible : Visibility.Collapsed; RandomDrawPanel.Visibility = Settings.RandSettings.ShowRandomAndSingleDraw ? Visibility.Visible : Visibility.Collapsed;
SingleDrawPanel.Visibility = Settings.RandSettings.ShowRandomAndSingleDraw ? Visibility.Visible : Visibility.Collapsed; SingleDrawPanel.Visibility = Settings.RandSettings.ShowRandomAndSingleDraw ? Visibility.Visible : Visibility.Collapsed;
// 计时器设置
ToggleSwitchUseLegacyTimerUI.IsOn = Settings.RandSettings.UseLegacyTimerUI;
TimerVolumeSlider.Value = Settings.RandSettings.TimerVolume;
// 加载自定义点名背景 // 加载自定义点名背景
UpdatePickNameBackgroundsInComboBox(); UpdatePickNameBackgroundsInComboBox();
@@ -874,6 +878,8 @@ namespace Ink_Canvas
RandWindowOnceMaxStudentsSlider.Value = Settings.RandSettings.RandWindowOnceMaxStudents; RandWindowOnceMaxStudentsSlider.Value = Settings.RandSettings.RandWindowOnceMaxStudents;
ToggleSwitchExternalCaller.IsOn = Settings.RandSettings.DirectCallCiRand; ToggleSwitchExternalCaller.IsOn = Settings.RandSettings.DirectCallCiRand;
ComboBoxExternalCallerType.SelectedIndex = Settings.RandSettings.ExternalCallerType; ComboBoxExternalCallerType.SelectedIndex = Settings.RandSettings.ExternalCallerType;
ToggleSwitchUseLegacyTimerUI.IsOn = Settings.RandSettings.UseLegacyTimerUI;
TimerVolumeSlider.Value = Settings.RandSettings.TimerVolume;
} }
// ModeSettings // ModeSettings
+2 -2
View File
@@ -71,10 +71,10 @@ namespace Ink_Canvas
private DateTime cachedNetworkTime = DateTime.Now; private DateTime cachedNetworkTime = DateTime.Now;
private DateTime lastNtpSyncTime = DateTime.MinValue; private DateTime lastNtpSyncTime = DateTime.MinValue;
private string lastDisplayedTime = ""; private string lastDisplayedTime = "";
private bool useNetworkTime = false; private bool useNetworkTime;
private TimeSpan networkTimeOffset = TimeSpan.Zero; private TimeSpan networkTimeOffset = TimeSpan.Zero;
private DateTime lastLocalTime = DateTime.Now; // 记录上次的本地时间,用于检测时间跳跃 private DateTime lastLocalTime = DateTime.Now; // 记录上次的本地时间,用于检测时间跳跃
private bool isNtpSyncing = false; // 防止重复NTP同步的标志 private bool isNtpSyncing; // 防止重复NTP同步的标志
private async Task<DateTime> GetNetworkTimeAsync() private async Task<DateTime> GetNetworkTimeAsync()
{ {
+1 -2
View File
@@ -24,8 +24,7 @@ namespace Ink_Canvas
private InkCanvasEditingMode lastInkCanvasEditingMode = InkCanvasEditingMode.Ink; private InkCanvasEditingMode lastInkCanvasEditingMode = InkCanvasEditingMode.Ink;
private DateTime lastTouchDownTime = DateTime.MinValue; private DateTime lastTouchDownTime = DateTime.MinValue;
private const double MULTI_TOUCH_DELAY_MS = 100; private const double MULTI_TOUCH_DELAY_MS = 100;
private bool isInWritingMode = false; private bool isMultiTouchTimerActive;
private bool isMultiTouchTimerActive = false;
/// </summary> /// </summary>
/// 保存画布上的非笔画元素(如图片、媒体元素等) /// 保存画布上的非笔画元素(如图片、媒体元素等)
+16 -10
View File
@@ -91,7 +91,7 @@ namespace Ink_Canvas
[JsonProperty("enablePalmEraser")] [JsonProperty("enablePalmEraser")]
public bool EnablePalmEraser { get; set; } = true; public bool EnablePalmEraser { get; set; } = true;
[JsonProperty("palmEraserSensitivity")] [JsonProperty("palmEraserSensitivity")]
public int PalmEraserSensitivity { get; set; } = 0; // 0-低敏感度, 1-中敏感度, 2-高敏感度 public int PalmEraserSensitivity { get; set; } // 0-低敏感度, 1-中敏感度, 2-高敏感度
[JsonProperty("clearCanvasAlsoClearImages")] [JsonProperty("clearCanvasAlsoClearImages")]
public bool ClearCanvasAlsoClearImages { get; set; } = true; public bool ClearCanvasAlsoClearImages { get; set; } = true;
[JsonProperty("showCircleCenter")] [JsonProperty("showCircleCenter")]
@@ -99,7 +99,7 @@ namespace Ink_Canvas
// 墨迹渐隐功能设置 // 墨迹渐隐功能设置
[JsonProperty("enableInkFade")] [JsonProperty("enableInkFade")]
public bool EnableInkFade { get; set; } = false; public bool EnableInkFade { get; set; }
[JsonProperty("inkFadeTime")] [JsonProperty("inkFadeTime")]
public int InkFadeTime { get; set; } = 3000; // 墨迹渐隐时间(毫秒) public int InkFadeTime { get; set; } = 3000; // 墨迹渐隐时间(毫秒)
@@ -236,7 +236,7 @@ namespace Ink_Canvas
public int QuickColorPaletteDisplayMode { get; set; } = 1; public int QuickColorPaletteDisplayMode { get; set; } = 1;
[JsonProperty("enableHotkeysInMouseMode")] [JsonProperty("enableHotkeysInMouseMode")]
public bool EnableHotkeysInMouseMode { get; set; } = false; public bool EnableHotkeysInMouseMode { get; set; }
} }
@@ -310,9 +310,9 @@ namespace Ink_Canvas
[JsonProperty("isAlwaysGoToFirstPageOnReenter")] [JsonProperty("isAlwaysGoToFirstPageOnReenter")]
public bool IsAlwaysGoToFirstPageOnReenter { get; set; } public bool IsAlwaysGoToFirstPageOnReenter { get; set; }
[JsonProperty("enablePowerPointEnhancement")] [JsonProperty("enablePowerPointEnhancement")]
public bool EnablePowerPointEnhancement { get; set; } = false; public bool EnablePowerPointEnhancement { get; set; }
[JsonProperty("showGestureButtonInSlideShow")] [JsonProperty("showGestureButtonInSlideShow")]
public bool ShowGestureButtonInSlideShow { get; set; } = false; public bool ShowGestureButtonInSlideShow { get; set; }
} }
public class Automation public class Automation
@@ -452,7 +452,7 @@ namespace Ink_Canvas
public int AutoDelSavedFilesDaysThreshold = 15; public int AutoDelSavedFilesDaysThreshold = 15;
[JsonProperty("keepFoldAfterSoftwareExit")] [JsonProperty("keepFoldAfterSoftwareExit")]
public bool KeepFoldAfterSoftwareExit { get; set; } = false; public bool KeepFoldAfterSoftwareExit { get; set; }
[JsonProperty("isSaveFullPageStrokes")] [JsonProperty("isSaveFullPageStrokes")]
public bool IsSaveFullPageStrokes; public bool IsSaveFullPageStrokes;
@@ -467,13 +467,13 @@ namespace Ink_Canvas
public class FloatingWindowInterceptorSettings public class FloatingWindowInterceptorSettings
{ {
[JsonProperty("isEnabled")] [JsonProperty("isEnabled")]
public bool IsEnabled { get; set; } = false; public bool IsEnabled { get; set; }
[JsonProperty("scanIntervalMs")] [JsonProperty("scanIntervalMs")]
public int ScanIntervalMs { get; set; } = 5000; public int ScanIntervalMs { get; set; } = 5000;
[JsonProperty("autoStart")] [JsonProperty("autoStart")]
public bool AutoStart { get; set; } = false; public bool AutoStart { get; set; }
[JsonProperty("showNotifications")] [JsonProperty("showNotifications")]
public bool ShowNotifications { get; set; } = true; public bool ShowNotifications { get; set; } = true;
@@ -622,11 +622,17 @@ namespace Ink_Canvas
[JsonProperty("directCallCiRand")] [JsonProperty("directCallCiRand")]
public bool DirectCallCiRand { get; set; } public bool DirectCallCiRand { get; set; }
[JsonProperty("externalCallerType")] [JsonProperty("externalCallerType")]
public int ExternalCallerType { get; set; } = 0; public int ExternalCallerType { get; set; }
[JsonProperty("selectedBackgroundIndex")] [JsonProperty("selectedBackgroundIndex")]
public int SelectedBackgroundIndex { get; set; } public int SelectedBackgroundIndex { get; set; }
[JsonProperty("customPickNameBackgrounds")] [JsonProperty("customPickNameBackgrounds")]
public List<CustomPickNameBackground> CustomPickNameBackgrounds { get; set; } = new List<CustomPickNameBackground>(); public List<CustomPickNameBackground> CustomPickNameBackgrounds { get; set; } = new List<CustomPickNameBackground>();
[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 public class CustomPickNameBackground
@@ -668,6 +674,6 @@ namespace Ink_Canvas
public class ModeSettings public class ModeSettings
{ {
[JsonProperty("isPPTOnlyMode")] [JsonProperty("isPPTOnlyMode")]
public bool IsPPTOnlyMode { get; set; } = false; // 是否为仅PPT模式,默认为false(正常模式) public bool IsPPTOnlyMode { get; set; } // 是否为仅PPT模式,默认为false(正常模式)
} }
} }
+12 -12
View File
@@ -44,18 +44,18 @@
<Grid Name="GridAdjustHour" Visibility="Visible" Margin="-29,-30,0,-30" Width="29"> <Grid Name="GridAdjustHour" Visibility="Visible" Margin="-29,-30,0,-30" Width="29">
<ui:SimpleStackPanel Spacing="2"> <ui:SimpleStackPanel Spacing="2">
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_1"> <Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_1">
<TextBlock Text="∧∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/> <TextBlock x:Name="HourPlus5Text" Text="∧∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Button> </Button>
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click"> <Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click">
<TextBlock Text="∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/> <TextBlock x:Name="HourPlus1Text" Text="∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Button> </Button>
</ui:SimpleStackPanel> </ui:SimpleStackPanel>
<ui:SimpleStackPanel Spacing="2" VerticalAlignment="Bottom"> <ui:SimpleStackPanel Spacing="2" VerticalAlignment="Bottom">
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_2"> <Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_2">
<TextBlock Text="" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/> <TextBlock x:Name="HourMinus1Text" Text="" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Button> </Button>
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_3"> <Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_3">
<TextBlock Text="∨∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/> <TextBlock x:Name="HourMinus5Text" Text="∨∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Button> </Button>
</ui:SimpleStackPanel> </ui:SimpleStackPanel>
</Grid> </Grid>
@@ -91,18 +91,18 @@
<Grid Visibility="{Binding ElementName=GridAdjustHour, Path=Visibility}" Margin="-29,-30,0,-30" Width="29"> <Grid Visibility="{Binding ElementName=GridAdjustHour, Path=Visibility}" Margin="-29,-30,0,-30" Width="29">
<ui:SimpleStackPanel Spacing="2"> <ui:SimpleStackPanel Spacing="2">
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_5"> <Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_5">
<TextBlock Text="∧∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/> <TextBlock x:Name="MinutePlus5Text" Text="∧∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Button> </Button>
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_4"> <Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_4">
<TextBlock Text="∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/> <TextBlock x:Name="MinutePlus1Text" Text="∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Button> </Button>
</ui:SimpleStackPanel> </ui:SimpleStackPanel>
<ui:SimpleStackPanel Spacing="2" VerticalAlignment="Bottom"> <ui:SimpleStackPanel Spacing="2" VerticalAlignment="Bottom">
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_6"> <Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_6">
<TextBlock Text="" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/> <TextBlock x:Name="MinuteMinus1Text" Text="" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Button> </Button>
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_7"> <Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_7">
<TextBlock Text="∨∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/> <TextBlock x:Name="MinuteMinus5Text" Text="∨∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Button> </Button>
</ui:SimpleStackPanel> </ui:SimpleStackPanel>
<Border x:Name="BtnTimeSetOkay" MouseUp="Grid_MouseUp" <Border x:Name="BtnTimeSetOkay" MouseUp="Grid_MouseUp"
@@ -151,18 +151,18 @@
<Grid Visibility="{Binding ElementName=GridAdjustHour, Path=Visibility}" Margin="-29,-30,0,-30" Width="29"> <Grid Visibility="{Binding ElementName=GridAdjustHour, Path=Visibility}" Margin="-29,-30,0,-30" Width="29">
<ui:SimpleStackPanel Spacing="2"> <ui:SimpleStackPanel Spacing="2">
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_8"> <Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_8">
<TextBlock Text="∧∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/> <TextBlock x:Name="SecondPlus5Text" Text="∧∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Button> </Button>
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_9"> <Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_9">
<TextBlock Text="∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/> <TextBlock x:Name="SecondPlus1Text" Text="∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Button> </Button>
</ui:SimpleStackPanel> </ui:SimpleStackPanel>
<ui:SimpleStackPanel Spacing="2" VerticalAlignment="Bottom"> <ui:SimpleStackPanel Spacing="2" VerticalAlignment="Bottom">
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_10"> <Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_10">
<TextBlock Text="" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/> <TextBlock x:Name="SecondMinus1Text" Text="" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Button> </Button>
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_11"> <Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_11">
<TextBlock Text="∨∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/> <TextBlock x:Name="SecondMinus5Text" Text="∨∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Button> </Button>
</ui:SimpleStackPanel> </ui:SimpleStackPanel>
</Grid> </Grid>
+102 -7
View File
@@ -1,4 +1,5 @@
using Ink_Canvas.Helpers; using Ink_Canvas.Helpers;
using Ink_Canvas.Resources;
using System; using System;
using System.Media; using System.Media;
using System.Timers; using System.Timers;
@@ -6,6 +7,7 @@ using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Interop; using System.Windows.Interop;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace Ink_Canvas namespace Ink_Canvas
{ {
@@ -21,6 +23,7 @@ namespace Ink_Canvas
timer.Elapsed += Timer_Elapsed; timer.Elapsed += Timer_Elapsed;
timer.Interval = 50; timer.Interval = 50;
InitializeUI();
} }
private void Timer_Elapsed(object sender, ElapsedEventArgs e) private void Timer_Elapsed(object sender, ElapsedEventArgs e)
@@ -62,24 +65,25 @@ namespace Ink_Canvas
Application.Current.Dispatcher.Invoke(() => Application.Current.Dispatcher.Invoke(() =>
{ {
//Play sound //Play sound
player.Stream = Properties.Resources.TimerDownNotice; PlayTimerSound();
player.Play();
}); });
} }
} }
SoundPlayer player = new SoundPlayer(); SoundPlayer player = new SoundPlayer();
MediaPlayer mediaPlayer = new MediaPlayer();
int hour = 0; int hour;
int minute = 1; int minute = 1;
int second = 0; int second;
int totalSeconds = 60; int totalSeconds = 60;
DateTime startTime = DateTime.Now; DateTime startTime = DateTime.Now;
DateTime pauseTime = DateTime.Now; DateTime pauseTime = DateTime.Now;
bool isTimerRunning = false; bool isTimerRunning;
bool isPaused = false; bool isPaused;
bool useLegacyUI;
Timer timer = new Timer(); Timer timer = new Timer();
@@ -334,6 +338,97 @@ 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) private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{ {
isTimerRunning = false; isTimerRunning = false;
@@ -344,7 +439,7 @@ namespace Ink_Canvas
Close(); Close();
} }
private bool _isInCompact = false; private bool _isInCompact;
private void BtnMinimal_OnMouseUp(object sender, MouseButtonEventArgs e) private void BtnMinimal_OnMouseUp(object sender, MouseButtonEventArgs e)
{ {
@@ -398,7 +398,7 @@ namespace Ink_Canvas.Windows
((Border)border).Background = new SolidColorBrush(Color.FromRgb(138, 138, 138)); ((Border)border).Background = new SolidColorBrush(Color.FromRgb(138, 138, 138));
} }
private Border _sidebarItemMouseDownBorder = null; private Border _sidebarItemMouseDownBorder;
private void SidebarItem_MouseDown(object sender, MouseButtonEventArgs e) private void SidebarItem_MouseDown(object sender, MouseButtonEventArgs e)
{ {
@@ -999,7 +999,7 @@ namespace Ink_Canvas.Windows
public Image ThumbImage { get; set; } public Image ThumbImage { get; set; }
public Border TrackBorder { get; set; } public Border TrackBorder { get; set; }
public Border ValueBorder { get; set; } public Border ValueBorder { get; set; }
public bool IsTouchCaptured { get; set; } = false; public bool IsTouchCaptured { get; set; }
} }
#endregion #endregion