From 147b4fc5edb60faae8cbeae878ad6bdabf489e41 Mon Sep 17 00:00:00 2001
From: CJKmkp <2564608840@qq.com>
Date: Sun, 31 Aug 2025 12:03:58 +0800
Subject: [PATCH] =?UTF-8?q?improve:=E6=96=87=E4=BB=B6=E5=85=B3=E8=81=94?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Ink Canvas/MainWindow.xaml | 20 +++++++
Ink Canvas/MainWindow.xaml.cs | 30 ++++++++++
Ink Canvas/MainWindow_cs/MW_Settings.cs | 80 +++++++++++++++++++++++++
3 files changed, 130 insertions(+)
diff --git a/Ink Canvas/MainWindow.xaml b/Ink Canvas/MainWindow.xaml
index 00b1ac61..42bc95ac 100644
--- a/Ink Canvas/MainWindow.xaml
+++ b/Ink Canvas/MainWindow.xaml
@@ -2659,6 +2659,26 @@
+
+
+
+
+
+
+
+
diff --git a/Ink Canvas/MainWindow.xaml.cs b/Ink Canvas/MainWindow.xaml.cs
index e3185c6f..2631cd59 100644
--- a/Ink Canvas/MainWindow.xaml.cs
+++ b/Ink Canvas/MainWindow.xaml.cs
@@ -526,6 +526,9 @@ namespace Ink_Canvas
// 处理命令行参数中的文件路径
HandleCommandLineFileOpen();
+
+ // 初始化文件关联状态显示
+ InitializeFileAssociationStatus();
}
private void SystemEventsOnDisplaySettingsChanged(object sender, EventArgs e)
@@ -2129,6 +2132,33 @@ namespace Ink_Canvas
}
#endregion
+ ///
+ /// 初始化文件关联状态显示
+ ///
+ private void InitializeFileAssociationStatus()
+ {
+ try
+ {
+ bool isRegistered = FileAssociationManager.IsFileAssociationRegistered();
+ if (isRegistered)
+ {
+ TextBlockFileAssociationStatus.Text = "✓ .icstk文件关联已注册";
+ TextBlockFileAssociationStatus.Foreground = new SolidColorBrush(Colors.LightGreen);
+ }
+ else
+ {
+ TextBlockFileAssociationStatus.Text = "✗ .icstk文件关联未注册";
+ TextBlockFileAssociationStatus.Foreground = new SolidColorBrush(Colors.LightCoral);
+ }
+ }
+ catch (Exception ex)
+ {
+ TextBlockFileAssociationStatus.Text = "✗ 检查文件关联状态时出错";
+ TextBlockFileAssociationStatus.Foreground = new SolidColorBrush(Colors.LightCoral);
+ LogHelper.WriteLogToFile($"初始化文件关联状态显示时出错: {ex.Message}", LogHelper.LogType.Error);
+ }
+ }
+
///
/// 处理命令行参数中的文件路径
///
diff --git a/Ink Canvas/MainWindow_cs/MW_Settings.cs b/Ink Canvas/MainWindow_cs/MW_Settings.cs
index 803000f5..3021481c 100644
--- a/Ink Canvas/MainWindow_cs/MW_Settings.cs
+++ b/Ink Canvas/MainWindow_cs/MW_Settings.cs
@@ -3080,5 +3080,85 @@ namespace Ink_Canvas
SaveSettingsToFile();
}
+ #region 文件关联管理
+
+ private void BtnUnregisterFileAssociation_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ bool success = FileAssociationManager.UnregisterFileAssociation();
+ if (success)
+ {
+ TextBlockFileAssociationStatus.Text = "✓ 文件关联已成功取消";
+ TextBlockFileAssociationStatus.Foreground = new SolidColorBrush(Colors.LightGreen);
+ ShowNotification("文件关联已取消");
+ }
+ else
+ {
+ TextBlockFileAssociationStatus.Text = "✗ 取消文件关联失败,可能需要管理员权限";
+ TextBlockFileAssociationStatus.Foreground = new SolidColorBrush(Colors.LightCoral);
+ ShowNotification("取消文件关联失败");
+ }
+ }
+ catch (Exception ex)
+ {
+ TextBlockFileAssociationStatus.Text = $"✗ 取消文件关联时出错: {ex.Message}";
+ TextBlockFileAssociationStatus.Foreground = new SolidColorBrush(Colors.LightCoral);
+ LogHelper.WriteLogToFile($"取消文件关联时出错: {ex.Message}", LogHelper.LogType.Error);
+ }
+ }
+
+ private void BtnCheckFileAssociation_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ bool isRegistered = FileAssociationManager.IsFileAssociationRegistered();
+ if (isRegistered)
+ {
+ TextBlockFileAssociationStatus.Text = "✓ .icstk文件关联已注册";
+ TextBlockFileAssociationStatus.Foreground = new SolidColorBrush(Colors.LightGreen);
+ }
+ else
+ {
+ TextBlockFileAssociationStatus.Text = "✗ .icstk文件关联未注册";
+ TextBlockFileAssociationStatus.Foreground = new SolidColorBrush(Colors.LightCoral);
+ }
+ }
+ catch (Exception ex)
+ {
+ TextBlockFileAssociationStatus.Text = $"✗ 检查文件关联状态时出错: {ex.Message}";
+ TextBlockFileAssociationStatus.Foreground = new SolidColorBrush(Colors.LightCoral);
+ LogHelper.WriteLogToFile($"检查文件关联状态时出错: {ex.Message}", LogHelper.LogType.Error);
+ }
+ }
+
+ private void BtnRegisterFileAssociation_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ bool success = FileAssociationManager.RegisterFileAssociation();
+ if (success)
+ {
+ TextBlockFileAssociationStatus.Text = "✓ 文件关联已成功注册";
+ TextBlockFileAssociationStatus.Foreground = new SolidColorBrush(Colors.LightGreen);
+ ShowNotification("文件关联已注册");
+ }
+ else
+ {
+ TextBlockFileAssociationStatus.Text = "✗ 注册文件关联失败,可能需要管理员权限";
+ TextBlockFileAssociationStatus.Foreground = new SolidColorBrush(Colors.LightCoral);
+ ShowNotification("注册文件关联失败");
+ }
+ }
+ catch (Exception ex)
+ {
+ TextBlockFileAssociationStatus.Text = $"✗ 注册文件关联时出错: {ex.Message}";
+ TextBlockFileAssociationStatus.Foreground = new SolidColorBrush(Colors.LightCoral);
+ LogHelper.WriteLogToFile($"注册文件关联时出错: {ex.Message}", LogHelper.LogType.Error);
+ }
+ }
+
+ #endregion
+
}
}