From 7c97b683eac56610e4e60eb3d910b9fe0b097aff Mon Sep 17 00:00:00 2001
From: PrefacedCorg <1876568293@qq.com>
Date: Wed, 1 Apr 2026 00:46:40 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E6=96=B0=E8=AE=BE=E7=BD=AE=E7=9A=84?=
=?UTF-8?q?=E7=AC=AC=E4=B8=80=E4=B8=AA=E5=BC=80=E5=85=B3=E8=AE=BE=E7=BD=AE?=
=?UTF-8?q?=E9=80=89=E9=A1=B9=20=E5=BC=80=E6=9C=BA=E6=97=B6=E5=90=AF?=
=?UTF-8?q?=E5=8A=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Pages/NewSettingStartup.xaml | 40 +++++++++--
.../Pages/NewSettingStartup.xaml.cs | 67 +++++++++++++++++++
2 files changed, 101 insertions(+), 6 deletions(-)
diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/NewSettingStartup.xaml b/Ink Canvas/Windows/SettingsViews2/Pages/NewSettingStartup.xaml
index 8c34eec5..62805dec 100644
--- a/Ink Canvas/Windows/SettingsViews2/Pages/NewSettingStartup.xaml
+++ b/Ink Canvas/Windows/SettingsViews2/Pages/NewSettingStartup.xaml
@@ -4,14 +4,42 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Ink_Canvas.Windows.SettingsViews2.Pages"
+ xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
+ xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
+ xmlns:i18n="clr-namespace:Ink_Canvas.MarkupExtensions"
+ xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="启动">
-
-
-
-
-
-
+
+
+
+
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Ink Canvas/Windows/SettingsViews2/Pages/NewSettingStartup.xaml.cs b/Ink Canvas/Windows/SettingsViews2/Pages/NewSettingStartup.xaml.cs
index cf0bc76b..8c553661 100644
--- a/Ink Canvas/Windows/SettingsViews2/Pages/NewSettingStartup.xaml.cs
+++ b/Ink Canvas/Windows/SettingsViews2/Pages/NewSettingStartup.xaml.cs
@@ -23,6 +23,73 @@ namespace Ink_Canvas.Windows.SettingsViews2.Pages
public NewSettingStartup()
{
InitializeComponent();
+ // 初始化开关状态
+ InitializeSwitchState();
+ }
+
+ ///
+ /// 初始化开关状态
+ ///
+ private void InitializeSwitchState()
+ {
+ try
+ {
+ // 通过检查启动文件夹中是否存在快捷方式来判断开机自启动状态
+ if (System.IO.File.Exists(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Startup) + "\\Ink Canvas Annotation.lnk"))
+ {
+ ToggleSwitchRunAtStartup.IsOn = true;
+ }
+ else
+ {
+ ToggleSwitchRunAtStartup.IsOn = false;
+ }
+
+ // 同步主窗口的开关状态
+ var mainWindow = Application.Current.MainWindow as MainWindow;
+ if (mainWindow != null && mainWindow.ToggleSwitchRunAtStartup != null)
+ {
+ mainWindow.ToggleSwitchRunAtStartup.IsOn = ToggleSwitchRunAtStartup.IsOn;
+ }
+ }
+ catch (Exception)
+ {
+ // 如果发生异常,默认设置为关闭
+ ToggleSwitchRunAtStartup.IsOn = false;
+ }
+ }
+
+ ///
+ /// 处理开机自启动开关状态更改事件
+ ///
+ /// 事件发送者
+ /// 路由事件参数
+ private void ToggleSwitchRunAtStartup_Toggled(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ // 直接实现开机自启动逻辑
+ if (ToggleSwitchRunAtStartup.IsOn)
+ {
+ MainWindow.StartAutomaticallyDel("InkCanvas");
+ MainWindow.StartAutomaticallyCreate("Ink Canvas Annotation");
+ }
+ else
+ {
+ MainWindow.StartAutomaticallyDel("InkCanvas");
+ MainWindow.StartAutomaticallyDel("Ink Canvas Annotation");
+ }
+
+ // 同步到主窗口的设置
+ var mainWindow = Application.Current.MainWindow as MainWindow;
+ if (mainWindow != null && mainWindow.ToggleSwitchRunAtStartup != null)
+ {
+ mainWindow.ToggleSwitchRunAtStartup.IsOn = ToggleSwitchRunAtStartup.IsOn;
+ }
+ }
+ catch (Exception)
+ {
+ // 忽略异常
+ }
}
}
}
\ No newline at end of file