@@ -2028,52 +2028,30 @@ namespace Ink_Canvas
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 暂时隐藏设置面板
|
||||||
|
BorderSettings.Visibility = Visibility.Hidden;
|
||||||
|
BorderSettingsMask.Visibility = Visibility.Hidden;
|
||||||
|
|
||||||
// 创建快捷键设置窗口
|
// 创建快捷键设置窗口
|
||||||
var hotkeySettingsWindow = new HotkeySettingsWindow(this, _globalHotkeyManager);
|
var hotkeySettingsWindow = new HotkeySettingsWindow(this, _globalHotkeyManager);
|
||||||
|
|
||||||
// 确保窗口在显示前获得正确的焦点和置顶状态
|
// 设置窗口关闭事件,用于在快捷键设置窗口关闭后恢复设置面板
|
||||||
hotkeySettingsWindow.Loaded += (s, e) =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// 确保窗口获得焦点
|
|
||||||
hotkeySettingsWindow.Activate();
|
|
||||||
hotkeySettingsWindow.Focus();
|
|
||||||
|
|
||||||
// 如果主窗口处于置顶状态,临时调整子窗口的置顶状态
|
|
||||||
if (Settings.Advanced.IsAlwaysOnTop)
|
|
||||||
{
|
|
||||||
// 临时设置子窗口为置顶,确保它在主窗口之上
|
|
||||||
hotkeySettingsWindow.Topmost = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
LogHelper.WriteLogToFile($"设置快捷键设置窗口焦点时出错: {ex.Message}", LogHelper.LogType.Error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 窗口关闭时恢复置顶状态
|
|
||||||
hotkeySettingsWindow.Closed += (s, e) =>
|
hotkeySettingsWindow.Closed += (s, e) =>
|
||||||
{
|
{
|
||||||
try
|
// 恢复设置面板显示
|
||||||
{
|
BorderSettings.Visibility = Visibility.Visible;
|
||||||
// 恢复主窗口的置顶状态
|
BorderSettingsMask.Visibility = Visibility.Visible;
|
||||||
if (Settings.Advanced.IsAlwaysOnTop)
|
|
||||||
{
|
|
||||||
ApplyAlwaysOnTop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
LogHelper.WriteLogToFile($"恢复主窗口置顶状态时出错: {ex.Message}", LogHelper.LogType.Error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 显示快捷键设置窗口
|
||||||
hotkeySettingsWindow.ShowDialog();
|
hotkeySettingsWindow.ShowDialog();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
// 确保在发生错误时也恢复设置面板显示
|
||||||
|
BorderSettings.Visibility = Visibility.Visible;
|
||||||
|
BorderSettingsMask.Visibility = Visibility.Visible;
|
||||||
|
|
||||||
LogHelper.WriteLogToFile($"打开快捷键设置窗口时出错: {ex.Message}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"打开快捷键设置窗口时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||||
MessageBox.Show($"打开快捷键设置窗口时出错: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show($"打开快捷键设置窗口时出错: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -468,45 +468,55 @@ namespace Ink_Canvas
|
|||||||
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
BlackboardUIGridForInkReplay.IsHitTestVisible = false;
|
||||||
dec.Add(e.TouchDevice.Id);
|
dec.Add(e.TouchDevice.Id);
|
||||||
|
|
||||||
// Palm Eraser 逻辑 - 优化:改进手掌判定条件,提高精度
|
// Palm Eraser 逻辑 - 优化:改进手掌判定条件,使用设备提供的触摸面积信息
|
||||||
if (Settings.Canvas.EnablePalmEraser && dec.Count >= 2 && !isPalmEraserActive && !palmEraserTouchDownHandled)
|
if (Settings.Canvas.EnablePalmEraser && dec.Count >= 2 && !isPalmEraserActive && !palmEraserTouchDownHandled)
|
||||||
{
|
{
|
||||||
var bounds = e.GetTouchPoint(inkCanvas).Bounds;
|
touchPoint = e.GetTouchPoint(inkCanvas);
|
||||||
|
var size = touchPoint.Size; // 使用设备提供的触摸面积信息
|
||||||
|
var bounds = touchPoint.Bounds; // 保留bounds用于宽高比计算
|
||||||
|
|
||||||
// 根据敏感度设置调整判定参数
|
// 根据敏感度设置调整判定参数
|
||||||
double palmThreshold;
|
double palmAreaThreshold; // 改为面积阈值
|
||||||
double aspectRatioThreshold;
|
double aspectRatioThreshold;
|
||||||
int minTouchPoints;
|
int minTouchPoints;
|
||||||
|
|
||||||
switch (Settings.Canvas.PalmEraserSensitivity)
|
switch (Settings.Canvas.PalmEraserSensitivity)
|
||||||
{
|
{
|
||||||
case 0: // 低敏感度 - 更严格的判定
|
case 0: // 低敏感度 - 更严格的判定
|
||||||
palmThreshold = 80;
|
palmAreaThreshold = 6400; // 80*80的面积
|
||||||
aspectRatioThreshold = 0.4;
|
aspectRatioThreshold = 0.4;
|
||||||
minTouchPoints = 4;
|
minTouchPoints = 4;
|
||||||
break;
|
break;
|
||||||
case 1: // 中敏感度 - 平衡的判定
|
case 1: // 中敏感度 - 平衡的判定
|
||||||
palmThreshold = 60;
|
palmAreaThreshold = 3600; // 60*60的面积
|
||||||
aspectRatioThreshold = 0.3;
|
aspectRatioThreshold = 0.3;
|
||||||
minTouchPoints = 3;
|
minTouchPoints = 3;
|
||||||
break;
|
break;
|
||||||
case 2: // 高敏感度 - 较宽松的判定
|
case 2: // 高敏感度 - 较宽松的判定
|
||||||
default:
|
default:
|
||||||
palmThreshold = 50;
|
palmAreaThreshold = 2500; // 50*50的面积
|
||||||
aspectRatioThreshold = 0.25;
|
aspectRatioThreshold = 0.25;
|
||||||
minTouchPoints = 2;
|
minTouchPoints = 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算宽高比
|
// 计算触摸面积(使用设备提供的Size)
|
||||||
|
double touchArea = size.Width * size.Height;
|
||||||
|
|
||||||
|
// 计算宽高比(使用Bounds确保准确性)
|
||||||
double aspectRatio = Math.Min(bounds.Width, bounds.Height) / Math.Max(bounds.Width, bounds.Height);
|
double aspectRatio = Math.Min(bounds.Width, bounds.Height) / Math.Max(bounds.Width, bounds.Height);
|
||||||
|
|
||||||
// 更严格的手掌判定条件
|
// 改进的手掌判定条件:使用面积而不是单独的宽高
|
||||||
bool isLargeTouch = bounds.Width >= palmThreshold && bounds.Height >= palmThreshold;
|
bool isLargeTouch = touchArea >= palmAreaThreshold;
|
||||||
bool isPalmLikeShape = aspectRatio >= aspectRatioThreshold;
|
bool isPalmLikeShape = aspectRatio >= aspectRatioThreshold;
|
||||||
bool hasMultipleTouchPoints = dec.Count >= minTouchPoints;
|
bool hasMultipleTouchPoints = dec.Count >= minTouchPoints;
|
||||||
|
|
||||||
|
// 新增:额外的判定条件提高准确性
|
||||||
|
bool isReasonableSize = size.Width >= 20 && size.Height >= 20 && size.Width <= 200 && size.Height <= 200; // 合理的触摸尺寸范围
|
||||||
|
bool isNotTooElongated = aspectRatio >= 0.2; // 避免过于细长的触摸(可能是手指)
|
||||||
|
bool hasEnoughArea = touchArea >= 400; // 最小面积要求,避免小面积误判
|
||||||
|
|
||||||
if (isLargeTouch && isPalmLikeShape && hasMultipleTouchPoints)
|
if (isLargeTouch && isPalmLikeShape && hasMultipleTouchPoints && isReasonableSize && isNotTooElongated && hasEnoughArea)
|
||||||
{
|
{
|
||||||
// 记录当前编辑模式和高光状态
|
// 记录当前编辑模式和高光状态
|
||||||
palmEraserLastEditingMode = inkCanvas.EditingMode;
|
palmEraserLastEditingMode = inkCanvas.EditingMode;
|
||||||
@@ -529,7 +539,7 @@ namespace Ink_Canvas
|
|||||||
StartPalmEraserRecoveryTimer();
|
StartPalmEraserRecoveryTimer();
|
||||||
|
|
||||||
// 记录日志
|
// 记录日志
|
||||||
LogHelper.WriteLogToFile($"Palm eraser activated - Sensitivity: {Settings.Canvas.PalmEraserSensitivity}, Touch bounds: {bounds.Width}x{bounds.Height}, Aspect ratio: {aspectRatio:F2}, Touch points: {dec.Count}");
|
LogHelper.WriteLogToFile($"Palm eraser activated - Sensitivity: {Settings.Canvas.PalmEraserSensitivity}, Touch area: {touchArea:F0}, Size: {size.Width}x{size.Height}, Bounds: {bounds.Width}x{bounds.Height}, Aspect ratio: {aspectRatio:F2}, Touch points: {dec.Count}, Reasonable size: {isReasonableSize}, Not elongated: {isNotTooElongated}, Enough area: {hasEnoughArea}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -602,6 +612,8 @@ namespace Ink_Canvas
|
|||||||
// 当所有手掌擦触摸点都抬起时,恢复原编辑模式
|
// 当所有手掌擦触摸点都抬起时,恢复原编辑模式
|
||||||
if (isPalmEraserActive && palmEraserTouchIds.Count == 0)
|
if (isPalmEraserActive && palmEraserTouchIds.Count == 0)
|
||||||
{
|
{
|
||||||
|
LogHelper.WriteLogToFile($"Palm eraser recovery triggered - Touch points remaining: {palmEraserTouchIds.Count}, dec.Count: {dec.Count}");
|
||||||
|
|
||||||
// 恢复高光状态
|
// 恢复高光状态
|
||||||
drawingAttributes.IsHighlighter = palmEraserLastIsHighlighter;
|
drawingAttributes.IsHighlighter = palmEraserLastIsHighlighter;
|
||||||
|
|
||||||
@@ -764,6 +776,37 @@ namespace Ink_Canvas
|
|||||||
// 修复:确保手掌擦除后触摸事件能正常响应
|
// 修复:确保手掌擦除后触摸事件能正常响应
|
||||||
if (isPalmEraserActive)
|
if (isPalmEraserActive)
|
||||||
{
|
{
|
||||||
|
LogHelper.WriteLogToFile("Palm eraser force recovery - all touch points cleared");
|
||||||
|
|
||||||
|
// 恢复高光状态
|
||||||
|
drawingAttributes.IsHighlighter = palmEraserLastIsHighlighter;
|
||||||
|
|
||||||
|
// 恢复编辑模式
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint)
|
||||||
|
{
|
||||||
|
switch (palmEraserLastEditingMode)
|
||||||
|
{
|
||||||
|
case InkCanvasEditingMode.Ink:
|
||||||
|
PenIcon_Click(null, null);
|
||||||
|
break;
|
||||||
|
case InkCanvasEditingMode.Select:
|
||||||
|
SymbolIconSelect_MouseUp(null, null);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
inkCanvas.EditingMode = palmEraserLastEditingMode;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
LogHelper.WriteLogToFile($"Palm eraser force recovered to mode: {palmEraserLastEditingMode}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogHelper.WriteLogToFile($"Palm eraser force recovery failed: {ex.Message}, forcing to Ink mode", LogHelper.LogType.Error);
|
||||||
|
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
|
||||||
|
}
|
||||||
|
|
||||||
// 如果手掌擦还在激活状态但触摸点已清空,强制重置状态
|
// 如果手掌擦还在激活状态但触摸点已清空,强制重置状态
|
||||||
isPalmEraserActive = false;
|
isPalmEraserActive = false;
|
||||||
palmEraserTouchDownHandled = false;
|
palmEraserTouchDownHandled = false;
|
||||||
@@ -773,6 +816,11 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
ViewboxFloatingBar.IsHitTestVisible = true;
|
ViewboxFloatingBar.IsHitTestVisible = true;
|
||||||
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
|
BlackboardUIGridForInkReplay.IsHitTestVisible = true;
|
||||||
|
|
||||||
|
// 停止恢复定时器
|
||||||
|
StopPalmEraserRecoveryTimer();
|
||||||
|
|
||||||
|
LogHelper.WriteLogToFile("Palm eraser force recovery completed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ namespace Ink_Canvas
|
|||||||
[JsonProperty("enablePalmEraser")]
|
[JsonProperty("enablePalmEraser")]
|
||||||
public bool EnablePalmEraser { get; set; } = true;
|
public bool EnablePalmEraser { get; set; } = true;
|
||||||
[JsonProperty("palmEraserSensitivity")]
|
[JsonProperty("palmEraserSensitivity")]
|
||||||
public int PalmEraserSensitivity { get; set; } = 2; // 0-低敏感度, 1-中敏感度, 2-高敏感度
|
public int PalmEraserSensitivity { get; set; } = 0; // 0-低敏感度, 1-中敏感度, 2-高敏感度
|
||||||
[JsonProperty("clearCanvasAlsoClearImages")]
|
[JsonProperty("clearCanvasAlsoClearImages")]
|
||||||
public bool ClearCanvasAlsoClearImages { get; set; } = true;
|
public bool ClearCanvasAlsoClearImages { get; set; } = true;
|
||||||
[JsonProperty("showCircleCenter")]
|
[JsonProperty("showCircleCenter")]
|
||||||
|
|||||||
@@ -6,185 +6,194 @@
|
|||||||
xmlns:local="clr-namespace:Ink_Canvas.Windows"
|
xmlns:local="clr-namespace:Ink_Canvas.Windows"
|
||||||
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||||
ui:ThemeManager.RequestedTheme="Light"
|
ui:ThemeManager.RequestedTheme="Light"
|
||||||
Background="Transparent"
|
Background="#F9F9F9"
|
||||||
AllowsTransparency="True"
|
AllowsTransparency="True"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
WindowStyle="None"
|
WindowStyle="None"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
|
ResizeMode="CanResize"
|
||||||
Title="快捷键设置"
|
Title="快捷键设置"
|
||||||
Height="600"
|
Height="600"
|
||||||
Width="800">
|
Width="800">
|
||||||
|
|
||||||
<Border Background="#F0F3F9" CornerRadius="10" BorderThickness="1" BorderBrush="#0066BF" Margin="10">
|
<Grid>
|
||||||
<Grid>
|
<Grid.RowDefinitions>
|
||||||
<!-- 标题栏 -->
|
<RowDefinition Height="Auto"/>
|
||||||
<Border Height="50" Background="#0066BF" CornerRadius="10,10,0,0" VerticalAlignment="Top">
|
<RowDefinition Height="*"/>
|
||||||
<Grid>
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!-- 标题栏 -->
|
||||||
|
<Border Grid.Row="0" Background="#3B82F6" Height="60"
|
||||||
|
MouseLeftButtonDown="TitleBar_MouseLeftButtonDown">
|
||||||
|
<Grid>
|
||||||
|
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="20,0,0,0">
|
||||||
<TextBlock Text="快捷键设置"
|
<TextBlock Text="快捷键设置"
|
||||||
Foreground="White"
|
Foreground="White"
|
||||||
FontSize="18"
|
FontSize="22"
|
||||||
FontWeight="Bold"
|
FontWeight="SemiBold"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"/>
|
||||||
HorizontalAlignment="Center"/>
|
</StackPanel>
|
||||||
<Button x:Name="BtnClose"
|
<Button x:Name="BtnClose"
|
||||||
Content="✕"
|
Content=""
|
||||||
Width="30"
|
FontFamily="Segoe MDL2 Assets"
|
||||||
Height="30"
|
HorizontalAlignment="Right"
|
||||||
Background="Transparent"
|
VerticalAlignment="Center"
|
||||||
Foreground="White"
|
Margin="0,0,20,0"
|
||||||
FontSize="14"
|
Background="Transparent"
|
||||||
HorizontalAlignment="Right"
|
BorderThickness="0"
|
||||||
Margin="0,0,30,0"
|
FontSize="16"
|
||||||
Click="BtnClose_Click"/>
|
Foreground="White"
|
||||||
</Grid>
|
Click="BtnClose_Click"/>
|
||||||
</Border>
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
|
||||||
<!-- 内容区域 -->
|
<!-- 主内容区 -->
|
||||||
<ScrollViewer Margin="0,50,0,0" VerticalScrollBarVisibility="Auto">
|
<ScrollViewer Grid.Row="1" Margin="20" VerticalScrollBarVisibility="Auto">
|
||||||
<ui:SimpleStackPanel Margin="20">
|
<ui:SimpleStackPanel Margin="20">
|
||||||
<!-- 说明文字 -->
|
<!-- 说明文字 -->
|
||||||
<TextBlock Text="在这里可以自定义全局快捷键设置。全局快捷键在任何情况下都能生效,即使应用程序不在焦点状态。"
|
<TextBlock Text="在这里可以自定义全局快捷键设置。全局快捷键在任何情况下都能生效,即使应用程序不在焦点状态。"
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
Margin="0,0,0,20"
|
Margin="0,0,0,20"
|
||||||
Foreground="#666666"/>
|
Foreground="#666666"/>
|
||||||
|
|
||||||
<!-- 鼠标模式快捷键设置 -->
|
<!-- 鼠标模式快捷键设置 -->
|
||||||
<GroupBox Header="鼠标模式设置" Margin="0,0,0,20">
|
<GroupBox Header="鼠标模式设置" Margin="0,0,0,20">
|
||||||
|
<ui:SimpleStackPanel>
|
||||||
|
<ui:SimpleStackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||||
|
<ui:ToggleSwitch x:Name="ToggleSwitchEnableHotkeysInMouseMode"
|
||||||
|
Header="在鼠标模式下启用快捷键"
|
||||||
|
Margin="0,0,10,0"
|
||||||
|
Width="200"/>
|
||||||
|
</ui:SimpleStackPanel>
|
||||||
|
<TextBlock Text="开启后,即使在鼠标模式下快捷键也会生效"
|
||||||
|
Foreground="#666666"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
TextWrapping="Wrap"/>
|
||||||
|
</ui:SimpleStackPanel>
|
||||||
|
</GroupBox>
|
||||||
|
|
||||||
|
<!-- 快捷键列表 -->
|
||||||
|
<ui:SimpleStackPanel x:Name="HotkeyList" Margin="0,0,0,20">
|
||||||
|
<!-- 基本操作 -->
|
||||||
|
<GroupBox Header="基本操作" Margin="0,0,0,15">
|
||||||
<ui:SimpleStackPanel>
|
<ui:SimpleStackPanel>
|
||||||
<ui:SimpleStackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
<local:HotkeyItem x:Name="UndoHotkey"
|
||||||
<ui:ToggleSwitch x:Name="ToggleSwitchEnableHotkeysInMouseMode"
|
Title="撤销"
|
||||||
Header="在鼠标模式下启用快捷键"
|
Description="撤销上一步操作"
|
||||||
Margin="0,0,10,0"
|
DefaultKey="Z"
|
||||||
Width="200"/>
|
DefaultModifiers="Control"/>
|
||||||
</ui:SimpleStackPanel>
|
<local:HotkeyItem x:Name="RedoHotkey"
|
||||||
<TextBlock Text="开启后,即使在鼠标模式下快捷键也会生效"
|
Title="重做"
|
||||||
Foreground="#666666"
|
Description="重做上一步操作"
|
||||||
VerticalAlignment="Center"
|
DefaultKey="Y"
|
||||||
TextWrapping="Wrap"/>
|
DefaultModifiers="Control"/>
|
||||||
|
<local:HotkeyItem x:Name="ClearHotkey"
|
||||||
|
Title="清空"
|
||||||
|
Description="清空当前画板内容"
|
||||||
|
DefaultKey="E"
|
||||||
|
DefaultModifiers="Control"/>
|
||||||
|
<local:HotkeyItem x:Name="PasteHotkey"
|
||||||
|
Title="粘贴"
|
||||||
|
Description="粘贴剪贴板内容"
|
||||||
|
DefaultKey="V"
|
||||||
|
DefaultModifiers="Control"/>
|
||||||
</ui:SimpleStackPanel>
|
</ui:SimpleStackPanel>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
<!-- 快捷键列表 -->
|
<!-- 工具切换 -->
|
||||||
<ui:SimpleStackPanel x:Name="HotkeyList" Margin="0,0,0,20">
|
<GroupBox Header="工具切换" Margin="0,0,0,15">
|
||||||
<!-- 基本操作 -->
|
<ui:SimpleStackPanel>
|
||||||
<GroupBox Header="基本操作" Margin="0,0,0,15">
|
<local:HotkeyItem x:Name="SelectToolHotkey"
|
||||||
<ui:SimpleStackPanel>
|
Title="选择工具"
|
||||||
<local:HotkeyItem x:Name="UndoHotkey"
|
Description="切换到选择工具"
|
||||||
Title="撤销"
|
DefaultKey="S"
|
||||||
Description="撤销上一步操作"
|
DefaultModifiers="Alt"/>
|
||||||
DefaultKey="Z"
|
<local:HotkeyItem x:Name="DrawToolHotkey"
|
||||||
DefaultModifiers="Control"/>
|
Title="绘图工具"
|
||||||
<local:HotkeyItem x:Name="RedoHotkey"
|
Description="切换到绘图工具"
|
||||||
Title="重做"
|
DefaultKey="D"
|
||||||
Description="重做上一步操作"
|
DefaultModifiers="Alt"/>
|
||||||
DefaultKey="Y"
|
<local:HotkeyItem x:Name="EraserToolHotkey"
|
||||||
DefaultModifiers="Control"/>
|
Title="橡皮擦工具"
|
||||||
<local:HotkeyItem x:Name="ClearHotkey"
|
Description="切换到橡皮擦工具"
|
||||||
Title="清空"
|
DefaultKey="E"
|
||||||
Description="清空当前画板内容"
|
DefaultModifiers="Alt"/>
|
||||||
DefaultKey="E"
|
<local:HotkeyItem x:Name="BlackboardToolHotkey"
|
||||||
DefaultModifiers="Control"/>
|
Title="黑板工具"
|
||||||
<local:HotkeyItem x:Name="PasteHotkey"
|
Description="切换到黑板工具"
|
||||||
Title="粘贴"
|
DefaultKey="B"
|
||||||
Description="粘贴剪贴板内容"
|
DefaultModifiers="Alt"/>
|
||||||
DefaultKey="V"
|
<local:HotkeyItem x:Name="QuitDrawToolHotkey"
|
||||||
DefaultModifiers="Control"/>
|
Title="退出绘图/白板"
|
||||||
</ui:SimpleStackPanel>
|
Description="退出绘图模式或白板模式"
|
||||||
</GroupBox>
|
DefaultKey="Q"
|
||||||
|
DefaultModifiers="Alt"/>
|
||||||
|
</ui:SimpleStackPanel>
|
||||||
|
</GroupBox>
|
||||||
|
|
||||||
<!-- 工具切换 -->
|
<!-- 画笔设置 -->
|
||||||
<GroupBox Header="工具切换" Margin="0,0,0,15">
|
<GroupBox Header="画笔设置" Margin="0,0,0,15">
|
||||||
<ui:SimpleStackPanel>
|
<ui:SimpleStackPanel>
|
||||||
<local:HotkeyItem x:Name="SelectToolHotkey"
|
<local:HotkeyItem x:Name="Pen1Hotkey"
|
||||||
Title="选择工具"
|
Title="画笔1"
|
||||||
Description="切换到选择工具"
|
Description="选择画笔1"
|
||||||
DefaultKey="S"
|
DefaultKey="D1"
|
||||||
DefaultModifiers="Alt"/>
|
DefaultModifiers="Alt"/>
|
||||||
<local:HotkeyItem x:Name="DrawToolHotkey"
|
<local:HotkeyItem x:Name="Pen2Hotkey"
|
||||||
Title="绘图工具"
|
Title="画笔2"
|
||||||
Description="切换到绘图工具"
|
Description="选择画笔2"
|
||||||
DefaultKey="D"
|
DefaultKey="D2"
|
||||||
DefaultModifiers="Alt"/>
|
DefaultModifiers="Alt"/>
|
||||||
<local:HotkeyItem x:Name="EraserToolHotkey"
|
<local:HotkeyItem x:Name="Pen3Hotkey"
|
||||||
Title="橡皮擦工具"
|
Title="画笔3"
|
||||||
Description="切换到橡皮擦工具"
|
Description="选择画笔3"
|
||||||
DefaultKey="E"
|
DefaultKey="D3"
|
||||||
DefaultModifiers="Alt"/>
|
DefaultModifiers="Alt"/>
|
||||||
<local:HotkeyItem x:Name="BlackboardToolHotkey"
|
<local:HotkeyItem x:Name="Pen4Hotkey"
|
||||||
Title="黑板工具"
|
Title="画笔4"
|
||||||
Description="切换到黑板工具"
|
Description="选择画笔4"
|
||||||
DefaultKey="B"
|
DefaultKey="D4"
|
||||||
DefaultModifiers="Alt"/>
|
DefaultModifiers="Alt"/>
|
||||||
<local:HotkeyItem x:Name="QuitDrawToolHotkey"
|
<local:HotkeyItem x:Name="Pen5Hotkey"
|
||||||
Title="退出绘图/白板"
|
Title="画笔5"
|
||||||
Description="退出绘图模式或白板模式"
|
Description="选择画笔5"
|
||||||
DefaultKey="Q"
|
DefaultKey="D5"
|
||||||
DefaultModifiers="Alt"/>
|
DefaultModifiers="Alt"/>
|
||||||
</ui:SimpleStackPanel>
|
</ui:SimpleStackPanel>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
<!-- 画笔设置 -->
|
<!-- 功能快捷键 -->
|
||||||
<GroupBox Header="画笔设置" Margin="0,0,0,15">
|
<GroupBox Header="功能快捷键" Margin="0,0,0,15">
|
||||||
<ui:SimpleStackPanel>
|
<ui:SimpleStackPanel>
|
||||||
<local:HotkeyItem x:Name="Pen1Hotkey"
|
<local:HotkeyItem x:Name="DrawLineHotkey"
|
||||||
Title="画笔1"
|
Title="绘制直线"
|
||||||
Description="选择画笔1"
|
Description="绘制直线工具"
|
||||||
DefaultKey="D1"
|
DefaultKey="L"
|
||||||
DefaultModifiers="Alt"/>
|
DefaultModifiers="Alt"/>
|
||||||
<local:HotkeyItem x:Name="Pen2Hotkey"
|
<local:HotkeyItem x:Name="ScreenshotHotkey"
|
||||||
Title="画笔2"
|
Title="截图"
|
||||||
Description="选择画笔2"
|
Description="保存屏幕截图到桌面"
|
||||||
DefaultKey="D2"
|
DefaultKey="C"
|
||||||
DefaultModifiers="Alt"/>
|
DefaultModifiers="Alt"/>
|
||||||
<local:HotkeyItem x:Name="Pen3Hotkey"
|
<local:HotkeyItem x:Name="HideHotkey"
|
||||||
Title="画笔3"
|
Title="隐藏"
|
||||||
Description="选择画笔3"
|
Description="隐藏应用程序"
|
||||||
DefaultKey="D3"
|
DefaultKey="V"
|
||||||
DefaultModifiers="Alt"/>
|
DefaultModifiers="Alt"/>
|
||||||
<local:HotkeyItem x:Name="Pen4Hotkey"
|
<local:HotkeyItem x:Name="ExitHotkey"
|
||||||
Title="画笔4"
|
Title="退出"
|
||||||
Description="选择画笔4"
|
Description="退出当前模式或应用程序"
|
||||||
DefaultKey="D4"
|
DefaultKey="Escape"
|
||||||
DefaultModifiers="Alt"/>
|
DefaultModifiers="None"/>
|
||||||
<local:HotkeyItem x:Name="Pen5Hotkey"
|
</ui:SimpleStackPanel>
|
||||||
Title="画笔5"
|
</GroupBox>
|
||||||
Description="选择画笔5"
|
</ui:SimpleStackPanel></ui:SimpleStackPanel>
|
||||||
DefaultKey="D5"
|
|
||||||
DefaultModifiers="Alt"/>
|
|
||||||
</ui:SimpleStackPanel>
|
|
||||||
</GroupBox>
|
|
||||||
|
|
||||||
<!-- 功能快捷键 -->
|
|
||||||
<GroupBox Header="功能快捷键" Margin="0,0,0,15">
|
|
||||||
<ui:SimpleStackPanel>
|
|
||||||
<local:HotkeyItem x:Name="DrawLineHotkey"
|
|
||||||
Title="绘制直线"
|
|
||||||
Description="绘制直线工具"
|
|
||||||
DefaultKey="L"
|
|
||||||
DefaultModifiers="Alt"/>
|
|
||||||
<local:HotkeyItem x:Name="ScreenshotHotkey"
|
|
||||||
Title="截图"
|
|
||||||
Description="保存屏幕截图到桌面"
|
|
||||||
DefaultKey="C"
|
|
||||||
DefaultModifiers="Alt"/>
|
|
||||||
<local:HotkeyItem x:Name="HideHotkey"
|
|
||||||
Title="隐藏"
|
|
||||||
Description="隐藏应用程序"
|
|
||||||
DefaultKey="V"
|
|
||||||
DefaultModifiers="Alt"/>
|
|
||||||
<local:HotkeyItem x:Name="ExitHotkey"
|
|
||||||
Title="退出"
|
|
||||||
Description="退出当前模式或应用程序"
|
|
||||||
DefaultKey="Escape"
|
|
||||||
DefaultModifiers="None"/>
|
|
||||||
</ui:SimpleStackPanel>
|
|
||||||
</GroupBox>
|
|
||||||
</ui:SimpleStackPanel>
|
|
||||||
</ui:SimpleStackPanel>
|
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
|
|
||||||
<!-- 底部按钮 -->
|
<!-- 底部操作栏 -->
|
||||||
<Border Height="60" Background="#F8F9FA" CornerRadius="0,0,10,10" VerticalAlignment="Bottom">
|
<Border Grid.Row="2" Background="#F0F0F0" Height="60">
|
||||||
|
<Grid>
|
||||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,20,0">
|
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,20,0">
|
||||||
<Button x:Name="BtnResetToDefault"
|
<Button x:Name="BtnResetToDefault"
|
||||||
Content="重置为默认"
|
Content="重置为默认"
|
||||||
@@ -196,11 +205,11 @@
|
|||||||
Content="保存设置"
|
Content="保存设置"
|
||||||
Width="100"
|
Width="100"
|
||||||
Height="35"
|
Height="35"
|
||||||
Background="#0066BF"
|
Background="#3B82F6"
|
||||||
Foreground="White"
|
Foreground="White"
|
||||||
Click="BtnSave_Click"/>
|
Click="BtnSave_Click"/>
|
||||||
</ui:SimpleStackPanel>
|
</ui:SimpleStackPanel>
|
||||||
</Border>
|
</Grid>
|
||||||
</Grid>
|
</Border>
|
||||||
</Border>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
@@ -27,11 +27,8 @@ namespace Ink_Canvas.Windows
|
|||||||
_hotkeyManager = hotkeyManager;
|
_hotkeyManager = hotkeyManager;
|
||||||
_hotkeyItems = new Dictionary<string, HotkeyItem>();
|
_hotkeyItems = new Dictionary<string, HotkeyItem>();
|
||||||
|
|
||||||
// 设置窗口属性以避免与主窗口置顶维护冲突
|
// 设置窗口属性
|
||||||
SetupWindowProperties();
|
SetupWindowProperties();
|
||||||
|
|
||||||
// 隐藏主窗口的设置页面
|
|
||||||
HideMainWindowSettings();
|
|
||||||
InitializeHotkeyItems();
|
InitializeHotkeyItems();
|
||||||
|
|
||||||
// 延迟加载快捷键,确保快捷键管理器已完全初始化
|
// 延迟加载快捷键,确保快捷键管理器已完全初始化
|
||||||
@@ -62,21 +59,17 @@ namespace Ink_Canvas.Windows
|
|||||||
|
|
||||||
#region Private Methods
|
#region Private Methods
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置窗口属性以避免与主窗口置顶维护冲突
|
/// 设置窗口属性
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void SetupWindowProperties()
|
private void SetupWindowProperties()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 设置为模态窗口,确保它始终在主窗口之上
|
|
||||||
// 但不设置Topmost,避免与主窗口的置顶维护机制冲突
|
|
||||||
this.Owner = _mainWindow;
|
|
||||||
|
|
||||||
// 设置窗口启动位置为屏幕中心
|
// 设置窗口启动位置为屏幕中心
|
||||||
this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||||
|
|
||||||
// 确保窗口在显示时获得焦点
|
// 确保窗口在显示时获得焦点
|
||||||
this.ShowInTaskbar = false;
|
this.ShowInTaskbar = true;
|
||||||
|
|
||||||
LogHelper.WriteLogToFile("快捷键设置窗口属性已设置");
|
LogHelper.WriteLogToFile("快捷键设置窗口属性已设置");
|
||||||
}
|
}
|
||||||
@@ -520,69 +513,6 @@ namespace Ink_Canvas.Windows
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region MainWindow Settings Management
|
|
||||||
/// <summary>
|
|
||||||
/// 隐藏主窗口的设置页面
|
|
||||||
/// </summary>
|
|
||||||
private void HideMainWindowSettings()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// 通过反射访问主窗口的设置面板
|
|
||||||
var settingsBorder = _mainWindow.GetType().GetField("BorderSettings",
|
|
||||||
BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(_mainWindow) as Border;
|
|
||||||
|
|
||||||
if (settingsBorder != null)
|
|
||||||
{
|
|
||||||
settingsBorder.Visibility = Visibility.Collapsed;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 隐藏设置蒙版
|
|
||||||
var settingsMask = _mainWindow.GetType().GetField("BorderSettingsMask",
|
|
||||||
BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(_mainWindow) as Border;
|
|
||||||
|
|
||||||
if (settingsMask != null)
|
|
||||||
{
|
|
||||||
settingsMask.Visibility = Visibility.Collapsed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
LogHelper.WriteLogToFile($"隐藏主窗口设置页面时出错: {ex.Message}", LogHelper.LogType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 显示主窗口的设置页面
|
|
||||||
/// </summary>
|
|
||||||
private void ShowMainWindowSettings()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// 通过反射访问主窗口的设置面板
|
|
||||||
var settingsBorder = _mainWindow.GetType().GetField("BorderSettings",
|
|
||||||
BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(_mainWindow) as Border;
|
|
||||||
|
|
||||||
if (settingsBorder != null)
|
|
||||||
{
|
|
||||||
settingsBorder.Visibility = Visibility.Visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 显示设置蒙版
|
|
||||||
var settingsMask = _mainWindow.GetType().GetField("BorderSettingsMask",
|
|
||||||
BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(_mainWindow) as Border;
|
|
||||||
|
|
||||||
if (settingsMask != null)
|
|
||||||
{
|
|
||||||
settingsMask.Visibility = Visibility.Visible;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
LogHelper.WriteLogToFile($"显示主窗口设置页面时出错: {ex.Message}", LogHelper.LogType.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Window Event Handlers
|
#region Window Event Handlers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -592,13 +522,7 @@ namespace Ink_Canvas.Windows
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 重置窗口置顶状态,避免影响主窗口
|
LogHelper.WriteLogToFile("快捷键设置窗口已关闭");
|
||||||
this.Topmost = false;
|
|
||||||
|
|
||||||
// 恢复主窗口设置页面的显示
|
|
||||||
ShowMainWindowSettings();
|
|
||||||
|
|
||||||
LogHelper.WriteLogToFile("快捷键设置窗口已关闭,置顶状态已重置");
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -613,6 +537,30 @@ namespace Ink_Canvas.Windows
|
|||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标题栏拖拽事件
|
||||||
|
/// </summary>
|
||||||
|
private void TitleBar_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.ClickCount == 2)
|
||||||
|
{
|
||||||
|
// 双击标题栏切换最大化状态
|
||||||
|
if (WindowState == WindowState.Maximized)
|
||||||
|
{
|
||||||
|
WindowState = WindowState.Normal;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WindowState = WindowState.Maximized;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 拖拽窗口
|
||||||
|
DragMove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void BtnResetToDefault_Click(object sender, RoutedEventArgs e)
|
private void BtnResetToDefault_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
Title="插件管理" Height="550" Width="800"
|
Title="插件管理" Height="550" Width="800"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
ResizeMode="CanResize"
|
ResizeMode="CanResize"
|
||||||
|
WindowStyle="None"
|
||||||
|
AllowsTransparency="True"
|
||||||
Background="#F9F9F9">
|
Background="#F9F9F9">
|
||||||
|
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
@@ -27,7 +29,8 @@
|
|||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<!-- 标题栏 -->
|
<!-- 标题栏 -->
|
||||||
<Border Grid.Row="0" Background="{DynamicResource SystemAccentColorLight1}" Height="60">
|
<Border Grid.Row="0" Background="{DynamicResource SystemAccentColorLight1}" Height="60"
|
||||||
|
MouseLeftButtonDown="TitleBar_MouseLeftButtonDown">
|
||||||
<Grid>
|
<Grid>
|
||||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="20,0,0,0">
|
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="20,0,0,0">
|
||||||
<TextBlock Text="插件管理" FontSize="22" FontWeight="SemiBold" Foreground="White" VerticalAlignment="Center"/>
|
<TextBlock Text="插件管理" FontSize="22" FontWeight="SemiBold" Foreground="White" VerticalAlignment="Center"/>
|
||||||
|
|||||||
@@ -624,6 +624,30 @@ namespace Ink_Canvas.Windows
|
|||||||
// 直接关闭窗口,窗口关闭事件会处理配置保存
|
// 直接关闭窗口,窗口关闭事件会处理配置保存
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标题栏拖拽事件
|
||||||
|
/// </summary>
|
||||||
|
private void TitleBar_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.ClickCount == 2)
|
||||||
|
{
|
||||||
|
// 双击标题栏切换最大化状态
|
||||||
|
if (WindowState == WindowState.Maximized)
|
||||||
|
{
|
||||||
|
WindowState = WindowState.Normal;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WindowState = WindowState.Maximized;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 拖拽窗口
|
||||||
|
DragMove();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user