[feat] 初步实现快捷键

This commit is contained in:
kengwang 2023-02-13 15:57:10 +08:00 committed by Kengwang
parent 5b64b1b834
commit e30ee836c4
2 changed files with 76 additions and 2 deletions

View File

@ -30,11 +30,31 @@
<c:VisibilityConverter x:Key="VisibilityConverter"/> <c:VisibilityConverter x:Key="VisibilityConverter"/>
<RoutedUICommand x:Key="KeyExit" Text=" "/> <RoutedUICommand x:Key="KeyExit" Text=" "/>
<RoutedUICommand x:Key="back_HotKey_Command" Text=" "/> <RoutedUICommand x:Key="back_HotKey_Command" Text=" "/>
<RoutedUICommand x:Key="HotKey_Capture" Text=" "/>
<RoutedUICommand x:Key="HotKey_Hide" Text=" "/>
<RoutedUICommand x:Key="HotKey_ChangeToDrawTool" Text=" "/>
<RoutedUICommand x:Key="HotKey_ChangeToSelect" Text=" "/>
<RoutedUICommand x:Key="HotKey_ChangeToEraser" Text=" "/>
<RoutedUICommand x:Key="HotKey_ChangeToPen1" Text=" "/>
<RoutedUICommand x:Key="HotKey_ChangeToPen2" Text=" "/>
<RoutedUICommand x:Key="HotKey_ChangeToPen3" Text=" "/>
<RoutedUICommand x:Key="HotKey_ChangeToPen4" Text=" "/>
<RoutedUICommand x:Key="HotKey_ChangeToPen5" Text=" "/>
</Window.Resources> </Window.Resources>
<!--输入命令绑定--> <!--输入命令绑定-->
<Window.InputBindings> <Window.InputBindings>
<KeyBinding Gesture="Shift+Esc" Command="{StaticResource KeyExit}"/> <KeyBinding Gesture="Shift+Esc" Command="{StaticResource KeyExit}"/>
<KeyBinding Modifiers="Ctrl" Key="Z" Command="{StaticResource back_HotKey_Command}"/> <KeyBinding Modifiers="Alt" Key="Z" Command="{StaticResource back_HotKey_Command}"/>
<KeyBinding Modifiers="Alt" Key="S" Command="{StaticResource HotKey_ChangeToSelect}" />
<KeyBinding Modifiers="Alt" Key="D" Command="{StaticResource HotKey_ChangeToDrawTool}" />
<KeyBinding Modifiers="Alt" Key="E" Command="{StaticResource HotKey_ChangeToEraser}" />
<KeyBinding Modifiers="Alt" Key="C" Command="{StaticResource HotKey_Capture}" />
<KeyBinding Modifiers="Alt" Key="D1" Command="{StaticResource HotKey_ChangeToPen1}" />
<KeyBinding Modifiers="Alt" Key="D2" Command="{StaticResource HotKey_ChangeToPen2}" />
<KeyBinding Modifiers="Alt" Key="D3" Command="{StaticResource HotKey_ChangeToPen3}" />
<KeyBinding Modifiers="Alt" Key="D4" Command="{StaticResource HotKey_ChangeToPen4}" />
<KeyBinding Modifiers="Alt" Key="D5" Command="{StaticResource HotKey_ChangeToPen5}" />
<KeyBinding Modifiers="Alt" Key="V" Command="{StaticResource HotKey_Hide}" />
</Window.InputBindings> </Window.InputBindings>
<!--命令执行方法绑定--> <!--命令执行方法绑定-->
<Window.CommandBindings> <Window.CommandBindings>
@ -44,6 +64,21 @@
<CommandBinding Command="{StaticResource KeyExit}" <CommandBinding Command="{StaticResource KeyExit}"
CanExecute="CommandBinding_CanExecute" CanExecute="CommandBinding_CanExecute"
Executed="KeyExit"/> Executed="KeyExit"/>
<CommandBinding Command="{StaticResource HotKey_ChangeToDrawTool}"
CanExecute="CommandBinding_CanExecute"
Executed="ChangeToDrawTool"/>
<CommandBinding Command="{StaticResource HotKey_ChangeToSelect}"
CanExecute="CommandBinding_CanExecute"
Executed="ChangeToSelect"/>
<CommandBinding Command="{StaticResource HotKey_ChangeToEraser}"
CanExecute="CommandBinding_CanExecute"
Executed="ChangeToEraser"/>
<CommandBinding Command="{StaticResource HotKey_Capture}"
CanExecute="CommandBinding_CanExecute"
Executed="Capture"/>
<CommandBinding Command="{StaticResource HotKey_Hide}"
CanExecute="CommandBinding_CanExecute"
Executed="Hide"/>
</Window.CommandBindings> </Window.CommandBindings>
<Grid x:Name="Main_Grid" Background="#01FFFFFF"> <Grid x:Name="Main_Grid" Background="#01FFFFFF">
<Grid Name="GridBackgroundCoverHolder"> <Grid Name="GridBackgroundCoverHolder">

View File

@ -267,6 +267,44 @@ namespace Ink_Canvas
BtnPPTSlideShowEnd_Click(BtnPPTSlideShowEnd, null); BtnPPTSlideShowEnd_Click(BtnPPTSlideShowEnd, null);
} }
private void ChangeToDrawTool(object sender, ExecutedRoutedEventArgs e)
{
if (inkCanvas.Visibility == Visibility.Collapsed)
{
BtnHideInkCanvas_Click(sender, e);
}
}
private void ChangeToSelect(object sender, ExecutedRoutedEventArgs e)
{
if (inkCanvas.Visibility == Visibility.Visible)
{
BtnHideInkCanvas_Click(sender, e);
}
}
private void ChangeToEraser(object sender, ExecutedRoutedEventArgs e)
{
if (ImageEraserMask.Visibility == Visibility.Visible)
{
BtnColorRed_Click(sender, null);
}
else
{
BtnErase_Click(sender, e);
}
}
private void Capture(object sender, ExecutedRoutedEventArgs e)
{
BtnScreenshot_Click(sender,e);
}
private void Hide(object sender, ExecutedRoutedEventArgs e)
{
SymbolIconEmoji_MouseUp(sender, null);
}
#endregion Hotkeys #endregion Hotkeys
#region Definations and Loading #region Definations and Loading
@ -6170,7 +6208,7 @@ namespace Ink_Canvas
{ {
isDragDropInEffect = false; isDragDropInEffect = false;
if (downPos.X == e.GetPosition(null).X && downPos.Y == e.GetPosition(null).Y) if (e is null || (downPos.X == e.GetPosition(null).X && downPos.Y == e.GetPosition(null).Y))
{ {
if (BorderFloatingBarMainControls.Visibility == Visibility.Visible) if (BorderFloatingBarMainControls.Visibility == Visibility.Visible)
{ {
@ -6299,6 +6337,7 @@ namespace Ink_Canvas
#endregion #endregion
} }
#region Test for pen #region Test for pen