代码清理
This commit is contained in:
@@ -865,7 +865,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
// 检查当前是否处于鼠标模式
|
// 检查当前是否处于鼠标模式
|
||||||
bool isMouseMode = IsInSelectMode();
|
bool isMouseMode = IsInSelectMode();
|
||||||
|
|
||||||
if (isMouseMode)
|
if (isMouseMode)
|
||||||
{
|
{
|
||||||
// 鼠标模式下,根据设置决定是否启用快捷键
|
// 鼠标模式下,根据设置决定是否启用快捷键
|
||||||
@@ -874,7 +874,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 非鼠标模式下,需要检查焦点和屏幕位置
|
// 非鼠标模式下,需要检查焦点和屏幕位置
|
||||||
|
|
||||||
// 策略1:鼠标在窗口上时启用热键(最高优先级)
|
// 策略1:鼠标在窗口上时启用热键(最高优先级)
|
||||||
if (_isMouseOverWindow)
|
if (_isMouseOverWindow)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -839,7 +839,7 @@ namespace Ink_Canvas
|
|||||||
// 检测到新版本,停止重试定时器
|
// 检测到新版本,停止重试定时器
|
||||||
timerCheckAutoUpdateRetry.Stop();
|
timerCheckAutoUpdateRetry.Stop();
|
||||||
updateCheckRetryCount = 0;
|
updateCheckRetryCount = 0;
|
||||||
|
|
||||||
// 检测到新版本
|
// 检测到新版本
|
||||||
LogHelper.WriteLogToFile($"AutoUpdate | New version available: {AvailableLatestVersion}");
|
LogHelper.WriteLogToFile($"AutoUpdate | New version available: {AvailableLatestVersion}");
|
||||||
|
|
||||||
@@ -1006,7 +1006,7 @@ namespace Ink_Canvas
|
|||||||
else if (hasValidLineGroup)
|
else if (hasValidLineGroup)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLogToFile("AutoUpdate | Current version is already the latest, no retry needed");
|
LogHelper.WriteLogToFile("AutoUpdate | Current version is already the latest, no retry needed");
|
||||||
|
|
||||||
// 停止重试定时器
|
// 停止重试定时器
|
||||||
timerCheckAutoUpdateRetry.Stop();
|
timerCheckAutoUpdateRetry.Stop();
|
||||||
updateCheckRetryCount = 0;
|
updateCheckRetryCount = 0;
|
||||||
@@ -1015,13 +1015,13 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 检查更新失败,启动重试定时器
|
// 检查更新失败,启动重试定时器
|
||||||
LogHelper.WriteLogToFile("AutoUpdate | Update check failed, starting retry timer");
|
LogHelper.WriteLogToFile("AutoUpdate | Update check failed, starting retry timer");
|
||||||
|
|
||||||
// 重置重试计数
|
// 重置重试计数
|
||||||
updateCheckRetryCount = 0;
|
updateCheckRetryCount = 0;
|
||||||
|
|
||||||
// 启动重试定时器,10分钟后重新检查
|
// 启动重试定时器,10分钟后重新检查
|
||||||
timerCheckAutoUpdateRetry.Start();
|
timerCheckAutoUpdateRetry.Start();
|
||||||
|
|
||||||
// 清理更新文件夹
|
// 清理更新文件夹
|
||||||
AutoUpdateHelper.DeleteUpdatesFolder();
|
AutoUpdateHelper.DeleteUpdatesFolder();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
// 强制刷新UI
|
// 强制刷新UI
|
||||||
window.InvalidateVisual();
|
window.InvalidateVisual();
|
||||||
|
|
||||||
// 通知其他窗口刷新主题
|
// 通知其他窗口刷新主题
|
||||||
RefreshOtherWindowsTheme();
|
RefreshOtherWindowsTheme();
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
// 强制刷新UI
|
// 强制刷新UI
|
||||||
window.InvalidateVisual();
|
window.InvalidateVisual();
|
||||||
|
|
||||||
// 通知其他窗口刷新主题
|
// 通知其他窗口刷新主题
|
||||||
RefreshOtherWindowsTheme();
|
RefreshOtherWindowsTheme();
|
||||||
}
|
}
|
||||||
@@ -184,18 +184,18 @@ namespace Ink_Canvas
|
|||||||
// 根据主题设置高光颜色
|
// 根据主题设置高光颜色
|
||||||
Color highlightBackgroundColor;
|
Color highlightBackgroundColor;
|
||||||
Color highlightBarColor;
|
Color highlightBarColor;
|
||||||
bool isDarkTheme = Settings.Appearance.Theme == 1 ||
|
bool isDarkTheme = Settings.Appearance.Theme == 1 ||
|
||||||
(Settings.Appearance.Theme == 2 && !IsSystemThemeLight());
|
(Settings.Appearance.Theme == 2 && !IsSystemThemeLight());
|
||||||
|
|
||||||
if (isDarkTheme)
|
if (isDarkTheme)
|
||||||
{
|
{
|
||||||
highlightBackgroundColor = Color.FromArgb(21, 102, 204, 255);
|
highlightBackgroundColor = Color.FromArgb(21, 102, 204, 255);
|
||||||
highlightBarColor = Color.FromRgb(102, 204, 255);
|
highlightBarColor = Color.FromRgb(102, 204, 255);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
highlightBackgroundColor = Color.FromArgb(21, 59, 130, 246);
|
highlightBackgroundColor = Color.FromArgb(21, 59, 130, 246);
|
||||||
highlightBarColor = Color.FromRgb(37, 99, 235);
|
highlightBarColor = Color.FromRgb(37, 99, 235);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置高光背景颜色
|
// 设置高光背景颜色
|
||||||
@@ -224,16 +224,16 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 根据主题选择高光颜色
|
// 根据主题选择高光颜色
|
||||||
Color selectedColor;
|
Color selectedColor;
|
||||||
bool isDarkTheme = Settings.Appearance.Theme == 1 ||
|
bool isDarkTheme = Settings.Appearance.Theme == 1 ||
|
||||||
(Settings.Appearance.Theme == 2 && !IsSystemThemeLight());
|
(Settings.Appearance.Theme == 2 && !IsSystemThemeLight());
|
||||||
|
|
||||||
if (isDarkTheme)
|
if (isDarkTheme)
|
||||||
{
|
{
|
||||||
selectedColor = Color.FromRgb(102, 204, 255);
|
selectedColor = Color.FromRgb(102, 204, 255);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
selectedColor = Color.FromRgb(30, 58, 138);
|
selectedColor = Color.FromRgb(30, 58, 138);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据当前模式设置按钮颜色
|
// 根据当前模式设置按钮颜色
|
||||||
@@ -376,7 +376,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 强制刷新墨迹选中栏的视觉状态
|
// 强制刷新墨迹选中栏的视觉状态
|
||||||
BorderStrokeSelectionControl.InvalidateVisual();
|
BorderStrokeSelectionControl.InvalidateVisual();
|
||||||
|
|
||||||
// 刷新墨迹选中栏内的所有图标
|
// 刷新墨迹选中栏内的所有图标
|
||||||
var viewbox = BorderStrokeSelectionControl.Child as Viewbox;
|
var viewbox = BorderStrokeSelectionControl.Child as Viewbox;
|
||||||
if (viewbox?.Child is ui.SimpleStackPanel stackPanel)
|
if (viewbox?.Child is ui.SimpleStackPanel stackPanel)
|
||||||
@@ -434,7 +434,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 强制刷新图片选中栏的视觉状态
|
// 强制刷新图片选中栏的视觉状态
|
||||||
BorderImageSelectionControl.InvalidateVisual();
|
BorderImageSelectionControl.InvalidateVisual();
|
||||||
|
|
||||||
// 刷新图片选中栏内的所有图标
|
// 刷新图片选中栏内的所有图标
|
||||||
var viewbox = BorderImageSelectionControl.Child as Viewbox;
|
var viewbox = BorderImageSelectionControl.Child as Viewbox;
|
||||||
if (viewbox?.Child is ui.SimpleStackPanel stackPanel)
|
if (viewbox?.Child is ui.SimpleStackPanel stackPanel)
|
||||||
|
|||||||
@@ -418,7 +418,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
// 获取主题颜色资源
|
// 获取主题颜色资源
|
||||||
var iconForegroundBrush = Application.Current.FindResource("IconForeground") as SolidColorBrush;
|
var iconForegroundBrush = Application.Current.FindResource("IconForeground") as SolidColorBrush;
|
||||||
|
|
||||||
// 设置下一页按钮颜色
|
// 设置下一页按钮颜色
|
||||||
if (iconForegroundBrush != null)
|
if (iconForegroundBrush != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -476,9 +476,9 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
// 根据主题选择高光颜色
|
// 根据主题选择高光颜色
|
||||||
Color highlightColor;
|
Color highlightColor;
|
||||||
bool isDarkTheme = Settings.Appearance.Theme == 1 ||
|
bool isDarkTheme = Settings.Appearance.Theme == 1 ||
|
||||||
(Settings.Appearance.Theme == 2 && !IsSystemThemeLight());
|
(Settings.Appearance.Theme == 2 && !IsSystemThemeLight());
|
||||||
|
|
||||||
if (isDarkTheme)
|
if (isDarkTheme)
|
||||||
{
|
{
|
||||||
highlightColor = Color.FromRgb(102, 204, 255); // #66ccff for dark theme
|
highlightColor = Color.FromRgb(102, 204, 255); // #66ccff for dark theme
|
||||||
@@ -3716,18 +3716,18 @@ namespace Ink_Canvas
|
|||||||
// 根据主题设置高光颜色
|
// 根据主题设置高光颜色
|
||||||
Color highlightBackgroundColor;
|
Color highlightBackgroundColor;
|
||||||
Color highlightBarColor;
|
Color highlightBarColor;
|
||||||
bool isDarkTheme = Settings.Appearance.Theme == 1 ||
|
bool isDarkTheme = Settings.Appearance.Theme == 1 ||
|
||||||
(Settings.Appearance.Theme == 2 && !IsSystemThemeLight());
|
(Settings.Appearance.Theme == 2 && !IsSystemThemeLight());
|
||||||
|
|
||||||
if (isDarkTheme)
|
if (isDarkTheme)
|
||||||
{
|
{
|
||||||
highlightBackgroundColor = Color.FromArgb(21, 102, 204, 255);
|
highlightBackgroundColor = Color.FromArgb(21, 102, 204, 255);
|
||||||
highlightBarColor = Color.FromRgb(102, 204, 255);
|
highlightBarColor = Color.FromRgb(102, 204, 255);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
highlightBackgroundColor = Color.FromArgb(21, 59, 130, 246);
|
highlightBackgroundColor = Color.FromArgb(21, 59, 130, 246);
|
||||||
highlightBarColor = Color.FromRgb(37, 99, 235);
|
highlightBarColor = Color.FromRgb(37, 99, 235);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置高光背景颜色
|
// 设置高光背景颜色
|
||||||
|
|||||||
@@ -61,10 +61,10 @@ namespace Ink_Canvas
|
|||||||
private Timer timerCheckAutoFold = new Timer();
|
private Timer timerCheckAutoFold = new Timer();
|
||||||
private string AvailableLatestVersion;
|
private string AvailableLatestVersion;
|
||||||
private Timer timerCheckAutoUpdateWithSilence = new Timer();
|
private Timer timerCheckAutoUpdateWithSilence = new Timer();
|
||||||
private Timer timerCheckAutoUpdateRetry = new Timer();
|
private Timer timerCheckAutoUpdateRetry = new Timer();
|
||||||
private bool isHidingSubPanelsWhenInking; // 避免书写时触发二次关闭二级菜单导致动画不连续
|
private bool isHidingSubPanelsWhenInking; // 避免书写时触发二次关闭二级菜单导致动画不连续
|
||||||
private int updateCheckRetryCount = 0;
|
private int updateCheckRetryCount = 0;
|
||||||
private const int MAX_UPDATE_CHECK_RETRIES = 6;
|
private const int MAX_UPDATE_CHECK_RETRIES = 6;
|
||||||
private Timer timerDisplayTime = new Timer();
|
private Timer timerDisplayTime = new Timer();
|
||||||
private Timer timerDisplayDate = new Timer();
|
private Timer timerDisplayDate = new Timer();
|
||||||
private Timer timerNtpSync = new Timer();
|
private Timer timerNtpSync = new Timer();
|
||||||
@@ -120,7 +120,7 @@ namespace Ink_Canvas
|
|||||||
timerCheckAutoUpdateWithSilence.Elapsed += timerCheckAutoUpdateWithSilence_Elapsed;
|
timerCheckAutoUpdateWithSilence.Elapsed += timerCheckAutoUpdateWithSilence_Elapsed;
|
||||||
timerCheckAutoUpdateWithSilence.Interval = 1000 * 60 * 10;
|
timerCheckAutoUpdateWithSilence.Interval = 1000 * 60 * 10;
|
||||||
timerCheckAutoUpdateRetry.Elapsed += timerCheckAutoUpdateRetry_Elapsed;
|
timerCheckAutoUpdateRetry.Elapsed += timerCheckAutoUpdateRetry_Elapsed;
|
||||||
timerCheckAutoUpdateRetry.Interval = 1000 * 60 * 10;
|
timerCheckAutoUpdateRetry.Interval = 1000 * 60 * 10;
|
||||||
WaterMarkTime.DataContext = nowTimeVM;
|
WaterMarkTime.DataContext = nowTimeVM;
|
||||||
WaterMarkDate.DataContext = nowTimeVM;
|
WaterMarkDate.DataContext = nowTimeVM;
|
||||||
timerDisplayTime.Elapsed += TimerDisplayTime_Elapsed;
|
timerDisplayTime.Elapsed += TimerDisplayTime_Elapsed;
|
||||||
@@ -863,7 +863,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
// 执行更新检查
|
// 执行更新检查
|
||||||
LogHelper.WriteLogToFile("AutoUpdate | Retrying update check after failure");
|
LogHelper.WriteLogToFile("AutoUpdate | Retrying update check after failure");
|
||||||
|
|
||||||
// 清除之前的更新状态
|
// 清除之前的更新状态
|
||||||
AvailableLatestVersion = null;
|
AvailableLatestVersion = null;
|
||||||
AvailableLatestLineGroup = null;
|
AvailableLatestLineGroup = null;
|
||||||
@@ -878,7 +878,7 @@ namespace Ink_Canvas
|
|||||||
// 检查更新成功,重置重试计数
|
// 检查更新成功,重置重试计数
|
||||||
updateCheckRetryCount = 0;
|
updateCheckRetryCount = 0;
|
||||||
LogHelper.WriteLogToFile($"AutoUpdate | Retry successful, found new version: {AvailableLatestVersion}");
|
LogHelper.WriteLogToFile($"AutoUpdate | Retry successful, found new version: {AvailableLatestVersion}");
|
||||||
|
|
||||||
// 停止重试定时器,因为已经找到了更新
|
// 停止重试定时器,因为已经找到了更新
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -886,7 +886,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 检查更新仍然失败,继续重试
|
// 检查更新仍然失败,继续重试
|
||||||
LogHelper.WriteLogToFile($"AutoUpdate | Retry {updateCheckRetryCount} failed, will retry in 10 minutes");
|
LogHelper.WriteLogToFile($"AutoUpdate | Retry {updateCheckRetryCount} failed, will retry in 10 minutes");
|
||||||
|
|
||||||
// 重新启动定时器,10分钟后再次尝试
|
// 重新启动定时器,10分钟后再次尝试
|
||||||
timerCheckAutoUpdateRetry.Start();
|
timerCheckAutoUpdateRetry.Start();
|
||||||
}
|
}
|
||||||
@@ -894,7 +894,7 @@ namespace Ink_Canvas
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLogToFile($"AutoUpdate | Error in retry check: {ex.Message}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"AutoUpdate | Error in retry check: {ex.Message}", LogHelper.LogType.Error);
|
||||||
|
|
||||||
// 出错时也重新启动定时器,稍后再检查
|
// 出错时也重新启动定时器,稍后再检查
|
||||||
if (updateCheckRetryCount <= MAX_UPDATE_CHECK_RETRIES)
|
if (updateCheckRetryCount <= MAX_UPDATE_CHECK_RETRIES)
|
||||||
{
|
{
|
||||||
@@ -910,10 +910,10 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 停止重试定时器
|
// 停止重试定时器
|
||||||
timerCheckAutoUpdateRetry.Stop();
|
timerCheckAutoUpdateRetry.Stop();
|
||||||
|
|
||||||
// 重置重试计数
|
// 重置重试计数
|
||||||
updateCheckRetryCount = 0;
|
updateCheckRetryCount = 0;
|
||||||
|
|
||||||
LogHelper.WriteLogToFile("AutoUpdate | Update check retry state reset");
|
LogHelper.WriteLogToFile("AutoUpdate | Update check retry state reset");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Controls.Primitives;
|
using System.Windows.Controls.Primitives;
|
||||||
|
|
||||||
namespace Ink_Canvas.Windows.Controls
|
namespace Ink_Canvas.Windows.Controls
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace Ink_Canvas
|
|||||||
timer.Elapsed += Timer_Elapsed;
|
timer.Elapsed += Timer_Elapsed;
|
||||||
timer.Interval = 50;
|
timer.Interval = 50;
|
||||||
InitializeUI();
|
InitializeUI();
|
||||||
|
|
||||||
// 应用主题
|
// 应用主题
|
||||||
ApplyTheme();
|
ApplyTheme();
|
||||||
}
|
}
|
||||||
@@ -111,9 +111,9 @@ namespace Ink_Canvas
|
|||||||
private void Grid_MouseUp(object sender, MouseButtonEventArgs e)
|
private void Grid_MouseUp(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (isTimerRunning) return;
|
if (isTimerRunning) return;
|
||||||
|
|
||||||
var textForeground = Application.Current.FindResource("TimerWindowTextForeground") as SolidColorBrush;
|
var textForeground = Application.Current.FindResource("TimerWindowTextForeground") as SolidColorBrush;
|
||||||
|
|
||||||
if (ProcessBarTime.Visibility == Visibility.Visible && isTimerRunning == false)
|
if (ProcessBarTime.Visibility == Visibility.Visible && isTimerRunning == false)
|
||||||
{
|
{
|
||||||
ProcessBarTime.Visibility = Visibility.Collapsed;
|
ProcessBarTime.Visibility = Visibility.Collapsed;
|
||||||
@@ -439,7 +439,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 重新应用主题
|
// 重新应用主题
|
||||||
ApplyTheme();
|
ApplyTheme();
|
||||||
|
|
||||||
// 强制刷新UI
|
// 强制刷新UI
|
||||||
InvalidateVisual();
|
InvalidateVisual();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using Ink_Canvas.Helpers;
|
using Ink_Canvas.Helpers;
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using iNKORE.UI.WPF.Modern;
|
using iNKORE.UI.WPF.Modern;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
namespace Ink_Canvas
|
namespace Ink_Canvas
|
||||||
{
|
{
|
||||||
@@ -54,9 +54,9 @@ namespace Ink_Canvas
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 根据当前主题设置窗口主题
|
// 根据当前主题设置窗口主题
|
||||||
bool isDarkTheme = MainWindow.Settings.Appearance.Theme == 1 ||
|
bool isDarkTheme = MainWindow.Settings.Appearance.Theme == 1 ||
|
||||||
(MainWindow.Settings.Appearance.Theme == 2 && !IsSystemThemeLight());
|
(MainWindow.Settings.Appearance.Theme == 2 && !IsSystemThemeLight());
|
||||||
|
|
||||||
if (isDarkTheme)
|
if (isDarkTheme)
|
||||||
{
|
{
|
||||||
ThemeManager.SetRequestedTheme(this, ElementTheme.Dark);
|
ThemeManager.SetRequestedTheme(this, ElementTheme.Dark);
|
||||||
|
|||||||
@@ -487,7 +487,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
// 重新应用主题
|
// 重新应用主题
|
||||||
ApplyTheme(MainWindow.Settings);
|
ApplyTheme(MainWindow.Settings);
|
||||||
|
|
||||||
// 强制刷新UI
|
// 强制刷新UI
|
||||||
InvalidateVisual();
|
InvalidateVisual();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using System.Timers;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Interop;
|
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace Ink_Canvas
|
namespace Ink_Canvas
|
||||||
@@ -23,7 +22,7 @@ namespace Ink_Canvas
|
|||||||
timer.Elapsed += Timer_Elapsed;
|
timer.Elapsed += Timer_Elapsed;
|
||||||
timer.Interval = 50;
|
timer.Interval = 50;
|
||||||
InitializeUI();
|
InitializeUI();
|
||||||
|
|
||||||
// 应用主题
|
// 应用主题
|
||||||
ApplyTheme();
|
ApplyTheme();
|
||||||
}
|
}
|
||||||
@@ -46,9 +45,9 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
int totalHours = (int)leftTimeSpan.TotalHours;
|
int totalHours = (int)leftTimeSpan.TotalHours;
|
||||||
int displayHours = totalHours;
|
int displayHours = totalHours;
|
||||||
|
|
||||||
if (displayHours > 99) displayHours = 99;
|
if (displayHours > 99) displayHours = 99;
|
||||||
|
|
||||||
Digit1Display.Text = (displayHours / 10).ToString();
|
Digit1Display.Text = (displayHours / 10).ToString();
|
||||||
Digit2Display.Text = (displayHours % 10).ToString();
|
Digit2Display.Text = (displayHours % 10).ToString();
|
||||||
Digit3Display.Text = (leftTimeSpan.Minutes / 10).ToString();
|
Digit3Display.Text = (leftTimeSpan.Minutes / 10).ToString();
|
||||||
@@ -86,7 +85,7 @@ namespace Ink_Canvas
|
|||||||
bool isPaused = false;
|
bool isPaused = false;
|
||||||
|
|
||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
|
|
||||||
// 最近计时记录
|
// 最近计时记录
|
||||||
private string recentTimer1 = "--:--";
|
private string recentTimer1 = "--:--";
|
||||||
private string recentTimer2 = "--:--";
|
private string recentTimer2 = "--:--";
|
||||||
@@ -94,7 +93,7 @@ namespace Ink_Canvas
|
|||||||
private string recentTimer4 = "--:--";
|
private string recentTimer4 = "--:--";
|
||||||
private string recentTimer5 = "--:--";
|
private string recentTimer5 = "--:--";
|
||||||
private string recentTimer6 = "--:--";
|
private string recentTimer6 = "--:--";
|
||||||
|
|
||||||
// 最近计时记录的注册表键名
|
// 最近计时记录的注册表键名
|
||||||
private const string RecentTimer1Key = "SeewoTimer_RecentTimer1";
|
private const string RecentTimer1Key = "SeewoTimer_RecentTimer1";
|
||||||
private const string RecentTimer2Key = "SeewoTimer_RecentTimer2";
|
private const string RecentTimer2Key = "SeewoTimer_RecentTimer2";
|
||||||
@@ -201,10 +200,10 @@ namespace Ink_Canvas
|
|||||||
int currentHour = hour;
|
int currentHour = hour;
|
||||||
int hourTens = currentHour / 10;
|
int hourTens = currentHour / 10;
|
||||||
int hourOnes = currentHour % 10;
|
int hourOnes = currentHour % 10;
|
||||||
|
|
||||||
hourTens++;
|
hourTens++;
|
||||||
if (hourTens >= 10) hourTens = 0;
|
if (hourTens >= 10) hourTens = 0;
|
||||||
|
|
||||||
hour = hourTens * 10 + hourOnes;
|
hour = hourTens * 10 + hourOnes;
|
||||||
UpdateDigitDisplays();
|
UpdateDigitDisplays();
|
||||||
}
|
}
|
||||||
@@ -215,10 +214,10 @@ namespace Ink_Canvas
|
|||||||
int currentHour = hour;
|
int currentHour = hour;
|
||||||
int hourTens = currentHour / 10;
|
int hourTens = currentHour / 10;
|
||||||
int hourOnes = currentHour % 10;
|
int hourOnes = currentHour % 10;
|
||||||
|
|
||||||
hourTens--;
|
hourTens--;
|
||||||
if (hourTens < 0) hourTens = 9;
|
if (hourTens < 0) hourTens = 9;
|
||||||
|
|
||||||
hour = hourTens * 10 + hourOnes;
|
hour = hourTens * 10 + hourOnes;
|
||||||
UpdateDigitDisplays();
|
UpdateDigitDisplays();
|
||||||
}
|
}
|
||||||
@@ -230,15 +229,15 @@ namespace Ink_Canvas
|
|||||||
int currentHour = hour;
|
int currentHour = hour;
|
||||||
int hourTens = currentHour / 10;
|
int hourTens = currentHour / 10;
|
||||||
int hourOnes = currentHour % 10;
|
int hourOnes = currentHour % 10;
|
||||||
|
|
||||||
hourOnes++;
|
hourOnes++;
|
||||||
if (hourOnes >= 10)
|
if (hourOnes >= 10)
|
||||||
{
|
{
|
||||||
hourOnes = 0;
|
hourOnes = 0;
|
||||||
hourTens++;
|
hourTens++;
|
||||||
if (hourTens >= 10) hourTens = 0;
|
if (hourTens >= 10) hourTens = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
hour = hourTens * 10 + hourOnes;
|
hour = hourTens * 10 + hourOnes;
|
||||||
UpdateDigitDisplays();
|
UpdateDigitDisplays();
|
||||||
}
|
}
|
||||||
@@ -249,15 +248,15 @@ namespace Ink_Canvas
|
|||||||
int currentHour = hour;
|
int currentHour = hour;
|
||||||
int hourTens = currentHour / 10;
|
int hourTens = currentHour / 10;
|
||||||
int hourOnes = currentHour % 10;
|
int hourOnes = currentHour % 10;
|
||||||
|
|
||||||
hourOnes--;
|
hourOnes--;
|
||||||
if (hourOnes < 0)
|
if (hourOnes < 0)
|
||||||
{
|
{
|
||||||
hourOnes = 9;
|
hourOnes = 9;
|
||||||
hourTens--;
|
hourTens--;
|
||||||
if (hourTens < 0) hourTens = 9;
|
if (hourTens < 0) hourTens = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
hour = hourTens * 10 + hourOnes;
|
hour = hourTens * 10 + hourOnes;
|
||||||
UpdateDigitDisplays();
|
UpdateDigitDisplays();
|
||||||
}
|
}
|
||||||
@@ -269,10 +268,10 @@ namespace Ink_Canvas
|
|||||||
int currentMinute = minute;
|
int currentMinute = minute;
|
||||||
int minuteTens = currentMinute / 10;
|
int minuteTens = currentMinute / 10;
|
||||||
int minuteOnes = currentMinute % 10;
|
int minuteOnes = currentMinute % 10;
|
||||||
|
|
||||||
minuteTens++;
|
minuteTens++;
|
||||||
if (minuteTens >= 6) minuteTens = 0;
|
if (minuteTens >= 6) minuteTens = 0;
|
||||||
|
|
||||||
minute = minuteTens * 10 + minuteOnes;
|
minute = minuteTens * 10 + minuteOnes;
|
||||||
UpdateDigitDisplays();
|
UpdateDigitDisplays();
|
||||||
}
|
}
|
||||||
@@ -283,10 +282,10 @@ namespace Ink_Canvas
|
|||||||
int currentMinute = minute;
|
int currentMinute = minute;
|
||||||
int minuteTens = currentMinute / 10;
|
int minuteTens = currentMinute / 10;
|
||||||
int minuteOnes = currentMinute % 10;
|
int minuteOnes = currentMinute % 10;
|
||||||
|
|
||||||
minuteTens--;
|
minuteTens--;
|
||||||
if (minuteTens < 0) minuteTens = 5;
|
if (minuteTens < 0) minuteTens = 5;
|
||||||
|
|
||||||
minute = minuteTens * 10 + minuteOnes;
|
minute = minuteTens * 10 + minuteOnes;
|
||||||
UpdateDigitDisplays();
|
UpdateDigitDisplays();
|
||||||
}
|
}
|
||||||
@@ -298,15 +297,15 @@ namespace Ink_Canvas
|
|||||||
int currentMinute = minute;
|
int currentMinute = minute;
|
||||||
int minuteTens = currentMinute / 10;
|
int minuteTens = currentMinute / 10;
|
||||||
int minuteOnes = currentMinute % 10;
|
int minuteOnes = currentMinute % 10;
|
||||||
|
|
||||||
minuteOnes++;
|
minuteOnes++;
|
||||||
if (minuteOnes >= 10)
|
if (minuteOnes >= 10)
|
||||||
{
|
{
|
||||||
minuteOnes = 0;
|
minuteOnes = 0;
|
||||||
minuteTens++;
|
minuteTens++;
|
||||||
if (minuteTens >= 6) minuteTens = 0;
|
if (minuteTens >= 6) minuteTens = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
minute = minuteTens * 10 + minuteOnes;
|
minute = minuteTens * 10 + minuteOnes;
|
||||||
UpdateDigitDisplays();
|
UpdateDigitDisplays();
|
||||||
}
|
}
|
||||||
@@ -317,15 +316,15 @@ namespace Ink_Canvas
|
|||||||
int currentMinute = minute;
|
int currentMinute = minute;
|
||||||
int minuteTens = currentMinute / 10;
|
int minuteTens = currentMinute / 10;
|
||||||
int minuteOnes = currentMinute % 10;
|
int minuteOnes = currentMinute % 10;
|
||||||
|
|
||||||
minuteOnes--;
|
minuteOnes--;
|
||||||
if (minuteOnes < 0)
|
if (minuteOnes < 0)
|
||||||
{
|
{
|
||||||
minuteOnes = 9;
|
minuteOnes = 9;
|
||||||
minuteTens--;
|
minuteTens--;
|
||||||
if (minuteTens < 0) minuteTens = 5;
|
if (minuteTens < 0) minuteTens = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
minute = minuteTens * 10 + minuteOnes;
|
minute = minuteTens * 10 + minuteOnes;
|
||||||
UpdateDigitDisplays();
|
UpdateDigitDisplays();
|
||||||
}
|
}
|
||||||
@@ -337,10 +336,10 @@ namespace Ink_Canvas
|
|||||||
int currentSecond = second;
|
int currentSecond = second;
|
||||||
int secondTens = currentSecond / 10;
|
int secondTens = currentSecond / 10;
|
||||||
int secondOnes = currentSecond % 10;
|
int secondOnes = currentSecond % 10;
|
||||||
|
|
||||||
secondTens++;
|
secondTens++;
|
||||||
if (secondTens >= 6) secondTens = 0;
|
if (secondTens >= 6) secondTens = 0;
|
||||||
|
|
||||||
second = secondTens * 10 + secondOnes;
|
second = secondTens * 10 + secondOnes;
|
||||||
UpdateDigitDisplays();
|
UpdateDigitDisplays();
|
||||||
}
|
}
|
||||||
@@ -351,10 +350,10 @@ namespace Ink_Canvas
|
|||||||
int currentSecond = second;
|
int currentSecond = second;
|
||||||
int secondTens = currentSecond / 10;
|
int secondTens = currentSecond / 10;
|
||||||
int secondOnes = currentSecond % 10;
|
int secondOnes = currentSecond % 10;
|
||||||
|
|
||||||
secondTens--;
|
secondTens--;
|
||||||
if (secondTens < 0) secondTens = 5;
|
if (secondTens < 0) secondTens = 5;
|
||||||
|
|
||||||
second = secondTens * 10 + secondOnes;
|
second = secondTens * 10 + secondOnes;
|
||||||
UpdateDigitDisplays();
|
UpdateDigitDisplays();
|
||||||
}
|
}
|
||||||
@@ -366,15 +365,15 @@ namespace Ink_Canvas
|
|||||||
int currentSecond = second;
|
int currentSecond = second;
|
||||||
int secondTens = currentSecond / 10;
|
int secondTens = currentSecond / 10;
|
||||||
int secondOnes = currentSecond % 10;
|
int secondOnes = currentSecond % 10;
|
||||||
|
|
||||||
secondOnes++;
|
secondOnes++;
|
||||||
if (secondOnes >= 10)
|
if (secondOnes >= 10)
|
||||||
{
|
{
|
||||||
secondOnes = 0;
|
secondOnes = 0;
|
||||||
secondTens++;
|
secondTens++;
|
||||||
if (secondTens >= 6) secondTens = 0;
|
if (secondTens >= 6) secondTens = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
second = secondTens * 10 + secondOnes;
|
second = secondTens * 10 + secondOnes;
|
||||||
UpdateDigitDisplays();
|
UpdateDigitDisplays();
|
||||||
}
|
}
|
||||||
@@ -385,15 +384,15 @@ namespace Ink_Canvas
|
|||||||
int currentSecond = second;
|
int currentSecond = second;
|
||||||
int secondTens = currentSecond / 10;
|
int secondTens = currentSecond / 10;
|
||||||
int secondOnes = currentSecond % 10;
|
int secondOnes = currentSecond % 10;
|
||||||
|
|
||||||
secondOnes--;
|
secondOnes--;
|
||||||
if (secondOnes < 0)
|
if (secondOnes < 0)
|
||||||
{
|
{
|
||||||
secondOnes = 9;
|
secondOnes = 9;
|
||||||
secondTens--;
|
secondTens--;
|
||||||
if (secondTens < 0) secondTens = 5;
|
if (secondTens < 0) secondTens = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
second = secondTens * 10 + secondOnes;
|
second = secondTens * 10 + secondOnes;
|
||||||
UpdateDigitDisplays();
|
UpdateDigitDisplays();
|
||||||
}
|
}
|
||||||
@@ -428,13 +427,13 @@ namespace Ink_Canvas
|
|||||||
second = 1;
|
second = 1;
|
||||||
UpdateDigitDisplays();
|
UpdateDigitDisplays();
|
||||||
}
|
}
|
||||||
|
|
||||||
startTime = DateTime.Now;
|
startTime = DateTime.Now;
|
||||||
StartPauseIcon.Data = Geometry.Parse(PauseIconData);
|
StartPauseIcon.Data = Geometry.Parse(PauseIconData);
|
||||||
isPaused = false;
|
isPaused = false;
|
||||||
isTimerRunning = true;
|
isTimerRunning = true;
|
||||||
timer.Start();
|
timer.Start();
|
||||||
|
|
||||||
// 保存到最近计时记录
|
// 保存到最近计时记录
|
||||||
SaveRecentTimer();
|
SaveRecentTimer();
|
||||||
}
|
}
|
||||||
@@ -518,7 +517,7 @@ namespace Ink_Canvas
|
|||||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||||
{
|
{
|
||||||
isTimerRunning = false;
|
isTimerRunning = false;
|
||||||
|
|
||||||
if (MainWindow.Settings != null)
|
if (MainWindow.Settings != null)
|
||||||
{
|
{
|
||||||
var mainWindow = Application.Current.MainWindow as MainWindow;
|
var mainWindow = Application.Current.MainWindow as MainWindow;
|
||||||
@@ -526,7 +525,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var currentModeField = mainWindow.GetType().GetField("currentMode",
|
var currentModeField = mainWindow.GetType().GetField("currentMode",
|
||||||
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||||
if (currentModeField != null)
|
if (currentModeField != null)
|
||||||
{
|
{
|
||||||
@@ -565,23 +564,23 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
CommonTimersGrid.Visibility = Visibility.Visible;
|
CommonTimersGrid.Visibility = Visibility.Visible;
|
||||||
RecentTimersGrid.Visibility = Visibility.Collapsed;
|
RecentTimersGrid.Visibility = Visibility.Collapsed;
|
||||||
|
|
||||||
// 更新字体粗细、透明度和颜色
|
// 更新字体粗细、透明度和颜色
|
||||||
var commonText = this.FindName("CommonTabText") as TextBlock;
|
var commonText = this.FindName("CommonTabText") as TextBlock;
|
||||||
var recentText = this.FindName("RecentTabText") as TextBlock;
|
var recentText = this.FindName("RecentTabText") as TextBlock;
|
||||||
if (commonText != null)
|
if (commonText != null)
|
||||||
{
|
{
|
||||||
commonText.FontWeight = FontWeights.Bold;
|
commonText.FontWeight = FontWeights.Bold;
|
||||||
commonText.Opacity = 1.0;
|
commonText.Opacity = 1.0;
|
||||||
commonText.Foreground = new SolidColorBrush(Colors.White);
|
commonText.Foreground = new SolidColorBrush(Colors.White);
|
||||||
}
|
}
|
||||||
if (recentText != null)
|
if (recentText != null)
|
||||||
{
|
{
|
||||||
recentText.FontWeight = FontWeights.Normal;
|
recentText.FontWeight = FontWeights.Normal;
|
||||||
recentText.Opacity = 0.8;
|
recentText.Opacity = 0.8;
|
||||||
recentText.Foreground = new SolidColorBrush(Color.FromRgb(102, 102, 102));
|
recentText.Foreground = new SolidColorBrush(Color.FromRgb(102, 102, 102));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移动指示器到左侧
|
// 移动指示器到左侧
|
||||||
var indicator = this.FindName("SegmentedIndicator") as Border;
|
var indicator = this.FindName("SegmentedIndicator") as Border;
|
||||||
if (indicator != null)
|
if (indicator != null)
|
||||||
@@ -589,7 +588,7 @@ namespace Ink_Canvas
|
|||||||
// 设置左侧圆角
|
// 设置左侧圆角
|
||||||
indicator.CornerRadius = new CornerRadius(7, 0, 0, 7);
|
indicator.CornerRadius = new CornerRadius(7, 0, 0, 7);
|
||||||
var animation = new System.Windows.Media.Animation.ThicknessAnimation(
|
var animation = new System.Windows.Media.Animation.ThicknessAnimation(
|
||||||
new Thickness(0, 0, 0, 0),
|
new Thickness(0, 0, 0, 0),
|
||||||
TimeSpan.FromMilliseconds(200));
|
TimeSpan.FromMilliseconds(200));
|
||||||
indicator.BeginAnimation(Border.MarginProperty, animation);
|
indicator.BeginAnimation(Border.MarginProperty, animation);
|
||||||
}
|
}
|
||||||
@@ -599,23 +598,23 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
CommonTimersGrid.Visibility = Visibility.Collapsed;
|
CommonTimersGrid.Visibility = Visibility.Collapsed;
|
||||||
RecentTimersGrid.Visibility = Visibility.Visible;
|
RecentTimersGrid.Visibility = Visibility.Visible;
|
||||||
|
|
||||||
// 更新字体粗细、透明度和颜色
|
// 更新字体粗细、透明度和颜色
|
||||||
var commonText = this.FindName("CommonTabText") as TextBlock;
|
var commonText = this.FindName("CommonTabText") as TextBlock;
|
||||||
var recentText = this.FindName("RecentTabText") as TextBlock;
|
var recentText = this.FindName("RecentTabText") as TextBlock;
|
||||||
if (commonText != null)
|
if (commonText != null)
|
||||||
{
|
{
|
||||||
commonText.FontWeight = FontWeights.Normal;
|
commonText.FontWeight = FontWeights.Normal;
|
||||||
commonText.Opacity = 0.8;
|
commonText.Opacity = 0.8;
|
||||||
commonText.Foreground = new SolidColorBrush(Color.FromRgb(102, 102, 102));
|
commonText.Foreground = new SolidColorBrush(Color.FromRgb(102, 102, 102));
|
||||||
}
|
}
|
||||||
if (recentText != null)
|
if (recentText != null)
|
||||||
{
|
{
|
||||||
recentText.FontWeight = FontWeights.Bold;
|
recentText.FontWeight = FontWeights.Bold;
|
||||||
recentText.Opacity = 1.0;
|
recentText.Opacity = 1.0;
|
||||||
recentText.Foreground = new SolidColorBrush(Colors.White);
|
recentText.Foreground = new SolidColorBrush(Colors.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移动指示器到右侧
|
// 移动指示器到右侧
|
||||||
var indicator = this.FindName("SegmentedIndicator") as Border;
|
var indicator = this.FindName("SegmentedIndicator") as Border;
|
||||||
if (indicator != null)
|
if (indicator != null)
|
||||||
@@ -623,7 +622,7 @@ namespace Ink_Canvas
|
|||||||
// 设置右侧圆角
|
// 设置右侧圆角
|
||||||
indicator.CornerRadius = new CornerRadius(0, 7, 7, 0);
|
indicator.CornerRadius = new CornerRadius(0, 7, 7, 0);
|
||||||
var animation = new System.Windows.Media.Animation.ThicknessAnimation(
|
var animation = new System.Windows.Media.Animation.ThicknessAnimation(
|
||||||
new Thickness(118, 0, 0, 0),
|
new Thickness(118, 0, 0, 0),
|
||||||
TimeSpan.FromMilliseconds(200));
|
TimeSpan.FromMilliseconds(200));
|
||||||
indicator.BeginAnimation(Border.MarginProperty, animation);
|
indicator.BeginAnimation(Border.MarginProperty, animation);
|
||||||
}
|
}
|
||||||
@@ -716,7 +715,7 @@ namespace Ink_Canvas
|
|||||||
private void ApplyRecentTimer(string timeString)
|
private void ApplyRecentTimer(string timeString)
|
||||||
{
|
{
|
||||||
if (timeString == "--:--") return;
|
if (timeString == "--:--") return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var parts = timeString.Split(':');
|
var parts = timeString.Split(':');
|
||||||
@@ -737,9 +736,9 @@ namespace Ink_Canvas
|
|||||||
private void SaveRecentTimer()
|
private void SaveRecentTimer()
|
||||||
{
|
{
|
||||||
if (hour == 0 && minute == 0 && second == 0) return;
|
if (hour == 0 && minute == 0 && second == 0) return;
|
||||||
|
|
||||||
string currentTime = $"{minute:D2}:{second:D2}";
|
string currentTime = $"{minute:D2}:{second:D2}";
|
||||||
|
|
||||||
// 如果当前时间与最近记录不同,则更新
|
// 如果当前时间与最近记录不同,则更新
|
||||||
if (currentTime != recentTimer1)
|
if (currentTime != recentTimer1)
|
||||||
{
|
{
|
||||||
@@ -835,7 +834,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
if (MainBorder != null)
|
if (MainBorder != null)
|
||||||
{
|
{
|
||||||
MainBorder.BorderBrush = new SolidColorBrush(Color.FromRgb(64, 64, 64));
|
MainBorder.BorderBrush = new SolidColorBrush(Color.FromRgb(64, 64, 64));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|||||||
Reference in New Issue
Block a user