add:debug功能

This commit is contained in:
2026-05-01 00:27:29 +08:00
parent b0aff1e378
commit 4d8fbef455
8 changed files with 185 additions and 2 deletions
@@ -0,0 +1,43 @@
<ui:Page x:Class="Ink_Canvas.Windows.SettingsViews.Pages.DebugPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
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.SettingsViews.Pages"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:controls="clr-namespace:Ink_Canvas.Controls;assembly=InkCanvas.Controls"
mc:Ignorable="d"
Title="Debug">
<ScrollViewer PanningMode="VerticalFirst">
<Grid Margin="59,0,59,0">
<FrameworkElement.Resources>
<sys:Double x:Key="SettingsCardSpacing">4</sys:Double>
<Style x:Key="SettingsSectionHeaderTextBlockStyle"
BasedOn="{StaticResource BodyStrongTextBlockStyle}"
TargetType="TextBlock">
<Style.Setters>
<Setter Property="Margin" Value="1,30,0,6" />
</Style.Setters>
</Style>
</FrameworkElement.Resources>
<ikw:SimpleStackPanel MaxWidth="1000"
HorizontalAlignment="Stretch"
Spacing="{StaticResource SettingsCardSpacing}">
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
Text="Debug" />
<controls:LabeledSettingsCard x:Name="ToggleSwitchDebugConsole"
Header="显示调试窗口"
Description="显示一个独立的控制台窗口,用于实时输出日志(开启后立即生效;关闭设置中的“启用日志记录”将不会输出内容)。"
Icon="{x:Static ui:SegoeFluentIcons.DeveloperTools}"
IsOn="False"
Toggled="ToggleSwitchDebugConsole_Toggled"/>
</ikw:SimpleStackPanel>
</Grid>
</ScrollViewer>
</ui:Page>
@@ -0,0 +1,34 @@
using Ink_Canvas.Helpers;
using Ink_Canvas.Windows.SettingsViews.Helpers;
using System.Windows;
using Page = iNKORE.UI.WPF.Modern.Controls.Page;
namespace Ink_Canvas.Windows.SettingsViews.Pages
{
public partial class DebugPage : Page
{
private bool _isLoaded;
public DebugPage()
{
InitializeComponent();
Loaded += (s, e) =>
{
ToggleSwitchDebugConsole.IsOn = SettingsManager.Settings.Advanced.IsDebugConsoleEnabled;
_isLoaded = true;
};
Unloaded += (s, e) => _isLoaded = false;
}
private void ToggleSwitchDebugConsole_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
bool isOn = ToggleSwitchDebugConsole.IsOn;
SettingsManager.Settings.Advanced.IsDebugConsoleEnabled = isOn;
SettingsManager.SaveSettingsToFile();
if (isOn) DebugConsoleManager.Show();
else DebugConsoleManager.Hide();
}
}
}