Skip to content

Commit

Permalink
improve keyboard shortcut interactive
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Jun 2, 2022
1 parent 35851b1 commit 3b76b57
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
6 changes: 5 additions & 1 deletion NavisAddinManager/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"profiles": {
"NavisAddinManager": {
"Navis2022": {
"commandName": "Executable",
"executablePath": "C:\\Program Files\\Autodesk\\Navisworks Manage 2022\\Roamer.exe"
} ,
"Navis2023": {
"commandName": "Executable",
"executablePath": "C:\\Program Files\\Autodesk\\Navisworks Manage 2023\\Roamer.exe"
}
Expand Down
5 changes: 4 additions & 1 deletion NavisAddinManager/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 @@ -46,7 +47,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 @@ -89,6 +91,7 @@
FontSize="14"
Foreground="SteelBlue"
Header="Load Plugins"
PreviewKeyDown="HandleTreeViewCommandKeyPress"
IsSelected="{Binding IsTabCmdSelected}">
<control:ExtendedTreeView
x:Name="TreeViewCommand"
Expand Down
40 changes: 40 additions & 0 deletions NavisAddinManager/View/FrmAddInManager.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Windows;
using System.Windows.Input;
using NavisAddinManager.ViewModel;
using KeyEventArgs = System.Windows.Input.KeyEventArgs;

namespace NavisAddinManager.View;

Expand Down Expand Up @@ -64,4 +65,43 @@ void ZoomOut()
TreeViewCommand.FontSize -= 2f;
}
}

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

private void ExecuteAddinCommandClick()
public void ExecuteAddinCommandClick()
{
try
{
Expand Down

0 comments on commit 3b76b57

Please sign in to comment.