Skip to content

Commit 7230d94

Browse files
committed
Ensure only file context menu is updated when being opened
1 parent 7ca28c6 commit 7230d94

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

src/SQLScriptsExplorer.Addin/Controls/FileExplorerTreeView.xaml.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,22 @@ private void TreeViewMain_SelectedItemChanged(object sender, RoutedPropertyChang
8484

8585
private void TreeViewMain_ContextMenuOpening(object sender, ContextMenuEventArgs e)
8686
{
87-
ISettingsRepository settingsRepository = new SettingsRepository();
88-
var fileContextMenu = TreeViewMain.Resources["FileContext"] as System.Windows.Controls.ContextMenu;
89-
90-
if (fileContextMenu != null)
87+
if (currentTreeNode.Type == TreeNodeType.File)
9188
{
92-
var executeMenuItem = fileContextMenu.Items[2] as MenuItem;
89+
ISettingsRepository settingsRepository = new SettingsRepository();
90+
var fileContextMenu = TreeViewMain.Resources["FileContext"] as System.Windows.Controls.ContextMenu;
9391

94-
if (executeMenuItem != null)
92+
if (fileContextMenu != null)
9593
{
96-
if (settingsRepository.ShowExecuteFileButton)
97-
executeMenuItem.Visibility = Visibility.Visible;
98-
else
99-
executeMenuItem.Visibility = Visibility.Collapsed;
94+
var executeMenuItem = fileContextMenu.Items[2] as MenuItem;
95+
96+
if (executeMenuItem != null)
97+
{
98+
if (settingsRepository.ShowExecuteFileButton)
99+
executeMenuItem.Visibility = Visibility.Visible;
100+
else
101+
executeMenuItem.Visibility = Visibility.Collapsed;
102+
}
100103
}
101104
}
102105
}

0 commit comments

Comments
 (0)