add:新新设置
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
|
||||
xmlns:i18n="clr-namespace:Ink_Canvas.MarkupExtensions"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:controls="clr-namespace:Ink_Canvas.Controls;assembly=InkCanvas.Controls"
|
||||
mc:Ignorable="d"
|
||||
|
||||
Title="启动">
|
||||
@@ -15,9 +16,7 @@
|
||||
<ScrollViewer PanningMode="VerticalFirst">
|
||||
<Grid Margin="59,0,59,0">
|
||||
<FrameworkElement.Resources>
|
||||
<!-- Spacing between cards -->
|
||||
<sys:Double x:Key="SettingsCardSpacing">4</sys:Double>
|
||||
<!-- Style (inc. the correct spacing) of a section header -->
|
||||
<Style x:Key="SettingsSectionHeaderTextBlockStyle"
|
||||
BasedOn="{StaticResource BodyStrongTextBlockStyle}"
|
||||
TargetType="TextBlock">
|
||||
@@ -36,62 +35,83 @@
|
||||
Text="窗口设置" />
|
||||
|
||||
<!-- 窗口无焦点模式 -->
|
||||
<ui:SettingsCard Description="{i18n:I18n Key=Startup_NoFocusModeHint}"
|
||||
Header="{i18n:I18n Key=Startup_NoFocusMode}">
|
||||
<ui:SettingsCard.HeaderIcon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.View}" />
|
||||
</ui:SettingsCard.HeaderIcon>
|
||||
<ui:ToggleSwitch Name="ToggleSwitchNoFocusMode" OnContent="{i18n:I18n Key=Common_On}" OffContent="{i18n:I18n Key=Common_Off}" Toggled="ToggleSwitchNoFocusMode_Toggled" />
|
||||
</ui:SettingsCard>
|
||||
<controls:LabeledSettingsCard x:Name="CardNoFocusMode"
|
||||
Header="{i18n:I18n Key=Startup_NoFocusMode}"
|
||||
Description="{i18n:I18n Key=Startup_NoFocusModeHint}"
|
||||
Icon="{x:Static ui:SegoeFluentIcons.View}"
|
||||
SwitchName="ToggleSwitchNoFocusMode"
|
||||
Toggled="ToggleSwitchNoFocusMode_Toggled" />
|
||||
|
||||
<!-- 窗口无边框模式 -->
|
||||
<ui:SettingsCard Description="{i18n:I18n Key=Startup_NoBorderModeHint}"
|
||||
Header="{i18n:I18n Key=Startup_NoBorderMode}">
|
||||
<ui:SettingsCard.HeaderIcon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.FullScreen}" />
|
||||
</ui:SettingsCard.HeaderIcon>
|
||||
<ui:ToggleSwitch Name="ToggleSwitchWindowMode" OnContent="{i18n:I18n Key=Common_On}" OffContent="{i18n:I18n Key=Common_Off}" Toggled="ToggleSwitchWindowMode_Toggled" />
|
||||
</ui:SettingsCard>
|
||||
<controls:LabeledSettingsCard x:Name="CardWindowMode"
|
||||
Header="{i18n:I18n Key=Startup_NoBorderMode}"
|
||||
Description="{i18n:I18n Key=Startup_NoBorderModeHint}"
|
||||
Icon="{x:Static ui:SegoeFluentIcons.FullScreen}"
|
||||
SwitchName="ToggleSwitchWindowMode"
|
||||
Toggled="ToggleSwitchWindowMode_Toggled" />
|
||||
|
||||
<!-- 窗口置顶 -->
|
||||
<ui:SettingsCard Description="{i18n:I18n Key=Startup_TopMostHint}"
|
||||
Header="{i18n:I18n Key=Startup_TopMost}">
|
||||
<ui:SettingsCard.HeaderIcon>
|
||||
<ui:SettingsExpander x:Name="ExpanderAlwaysOnTop"
|
||||
Header="{i18n:I18n Key=Startup_TopMost}"
|
||||
Description="{i18n:I18n Key=Startup_TopMostHint}">
|
||||
<ui:SettingsExpander.HeaderIcon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Pinned}" />
|
||||
</ui:SettingsCard.HeaderIcon>
|
||||
<ui:ToggleSwitch Name="ToggleSwitchAlwaysOnTop" OnContent="{i18n:I18n Key=Common_On}" OffContent="{i18n:I18n Key=Common_Off}" Toggled="ToggleSwitchAlwaysOnTop_Toggled" />
|
||||
</ui:SettingsCard>
|
||||
|
||||
<!-- UIA置顶 -->
|
||||
<ui:SettingsCard Description="{i18n:I18n Key=Startup_UIAccessTopMostHint_1}"
|
||||
Header="{i18n:I18n Key=Startup_UIATopMost}">
|
||||
<ui:SettingsCard.HeaderIcon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Shield}" />
|
||||
</ui:SettingsCard.HeaderIcon>
|
||||
<ui:ToggleSwitch Name="ToggleSwitchUIAccessTopMost" OnContent="{i18n:I18n Key=Common_On}" OffContent="{i18n:I18n Key=Common_Off}" Toggled="ToggleSwitchUIAccessTopMost_Toggled" />
|
||||
</ui:SettingsCard>
|
||||
</ui:SettingsExpander.HeaderIcon>
|
||||
<ui:ToggleSwitch x:Name="ToggleSwitchAlwaysOnTop"
|
||||
OnContent="{DynamicResource Common_On}"
|
||||
OffContent="{DynamicResource Common_Off}"
|
||||
Toggled="ToggleSwitchAlwaysOnTop_Toggled" />
|
||||
<ui:SettingsExpander.ItemTemplate>
|
||||
<local:TopMostModeTemplateSelector>
|
||||
<local:TopMostModeTemplateSelector.SelectionTemplate>
|
||||
<DataTemplate>
|
||||
<ui:SettingsCard Header="{i18n:I18n Key=Startup_TopMostMode}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<RadioButton Content="{i18n:I18n Key=Startup_TopMostMode_Normal}"
|
||||
GroupName="TopMostMode"
|
||||
Checked="RadioTopMostNormal_Checked"
|
||||
Loaded="RadioTopMostNormal_Loaded"
|
||||
Margin="0,0,16,0" />
|
||||
<RadioButton Content="{i18n:I18n Key=Startup_TopMostMode_UIA}"
|
||||
GroupName="TopMostMode"
|
||||
Checked="RadioTopMostUIA_Checked"
|
||||
Loaded="RadioTopMostUIA_Loaded" />
|
||||
</StackPanel>
|
||||
</ui:SettingsCard>
|
||||
</DataTemplate>
|
||||
</local:TopMostModeTemplateSelector.SelectionTemplate>
|
||||
<local:TopMostModeTemplateSelector.ButtonTemplate>
|
||||
<DataTemplate>
|
||||
<ui:SettingsCard Header="{Binding ButtonHeader}">
|
||||
<Button Content="{Binding ButtonContent}"
|
||||
Click="BtnRestart_Click"
|
||||
Tag="{Binding RestartAsAdmin}" />
|
||||
</ui:SettingsCard>
|
||||
</DataTemplate>
|
||||
</local:TopMostModeTemplateSelector.ButtonTemplate>
|
||||
</local:TopMostModeTemplateSelector>
|
||||
</ui:SettingsExpander.ItemTemplate>
|
||||
</ui:SettingsExpander>
|
||||
|
||||
<!-- 启动设置 -->
|
||||
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
|
||||
Text="启动设置" />
|
||||
|
||||
<!-- 开机时运行 -->
|
||||
<ui:SettingsCard Description="{i18n:I18n Key=Startup_RunAtStartupHint}"
|
||||
Header="{i18n:I18n Key=Startup_RunAtStartup}">
|
||||
<ui:SettingsCard.HeaderIcon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Settings}"/>
|
||||
</ui:SettingsCard.HeaderIcon>
|
||||
<ui:ToggleSwitch Name="ToggleSwitchRunAtStartup" OnContent="{i18n:I18n Key=Common_On}" OffContent="{i18n:I18n Key=Common_Off}" Toggled="ToggleSwitchRunAtStartup_Toggled" />
|
||||
</ui:SettingsCard>
|
||||
<controls:LabeledSettingsCard x:Name="CardRunAtStartup"
|
||||
Header="{i18n:I18n Key=Startup_RunAtStartup}"
|
||||
Description="{i18n:I18n Key=Startup_RunAtStartupHint}"
|
||||
Icon="{x:Static ui:SegoeFluentIcons.Settings}"
|
||||
SwitchName="ToggleSwitchRunAtStartup"
|
||||
Toggled="ToggleSwitchRunAtStartup_Toggled" />
|
||||
|
||||
<!-- 开机运行后收纳到侧边栏 -->
|
||||
<ui:SettingsCard Description="{i18n:I18n Key=Startup_FoldAtStartupHint}"
|
||||
Header="{i18n:I18n Key=Startup_FoldAtStartup}">
|
||||
<ui:SettingsCard.HeaderIcon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.ChevronLeft}" />
|
||||
</ui:SettingsCard.HeaderIcon>
|
||||
<ui:ToggleSwitch Name="ToggleSwitchFoldAtStartup" OnContent="{i18n:I18n Key=Common_On}" OffContent="{i18n:I18n Key=Common_Off}" Toggled="ToggleSwitchFoldAtStartup_Toggled" />
|
||||
</ui:SettingsCard>
|
||||
<controls:LabeledSettingsCard x:Name="CardFoldAtStartup"
|
||||
Header="{i18n:I18n Key=Startup_FoldAtStartup}"
|
||||
Description="{i18n:I18n Key=Startup_FoldAtStartupHint}"
|
||||
Icon="{x:Static ui:SegoeFluentIcons.ChevronLeft}"
|
||||
SwitchName="ToggleSwitchFoldAtStartup"
|
||||
Toggled="ToggleSwitchFoldAtStartup_Toggled" />
|
||||
|
||||
<!-- 模式设置 -->
|
||||
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using Ink_Canvas.Controls;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Security.Principal;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Ink_Canvas.Windows.SettingsViews.Pages
|
||||
{
|
||||
/// <summary>
|
||||
/// StartupPage.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class StartupPage : Page
|
||||
public partial class StartupPage : iNKORE.UI.WPF.Modern.Controls.Page
|
||||
{
|
||||
private bool _isLoaded = false;
|
||||
private bool _isAdmin = false;
|
||||
private RadioButton _radioNormal;
|
||||
private RadioButton _radioUIA;
|
||||
private readonly ObservableCollection<object> _topMostModeItems = new();
|
||||
|
||||
public StartupPage()
|
||||
{
|
||||
@@ -23,53 +28,93 @@ namespace Ink_Canvas.Windows.SettingsViews.Pages
|
||||
_isLoaded = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载设置到UI
|
||||
/// </summary>
|
||||
private static bool IsRunningAsAdmin()
|
||||
{
|
||||
try
|
||||
{
|
||||
var identity = WindowsIdentity.GetCurrent();
|
||||
var principal = new WindowsPrincipal(identity);
|
||||
return principal.IsInRole(WindowsBuiltInRole.Administrator);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void RestartApp(bool asAdmin)
|
||||
{
|
||||
try
|
||||
{
|
||||
App.IsAppExitByUser = true;
|
||||
|
||||
(Application.Current as App)?.ReleaseMutexForRestart();
|
||||
|
||||
string exePath = Process.GetCurrentProcess().MainModule.FileName;
|
||||
|
||||
if (asAdmin)
|
||||
{
|
||||
var psi = new ProcessStartInfo(exePath) { UseShellExecute = true, Verb = "runas" };
|
||||
Process.Start(psi);
|
||||
}
|
||||
else
|
||||
{
|
||||
Process.Start("explorer.exe", "\"" + exePath + "\"");
|
||||
}
|
||||
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"重启应用时出错: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadSettings()
|
||||
{
|
||||
if (MainWindow.Settings == null) return;
|
||||
|
||||
_isLoaded = false;
|
||||
_isAdmin = IsRunningAsAdmin();
|
||||
|
||||
try
|
||||
{
|
||||
// 窗口无焦点模式
|
||||
if (MainWindow.Settings.Advanced != null)
|
||||
{
|
||||
ToggleSwitchNoFocusMode.IsOn = MainWindow.Settings.Advanced.IsNoFocusMode;
|
||||
}
|
||||
|
||||
// 窗口无边框模式
|
||||
if (MainWindow.Settings.Advanced != null)
|
||||
{
|
||||
ToggleSwitchWindowMode.IsOn = MainWindow.Settings.Advanced.WindowMode;
|
||||
}
|
||||
|
||||
// 窗口置顶
|
||||
if (MainWindow.Settings.Advanced != null)
|
||||
{
|
||||
CardNoFocusMode.IsOn = MainWindow.Settings.Advanced.IsNoFocusMode;
|
||||
CardWindowMode.IsOn = MainWindow.Settings.Advanced.WindowMode;
|
||||
ToggleSwitchAlwaysOnTop.IsOn = MainWindow.Settings.Advanced.IsAlwaysOnTop;
|
||||
|
||||
_topMostModeItems.Clear();
|
||||
_topMostModeItems.Add(new TopMostModeSelectionItem());
|
||||
|
||||
var btnItem = _isAdmin
|
||||
? new TopMostModeButtonItem
|
||||
{
|
||||
ButtonHeader = Properties.Strings.GetString("Startup_TopMostMode_RestartAsNormal"),
|
||||
ButtonContent = Properties.Strings.GetString("Startup_TopMostMode_RestartAsNormal"),
|
||||
RestartAsAdmin = false
|
||||
}
|
||||
: new TopMostModeButtonItem
|
||||
{
|
||||
ButtonHeader = Properties.Strings.GetString("Startup_TopMostMode_RestartAsAdmin"),
|
||||
ButtonContent = Properties.Strings.GetString("Startup_TopMostMode_RestartAsAdmin"),
|
||||
RestartAsAdmin = true
|
||||
};
|
||||
_topMostModeItems.Add(btnItem);
|
||||
|
||||
ExpanderAlwaysOnTop.ItemsSource = _topMostModeItems;
|
||||
}
|
||||
|
||||
// UIA置顶
|
||||
if (MainWindow.Settings.Advanced != null)
|
||||
{
|
||||
ToggleSwitchUIAccessTopMost.IsOn = MainWindow.Settings.Advanced.EnableUIAccessTopMost;
|
||||
}
|
||||
|
||||
// 开机时运行
|
||||
bool runAtStartup = System.IO.File.Exists(
|
||||
System.Environment.GetFolderPath(System.Environment.SpecialFolder.Startup) + "\\Ink Canvas Annotation.lnk");
|
||||
ToggleSwitchRunAtStartup.IsOn = runAtStartup;
|
||||
CardRunAtStartup.IsOn = runAtStartup;
|
||||
|
||||
// 启动时折叠
|
||||
if (MainWindow.Settings.Startup != null)
|
||||
{
|
||||
ToggleSwitchFoldAtStartup.IsOn = MainWindow.Settings.Startup.IsFoldAtStartup;
|
||||
CardFoldAtStartup.IsOn = MainWindow.Settings.Startup.IsFoldAtStartup;
|
||||
}
|
||||
|
||||
// 仅PPT模式
|
||||
if (MainWindow.Settings.ModeSettings != null)
|
||||
{
|
||||
ToggleSwitchPPTOnlyMode.IsOn = MainWindow.Settings.ModeSettings.IsPPTOnlyMode;
|
||||
@@ -77,57 +122,101 @@ namespace Ink_Canvas.Windows.SettingsViews.Pages
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"加载启动设置时出错: {ex.Message}");
|
||||
Debug.WriteLine($"加载启动设置时出错: {ex.Message}");
|
||||
}
|
||||
|
||||
_isLoaded = true;
|
||||
}
|
||||
|
||||
private void UpdateRadioButtons()
|
||||
{
|
||||
if (_radioNormal == null || _radioUIA == null) return;
|
||||
|
||||
bool wasLoaded = _isLoaded;
|
||||
_isLoaded = false;
|
||||
|
||||
_radioNormal.IsEnabled = _isAdmin;
|
||||
_radioUIA.IsEnabled = _isAdmin;
|
||||
|
||||
if (_isAdmin && MainWindow.Settings.Advanced.EnableUIAccessTopMost)
|
||||
_radioUIA.IsChecked = true;
|
||||
else
|
||||
_radioNormal.IsChecked = true;
|
||||
|
||||
_isLoaded = wasLoaded;
|
||||
}
|
||||
|
||||
private void RadioTopMostNormal_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_radioNormal = sender as RadioButton;
|
||||
UpdateRadioButtons();
|
||||
}
|
||||
|
||||
private void RadioTopMostUIA_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_radioUIA = sender as RadioButton;
|
||||
UpdateRadioButtons();
|
||||
}
|
||||
|
||||
#region 窗口设置事件处理
|
||||
|
||||
/// <summary>
|
||||
/// 窗口无焦点模式开关事件
|
||||
/// </summary>
|
||||
private void ToggleSwitchNoFocusMode_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!_isLoaded) return;
|
||||
|
||||
try
|
||||
{
|
||||
bool newState = ToggleSwitchNoFocusMode.IsOn;
|
||||
bool newState = CardNoFocusMode.IsOn;
|
||||
|
||||
// 使用Helper类更新设置并应用
|
||||
Windows.SettingsViews.MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchNoFocusMode", newState);
|
||||
if (MainWindow.Settings.Advanced != null)
|
||||
{
|
||||
MainWindow.Settings.Advanced.IsNoFocusMode = newState;
|
||||
MainWindow.SaveSettingsToFile();
|
||||
}
|
||||
|
||||
var mainWindow = Application.Current.MainWindow as MainWindow;
|
||||
if (mainWindow != null)
|
||||
{
|
||||
mainWindow.ApplyNoFocusMode();
|
||||
|
||||
if (MainWindow.Settings.Advanced.IsAlwaysOnTop)
|
||||
{
|
||||
mainWindow.ApplyAlwaysOnTop();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"设置窗口无焦点模式时出错: {ex.Message}");
|
||||
Debug.WriteLine($"设置窗口无焦点模式时出错: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 窗口无边框模式开关事件
|
||||
/// </summary>
|
||||
private void ToggleSwitchWindowMode_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!_isLoaded) return;
|
||||
|
||||
try
|
||||
{
|
||||
bool newState = ToggleSwitchWindowMode.IsOn;
|
||||
bool newState = CardWindowMode.IsOn;
|
||||
|
||||
// 使用Helper类更新设置并应用
|
||||
Windows.SettingsViews.MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchWindowMode", newState);
|
||||
if (MainWindow.Settings.Advanced != null)
|
||||
{
|
||||
MainWindow.Settings.Advanced.WindowMode = newState;
|
||||
MainWindow.SaveSettingsToFile();
|
||||
}
|
||||
|
||||
var mainWindow = Application.Current.MainWindow as MainWindow;
|
||||
if (mainWindow != null)
|
||||
{
|
||||
mainWindow.SetWindowMode();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"设置窗口无边框模式时出错: {ex.Message}");
|
||||
Debug.WriteLine($"设置窗口无边框模式时出错: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 窗口置顶开关事件
|
||||
/// </summary>
|
||||
private void ToggleSwitchAlwaysOnTop_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!_isLoaded) return;
|
||||
@@ -136,41 +225,100 @@ namespace Ink_Canvas.Windows.SettingsViews.Pages
|
||||
{
|
||||
bool newState = ToggleSwitchAlwaysOnTop.IsOn;
|
||||
|
||||
// 使用Helper类更新设置并应用
|
||||
Windows.SettingsViews.MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAlwaysOnTop", newState);
|
||||
if (MainWindow.Settings.Advanced != null)
|
||||
{
|
||||
MainWindow.Settings.Advanced.IsAlwaysOnTop = newState;
|
||||
MainWindow.SaveSettingsToFile();
|
||||
}
|
||||
|
||||
var mainWindow = Application.Current.MainWindow as MainWindow;
|
||||
if (mainWindow != null)
|
||||
{
|
||||
mainWindow.ApplyAlwaysOnTop();
|
||||
|
||||
if (!newState && MainWindow.Settings.Advanced.EnableUIAccessTopMost)
|
||||
{
|
||||
MainWindow.Settings.Advanced.EnableUIAccessTopMost = false;
|
||||
App.IsUIAccessTopMostEnabled = false;
|
||||
mainWindow.ApplyUIAccessTopMost();
|
||||
MainWindow.SaveSettingsToFile();
|
||||
if (_radioNormal != null) _radioNormal.IsChecked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"设置窗口置顶时出错: {ex.Message}");
|
||||
Debug.WriteLine($"设置窗口置顶时出错: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// UIA置顶开关事件
|
||||
/// </summary>
|
||||
private void ToggleSwitchUIAccessTopMost_Toggled(object sender, RoutedEventArgs e)
|
||||
private void RadioTopMostNormal_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!_isLoaded) return;
|
||||
|
||||
try
|
||||
{
|
||||
bool newState = ToggleSwitchUIAccessTopMost.IsOn;
|
||||
|
||||
// 更新Settings对象
|
||||
if (MainWindow.Settings.Advanced != null)
|
||||
{
|
||||
MainWindow.Settings.Advanced.EnableUIAccessTopMost = newState;
|
||||
MainWindow.Settings.Advanced.EnableUIAccessTopMost = false;
|
||||
MainWindow.SaveSettingsToFile();
|
||||
}
|
||||
|
||||
// 保存设置
|
||||
MainWindow.SaveSettingsToFile();
|
||||
App.IsUIAccessTopMostEnabled = false;
|
||||
|
||||
// 通知其他面板同步状态
|
||||
Windows.SettingsViews.MainWindowSettingsHelper.NotifySettingsPanelsSyncState("ToggleSwitchUIAccessTopMost");
|
||||
var msg = Properties.Strings.GetString("Startup_TopMostMode_Normal_RestartRequired");
|
||||
var result = System.Windows.MessageBox.Show(msg, "Ink Canvas", MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
RestartApp(_isAdmin);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"设置UIA置顶时出错: {ex.Message}");
|
||||
Debug.WriteLine($"设置普通置顶模式时出错: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void RadioTopMostUIA_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!_isLoaded) return;
|
||||
|
||||
try
|
||||
{
|
||||
if (MainWindow.Settings.Advanced != null)
|
||||
{
|
||||
MainWindow.Settings.Advanced.EnableUIAccessTopMost = true;
|
||||
|
||||
if (!MainWindow.Settings.Advanced.IsAlwaysOnTop)
|
||||
{
|
||||
MainWindow.Settings.Advanced.IsAlwaysOnTop = true;
|
||||
ToggleSwitchAlwaysOnTop.IsOn = true;
|
||||
}
|
||||
|
||||
MainWindow.SaveSettingsToFile();
|
||||
}
|
||||
|
||||
var msg = Properties.Strings.GetString("Startup_TopMostMode_UIA_RestartRequired");
|
||||
var result = System.Windows.MessageBox.Show(msg, "Ink Canvas", MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
App.IsUIAccessTopMostEnabled = true;
|
||||
RestartApp(true);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"设置UIA置顶模式时出错: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnRestart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Button btn && btn.Tag is bool asAdmin)
|
||||
{
|
||||
RestartApp(asAdmin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,43 +326,48 @@ namespace Ink_Canvas.Windows.SettingsViews.Pages
|
||||
|
||||
#region 启动设置事件处理
|
||||
|
||||
/// <summary>
|
||||
/// 开机时运行开关事件
|
||||
/// </summary>
|
||||
private void ToggleSwitchRunAtStartup_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!_isLoaded) return;
|
||||
|
||||
try
|
||||
{
|
||||
bool newState = ToggleSwitchRunAtStartup.IsOn;
|
||||
bool newState = CardRunAtStartup.IsOn;
|
||||
|
||||
// 使用Helper类更新设置并应用
|
||||
Windows.SettingsViews.MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchRunAtStartup", newState);
|
||||
if (newState)
|
||||
{
|
||||
MainWindow.StartAutomaticallyDel("InkCanvas");
|
||||
MainWindow.StartAutomaticallyCreate("Ink Canvas Annotation");
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.StartAutomaticallyDel("InkCanvas");
|
||||
MainWindow.StartAutomaticallyDel("Ink Canvas Annotation");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"设置开机启动时出错: {ex.Message}");
|
||||
Debug.WriteLine($"设置开机启动时出错: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开机运行后收纳到侧边栏开关事件
|
||||
/// </summary>
|
||||
private void ToggleSwitchFoldAtStartup_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!_isLoaded) return;
|
||||
|
||||
try
|
||||
{
|
||||
bool newState = ToggleSwitchFoldAtStartup.IsOn;
|
||||
bool newState = CardFoldAtStartup.IsOn;
|
||||
|
||||
// 使用Helper类更新设置并应用
|
||||
Windows.SettingsViews.MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchFoldAtStartup", newState);
|
||||
if (MainWindow.Settings.Startup != null)
|
||||
{
|
||||
MainWindow.Settings.Startup.IsFoldAtStartup = newState;
|
||||
MainWindow.SaveSettingsToFile();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"设置开机折叠时出错: {ex.Message}");
|
||||
Debug.WriteLine($"设置开机折叠时出错: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,9 +375,6 @@ namespace Ink_Canvas.Windows.SettingsViews.Pages
|
||||
|
||||
#region 模式设置事件处理
|
||||
|
||||
/// <summary>
|
||||
/// 仅PPT模式开关事件
|
||||
/// </summary>
|
||||
private void ToggleSwitchPPTOnlyMode_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!_isLoaded) return;
|
||||
@@ -233,12 +383,11 @@ namespace Ink_Canvas.Windows.SettingsViews.Pages
|
||||
{
|
||||
bool newState = ToggleSwitchPPTOnlyMode.IsOn;
|
||||
|
||||
// 使用Helper类更新设置并应用
|
||||
Windows.SettingsViews.MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchMode", newState);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"设置仅PPT模式时出错: {ex.Message}");
|
||||
Debug.WriteLine($"设置仅PPT模式时出错: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Ink_Canvas.Windows.SettingsViews.Pages
|
||||
{
|
||||
public class TopMostModeSelectionItem
|
||||
{
|
||||
}
|
||||
|
||||
public class TopMostModeButtonItem
|
||||
{
|
||||
public string ButtonHeader { get; set; }
|
||||
public string ButtonContent { get; set; }
|
||||
public bool RestartAsAdmin { get; set; }
|
||||
}
|
||||
|
||||
public class TopMostModeTemplateSelector : DataTemplateSelector
|
||||
{
|
||||
public DataTemplate SelectionTemplate { get; set; }
|
||||
public DataTemplate ButtonTemplate { get; set; }
|
||||
|
||||
public override DataTemplate SelectTemplate(object item, DependencyObject container)
|
||||
{
|
||||
if (item is TopMostModeSelectionItem) return SelectionTemplate;
|
||||
if (item is TopMostModeButtonItem) return ButtonTemplate;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user