From 49aaa2d58b8b6ff73c17682c3be0dbf925f5885e Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sat, 7 Feb 2026 11:23:59 +0800 Subject: [PATCH] =?UTF-8?q?add:Dlass=E9=81=A5=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/MainWindow_cs/MW_Settings.cs | 2 + .../Windows/PrivacyAgreementWindow.xaml.cs | 78 +++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/Ink Canvas/MainWindow_cs/MW_Settings.cs b/Ink Canvas/MainWindow_cs/MW_Settings.cs index 623fd365..05a154af 100644 --- a/Ink Canvas/MainWindow_cs/MW_Settings.cs +++ b/Ink Canvas/MainWindow_cs/MW_Settings.cs @@ -76,6 +76,7 @@ namespace Ink_Canvas else { var privacyWindow = new PrivacyAgreementWindow(); + privacyWindow.Owner = this; bool? dialogResult = privacyWindow.ShowDialog(); if (dialogResult == true && privacyWindow.UserAccepted) @@ -356,6 +357,7 @@ namespace Ink_Canvas } var privacyWindow = new PrivacyAgreementWindow(); + privacyWindow.Owner = this; bool? dialogResult = privacyWindow.ShowDialog(); if (dialogResult == true && privacyWindow.UserAccepted) diff --git a/Ink Canvas/Windows/PrivacyAgreementWindow.xaml.cs b/Ink Canvas/Windows/PrivacyAgreementWindow.xaml.cs index ab21f1ed..ec94c9f6 100644 --- a/Ink Canvas/Windows/PrivacyAgreementWindow.xaml.cs +++ b/Ink Canvas/Windows/PrivacyAgreementWindow.xaml.cs @@ -2,26 +2,76 @@ using Ink_Canvas.Helpers; using System; using System.ComponentModel; using System.IO; +using System.Runtime.InteropServices; using System.Windows; +using System.Windows.Controls; +using System.Windows.Interop; using System.Windows.Media; +using System.Windows.Threading; namespace Ink_Canvas { public partial class PrivacyAgreementWindow : Window { public bool UserAccepted { get; private set; } = false; + private bool wasSettingsPanelVisible = false; public PrivacyAgreementWindow() { InitializeComponent(); + this.Topmost = true; AnimationsHelper.ShowWithSlideFromBottomAndFade(this, 0.25); ApplyTheme(); + HideSettingsPanel(); + } + + private void HideSettingsPanel() + { + try + { + if (Application.Current.MainWindow is MainWindow mainWindow) + { + var borderSettings = mainWindow.FindName("BorderSettings") as Border; + var borderSettingsMask = mainWindow.FindName("BorderSettingsMask") as Border; + + if (borderSettings != null) + { + wasSettingsPanelVisible = borderSettings.Visibility == Visibility.Visible; + if (wasSettingsPanelVisible) + { + borderSettings.Visibility = Visibility.Hidden; + } + } + + if (borderSettingsMask != null) + { + if (wasSettingsPanelVisible) + { + borderSettingsMask.Visibility = Visibility.Hidden; + } + } + } + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"隐藏设置面板失败: {ex.Message}", LogHelper.LogType.Warning); + } } private void Window_Loaded(object sender, RoutedEventArgs e) { try { + this.Topmost = true; + + Dispatcher.BeginInvoke(new Action(() => + { + this.Activate(); + this.Focus(); + this.Topmost = true; + SetForegroundWindow(new WindowInteropHelper(this).Handle); + }), DispatcherPriority.Loaded); + string privacyText = null; string pathTxt = Path.Combine(App.RootPath, "privacy.txt"); string pathNoExt = Path.Combine(App.RootPath, "privacy"); @@ -49,8 +99,36 @@ namespace Ink_Canvas } } + [DllImport("user32.dll")] + private static extern bool SetForegroundWindow(IntPtr hWnd); + private void Window_Closing(object sender, CancelEventArgs e) { + if (wasSettingsPanelVisible) + { + try + { + if (Application.Current.MainWindow is MainWindow mainWindow) + { + var borderSettings = mainWindow.FindName("BorderSettings") as Border; + var borderSettingsMask = mainWindow.FindName("BorderSettingsMask") as Border; + + if (borderSettings != null) + { + borderSettings.Visibility = Visibility.Visible; + } + + if (borderSettingsMask != null) + { + borderSettingsMask.Visibility = Visibility.Visible; + } + } + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"恢复设置面板失败: {ex.Message}", LogHelper.LogType.Warning); + } + } } private void ButtonCancel_Click(object sender, RoutedEventArgs e)