Skip to content

Commit

Permalink
improve keyboard shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Jun 2, 2022
1 parent 801ec22 commit 411d55d
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Changelog
- 2022-06-02 **1.0.7**
- Support event ArrowKeyDown and ArrowKeyUp to move between items search and TreeView
- Support press key Esc from keyboard to close Form.
- 2022-05-29 **1.0.6**
- Add tab lisp function and support reload update lisp function
- 2022-05-22 **1.0.5**
Expand Down
6 changes: 5 additions & 1 deletion CadAddinManager/View/FrmAddInManager.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
MinHeight="400"
d:DataContext="{d:DesignInstance viewModel:AddInManagerViewModel}"
FocusManager.FocusedElement="{x:Reference tbxSearch}"
PreviewKeyDown="CloseFormEvent"
Icon="../Resources/dev.ico"
mc:Ignorable="d">
<Window.Resources>
Expand Down Expand Up @@ -47,7 +48,8 @@
Grid.Row="0"
Margin="5,0,5,0"
VerticalAlignment="Center"
Text="{Binding SearchText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
Text="{Binding SearchText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
PreviewKeyDown="HandleTextboxKeyPress">
<TextBox.Resources>
<VisualBrush
x:Key="tbxText"
Expand Down Expand Up @@ -91,6 +93,7 @@
FontSize="14"
Foreground="SteelBlue"
Header="Command"
PreviewKeyDown="HandleTreeViewCommandKeyPress"
IsSelected="{Binding IsTabCmdSelected}">
<control:ExtendedTreeView
x:Name="TreeViewCommand"
Expand Down Expand Up @@ -152,6 +155,7 @@
FontSize="14"
Foreground="SteelBlue"
Header="Lisp Function"
PreviewKeyDown="HandleTreeViewLispKeyPress"
IsSelected="{Binding IsTabLispSelected}">
<control:ExtendedTreeView
x:Name="TreeViewLispFunction"
Expand Down
65 changes: 65 additions & 0 deletions CadAddinManager/View/FrmAddInManager.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,69 @@ private void TbxDescription_OnLostKeyboardFocus(object sender, KeyboardFocusChan
}
viewModel.MAddinManagerBase.AddinManager.SaveToAimIni();
}
private void HandleTextboxKeyPress(object sender, KeyEventArgs e)
{
if(e.Key == Key.Down)
{
if (viewModel.IsTabCmdSelected)
{
TreeViewCommand.Focus();
}
if (viewModel.IsTabLispSelected)
{
TreeViewLispFunction.Focus();
}
else
{
LogControl.Focus();
}
}

}
private void HandleTreeViewCommandKeyPress(object sender, KeyEventArgs e)
{
int indexCmd = TreeViewCommand.Items.IndexOf(TreeViewCommand.SelectedItem);
if (e.Key == Key.Up && TabCommand.IsFocused)
{
tbxSearch.Focus();
}
else if (e.Key == Key.Up && indexCmd==0 && TabCommand.IsSelected)
{
TabCommand.Focus();
}
if (e.Key == Key.Down && TabCommand.IsSelected)
{
TreeViewCommand.Focus();
}
if (e.Key == Key.Enter)
{
viewModel.ExecuteAddinCommandClick();
}

}
private void HandleTreeViewLispKeyPress(object sender, KeyEventArgs e)
{
int indexCmd = TreeViewLispFunction.Items.IndexOf(TreeViewLispFunction.SelectedItem);
if (e.Key == Key.Up && TabLispFunction.IsFocused)
{
tbxSearch.Focus();
}
else if (e.Key == Key.Up && indexCmd==0 && TabLispFunction.IsSelected)
{
TabLispFunction.Focus();
}
if (e.Key == Key.Down && TabLispFunction.IsSelected)
{
TreeViewLispFunction.Focus();
}
if (e.Key == Key.Enter)
{
viewModel.ExecuteAddinCommandClick();
}

}
private void CloseFormEvent(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape) Close();
}
}
2 changes: 1 addition & 1 deletion CadAddinManager/ViewModel/AddInManagerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private ObservableCollection<AddinModel> FreshTreeItems(bool isSearchText, Addin
return MainTrees;
}

private void ExecuteAddinCommandClick()
public void ExecuteAddinCommandClick()
{
try
{
Expand Down
2 changes: 1 addition & 1 deletion Installer/Installer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
const string projectName = "CadAddinManager";
const string outputName = "CadAddinManager";
const string outputDir = "output";
const string version = "1.0.6";
const string version = "1.0.7";
var fileName = new StringBuilder().Append(outputName).Append("-").Append(version);
var project = new Project
{
Expand Down
5 changes: 4 additions & 1 deletion Readme.MD
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ Some feature include:
- <kbd>F1</kbd> - Go link open source report some error,bug or feature request.
- <kbd>Delete</kbd> - Quick remove by use right click or use from keyboard.
- <kbd>Crt + MouseWheel</kbd> - Zoom in/out by use mouse wheel in command plugin.

- <kbd>Arrow Up</kbd> - Move from TreeView to search.
- <kbd>Arrow Down</kbd> - Move from search to TreeView.
- <kbd>Esc</kbd> - Quick Close Add-in Manager.
- <kbd>Enter</kbd> - Quick Run Execute a command selected in Add-in Manager.
## Add-In Manager

![](pic/AddinManager.gif)
Expand Down

0 comments on commit 411d55d

Please sign in to comment.