improve:快捷键和墨迹渐隐
This commit is contained in:
@@ -165,6 +165,59 @@ namespace Ink_Canvas.Helpers
|
||||
return new List<HotkeyInfo>(_registeredHotkeys.Values);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取配置文件中的快捷键信息(不注册,仅用于显示)
|
||||
/// </summary>
|
||||
/// <returns>配置文件中的快捷键列表</returns>
|
||||
public List<HotkeyInfo> GetHotkeysFromConfigFile()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!File.Exists(HotkeyConfigFile))
|
||||
{
|
||||
LogHelper.WriteLogToFile("快捷键配置文件不存在", LogHelper.LogType.Info);
|
||||
return new List<HotkeyInfo>();
|
||||
}
|
||||
|
||||
// 读取配置文件内容
|
||||
string jsonContent = File.ReadAllText(HotkeyConfigFile, System.Text.Encoding.UTF8);
|
||||
if (string.IsNullOrEmpty(jsonContent))
|
||||
{
|
||||
LogHelper.WriteLogToFile("快捷键配置文件为空", LogHelper.LogType.Warning);
|
||||
return new List<HotkeyInfo>();
|
||||
}
|
||||
|
||||
// 反序列化配置
|
||||
var config = JsonConvert.DeserializeObject<HotkeyConfig>(jsonContent);
|
||||
if (config?.Hotkeys == null || config.Hotkeys.Count == 0)
|
||||
{
|
||||
LogHelper.WriteLogToFile("快捷键配置为空或格式错误", LogHelper.LogType.Warning);
|
||||
return new List<HotkeyInfo>();
|
||||
}
|
||||
|
||||
// 转换为HotkeyInfo列表(不注册,仅用于显示)
|
||||
var hotkeyList = new List<HotkeyInfo>();
|
||||
foreach (var hotkeyConfig in config.Hotkeys)
|
||||
{
|
||||
hotkeyList.Add(new HotkeyInfo
|
||||
{
|
||||
Name = hotkeyConfig.Name,
|
||||
Key = hotkeyConfig.Key,
|
||||
Modifiers = hotkeyConfig.Modifiers,
|
||||
Action = null // 不设置动作,仅用于显示
|
||||
});
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"从配置文件读取到 {hotkeyList.Count} 个快捷键信息", LogHelper.LogType.Info);
|
||||
return hotkeyList;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"从配置文件读取快捷键信息时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
return new List<HotkeyInfo>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册默认快捷键集合
|
||||
/// </summary>
|
||||
@@ -211,7 +264,7 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从设置加载快捷键
|
||||
/// 从配置文件加载快捷键
|
||||
/// </summary>
|
||||
public void LoadHotkeysFromSettings()
|
||||
{
|
||||
|
||||
+41
-29
@@ -4061,7 +4061,7 @@
|
||||
</Border>
|
||||
<Border>
|
||||
<Grid Margin="0,5,0,5" Width="0">
|
||||
<Grid Name="BoardPenPaletteGrid" Margin="-160,-200,-33,50"
|
||||
<Grid Name="BoardPenPaletteGrid" Margin="-160,-200,-53,50"
|
||||
RenderTransformOrigin="0,1">
|
||||
<Grid.RenderTransform>
|
||||
<TransformGroup>
|
||||
@@ -4176,10 +4176,8 @@
|
||||
Margin="12,8,12,0" HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" Stretch="Fill">
|
||||
<ui:SimpleStackPanel>
|
||||
<Controls:UniformGrid Columns="2" Width="300"
|
||||
Height="55">
|
||||
<ui:SimpleStackPanel Orientation="Horizontal"
|
||||
Height="35">
|
||||
Height="35" Margin="0,0,0,8">
|
||||
<Label Content="笔锋" Margin="0,0,6,0"
|
||||
Foreground="{DynamicResource FloatBarForeground}"
|
||||
FontSize="16" FontWeight="Bold"
|
||||
@@ -4198,23 +4196,23 @@
|
||||
FontFamily="Microsoft YaHei UI" />
|
||||
</ComboBox>
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Margin="0,-5,0,-5"
|
||||
VerticalAlignment="Center">
|
||||
<Controls:UniformGrid Columns="3" Width="300"
|
||||
Height="55">
|
||||
<ui:SimpleStackPanel
|
||||
x:Name="BoardNibModeSimpleStackPanel"
|
||||
Orientation="Horizontal" Width="140">
|
||||
Orientation="Horizontal" Width="100">
|
||||
<Label Content="笔尖模式" FontSize="15"
|
||||
VerticalAlignment="Center" />
|
||||
<ui:ToggleSwitch
|
||||
x:Name="BoardToggleSwitchEnableNibMode"
|
||||
MinWidth="0"
|
||||
FontFamily="Microsoft YaHei UI"
|
||||
Width="70" Margin="10,0,0,0"
|
||||
Width="80" Margin="10,0,0,0"
|
||||
Toggled="ToggleSwitchEnableNibMode_Toggled"
|
||||
IsOn="True" />
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Orientation="Horizontal"
|
||||
Width="140">
|
||||
Width="100">
|
||||
<Label Margin="0,0,10,0" Content="墨迹纠正"
|
||||
Foreground="{DynamicResource FloatBarForeground}"
|
||||
FontSize="15"
|
||||
@@ -4222,11 +4220,25 @@
|
||||
<ui:ToggleSwitch
|
||||
Foreground="{DynamicResource FloatBarForeground}"
|
||||
FontFamily="Microsoft YaHei UI"
|
||||
Width="70"
|
||||
Width="80"
|
||||
Toggled="ToggleSwitchEnableInkToShape_Toggled"
|
||||
MinWidth="0"
|
||||
IsOn="{Binding ElementName=ToggleSwitchEnableInkToShape, Path=IsOn}" />
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Orientation="Horizontal"
|
||||
Width="100">
|
||||
<Label Margin="0,0,10,0" Content="墨迹渐隐"
|
||||
Foreground="{DynamicResource FloatBarForeground}"
|
||||
FontSize="15"
|
||||
VerticalAlignment="Center" />
|
||||
<ui:ToggleSwitch
|
||||
x:Name="ToggleSwitchInkFadeInPanel"
|
||||
Foreground="{DynamicResource FloatBarForeground}"
|
||||
FontFamily="Microsoft YaHei UI"
|
||||
Width="90"
|
||||
Toggled="ToggleSwitchInkFadeInPanel_Toggled"
|
||||
MinWidth="0"
|
||||
IsOn="False" />
|
||||
</ui:SimpleStackPanel>
|
||||
</Controls:UniformGrid>
|
||||
|
||||
@@ -7193,9 +7205,8 @@
|
||||
Margin="12,8,12,0" HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" Stretch="Fill">
|
||||
<ui:SimpleStackPanel>
|
||||
<Controls:UniformGrid Columns="2" Width="300" Height="55">
|
||||
<ui:SimpleStackPanel Orientation="Horizontal"
|
||||
Height="35">
|
||||
Height="35" Margin="0,0,0,8">
|
||||
<Label Content="笔锋" Margin="0,0,6,0"
|
||||
Foreground="{DynamicResource FloatBarForeground}"
|
||||
FontSize="16" FontWeight="Bold"
|
||||
@@ -7213,33 +7224,44 @@
|
||||
FontFamily="Microsoft YaHei UI" />
|
||||
</ComboBox>
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Margin="0,-5,0,-5"
|
||||
VerticalAlignment="Center">
|
||||
<Controls:UniformGrid Columns="3" Width="300" Height="55">
|
||||
<ui:SimpleStackPanel
|
||||
x:Name="NibModeSimpleStackPanel"
|
||||
Orientation="Horizontal" Width="140">
|
||||
Orientation="Horizontal" Width="100">
|
||||
<Label Content="笔尖模式" FontSize="15"
|
||||
VerticalAlignment="Center" />
|
||||
<ui:ToggleSwitch
|
||||
x:Name="ToggleSwitchEnableNibMode"
|
||||
MinWidth="0"
|
||||
FontFamily="Microsoft YaHei UI"
|
||||
Width="70" Margin="10,0,0,0"
|
||||
Width="80" Margin="10,0,0,0"
|
||||
Toggled="ToggleSwitchEnableNibMode_Toggled"
|
||||
IsOn="True" />
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Orientation="Horizontal"
|
||||
Width="140">
|
||||
Width="100">
|
||||
<Label Margin="0,0,10,0" Content="墨迹纠正"
|
||||
Foreground="{DynamicResource FloatBarForeground}"
|
||||
FontSize="15" VerticalAlignment="Center" />
|
||||
<ui:ToggleSwitch
|
||||
Foreground="{DynamicResource FloatBarForeground}"
|
||||
FontFamily="Microsoft YaHei UI" Width="70"
|
||||
FontFamily="Microsoft YaHei UI" Width="80"
|
||||
Toggled="ToggleSwitchEnableInkToShape_Toggled"
|
||||
MinWidth="0"
|
||||
IsOn="{Binding ElementName=ToggleSwitchEnableInkToShape, Path=IsOn}" />
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Orientation="Horizontal"
|
||||
Width="100">
|
||||
<Label Margin="0,0,10,0" Content="墨迹渐隐"
|
||||
Foreground="{DynamicResource FloatBarForeground}"
|
||||
FontSize="15" VerticalAlignment="Center" />
|
||||
<ui:ToggleSwitch
|
||||
x:Name="ToggleSwitchInkFadeInPanel2"
|
||||
Foreground="{DynamicResource FloatBarForeground}"
|
||||
FontFamily="Microsoft YaHei UI" Width="90"
|
||||
Toggled="ToggleSwitchInkFadeInPanel_Toggled"
|
||||
MinWidth="0"
|
||||
IsOn="{Binding ElementName=ToggleSwitchInkFadeInPanel, Path=IsOn}" />
|
||||
</ui:SimpleStackPanel>
|
||||
</Controls:UniformGrid>
|
||||
|
||||
@@ -7994,17 +8016,7 @@
|
||||
</Canvas>
|
||||
</ui:SimpleStackPanel>
|
||||
</Border>
|
||||
<!-- 墨迹渐隐开关 -->
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left"
|
||||
Margin="8,8,8,4" Spacing="8">
|
||||
<TextBlock Foreground="#1e3a8a" Text="墨迹渐隐" FontSize="12"
|
||||
VerticalAlignment="Center" FontWeight="SemiBold" />
|
||||
<ui:ToggleSwitch OnContent="" OffContent="" Name="ToggleSwitchInkFadeInPanel"
|
||||
IsOn="False" FontFamily="Microsoft YaHei UI"
|
||||
FontWeight="Bold" Toggled="ToggleSwitchInkFadeInPanel_Toggled" />
|
||||
</ui:SimpleStackPanel>
|
||||
<Line HorizontalAlignment="Center" X1="0" Y1="0" X2="315" Y2="0"
|
||||
Stroke="#e5e7eb" StrokeThickness="1" Margin="8,0,8,4" />
|
||||
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" Height="38" Spacing="2"
|
||||
Margin="4,6,4,0">
|
||||
<ui:SimpleStackPanel Name="BoardImageDrawLine"
|
||||
|
||||
@@ -907,6 +907,12 @@ namespace Ink_Canvas
|
||||
ToggleSwitchInkFadeInPanel.IsOn = Settings.Canvas.EnableInkFade;
|
||||
}
|
||||
|
||||
// 同步普通画笔面板中的开关状态
|
||||
if (ToggleSwitchInkFadeInPanel2 != null)
|
||||
{
|
||||
ToggleSwitchInkFadeInPanel2.IsOn = Settings.Canvas.EnableInkFade;
|
||||
}
|
||||
|
||||
// 同步滑块值
|
||||
if (InkFadeTimeSlider != null)
|
||||
{
|
||||
|
||||
@@ -34,8 +34,10 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
try
|
||||
{
|
||||
// 不自动启用快捷键注册功能,让用户手动决定
|
||||
// 只加载当前已注册的快捷键
|
||||
// 不启用快捷键注册功能,只读取配置文件中的快捷键信息用于显示
|
||||
// 这样用户可以看到配置文件中保存的快捷键,但不会自动注册
|
||||
|
||||
// 加载当前快捷键(包括配置文件中的)
|
||||
LoadCurrentHotkeys();
|
||||
SetupEventHandlers();
|
||||
}
|
||||
@@ -124,22 +126,31 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
try
|
||||
{
|
||||
var registeredHotkeys = _hotkeyManager.GetRegisteredHotkeys();
|
||||
LogHelper.WriteLogToFile($"当前已注册快捷键数量: {registeredHotkeys.Count}", LogHelper.LogType.Info);
|
||||
// 首先尝试从配置文件获取快捷键信息
|
||||
var configHotkeys = _hotkeyManager.GetHotkeysFromConfigFile();
|
||||
LogHelper.WriteLogToFile($"配置文件中的快捷键数量: {configHotkeys.Count}", LogHelper.LogType.Info);
|
||||
|
||||
// 显示已注册的快捷键
|
||||
foreach (var hotkey in registeredHotkeys)
|
||||
// 显示配置文件中的快捷键
|
||||
foreach (var hotkey in configHotkeys)
|
||||
{
|
||||
if (_hotkeyItems.TryGetValue(hotkey.Name, out var hotkeyItem))
|
||||
{
|
||||
hotkeyItem.SetCurrentHotkey(hotkey.Key, hotkey.Modifiers);
|
||||
LogHelper.WriteLogToFile($"设置快捷键项: {hotkey.Name} -> {hotkey.Modifiers}+{hotkey.Key}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"从配置文件设置快捷键项: {hotkey.Name} -> {hotkey.Modifiers}+{hotkey.Key}", LogHelper.LogType.Info);
|
||||
}
|
||||
}
|
||||
|
||||
// 对于没有快捷键的项目,不设置任何值,保持为空状态
|
||||
// 这样用户就能清楚地知道哪些快捷键还没有设置
|
||||
LogHelper.WriteLogToFile("未注册的快捷键项保持为空状态", LogHelper.LogType.Info);
|
||||
// 为没有快捷键的项目设置默认显示值(仅用于UI显示,不实际注册)
|
||||
foreach (var kvp in _hotkeyItems)
|
||||
{
|
||||
var hotkeyItem = kvp.Value;
|
||||
if (hotkeyItem.GetCurrentHotkey().key == Key.None)
|
||||
{
|
||||
// 根据DefaultKey和DefaultModifiers设置默认显示值
|
||||
SetDefaultHotkeyForItem(hotkeyItem);
|
||||
LogHelper.WriteLogToFile($"设置默认显示值: {hotkeyItem.HotkeyName}", LogHelper.LogType.Info);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user