diff --git a/ILSpy/Analyzers/AnalyzeContextMenuEntry.cs b/ILSpy/Analyzers/AnalyzeCommand.cs similarity index 73% rename from ILSpy/Analyzers/AnalyzeContextMenuEntry.cs rename to ILSpy/Analyzers/AnalyzeCommand.cs index d928c4197..e30506ee8 100644 --- a/ILSpy/Analyzers/AnalyzeContextMenuEntry.cs +++ b/ILSpy/Analyzers/AnalyzeCommand.cs @@ -18,14 +18,14 @@ using System; using System.Linq; +using System.Windows.Input; using ICSharpCode.Decompiler.TypeSystem; -using ICSharpCode.ILSpy.Analyzers.TreeNodes; using ICSharpCode.ILSpy.TreeNodes; namespace ICSharpCode.ILSpy.Analyzers { - [ExportContextMenuEntry(Header = "Analyze", Icon = "images/Search.png", Category = "Analyze", Order = 100)] - internal sealed class AnalyzeContextMenuEntry : IContextMenuEntry + [ExportContextMenuEntry(Header = "Analyze", Icon = "images/Search.png", Category = "Analyze", InputGestureText = "Ctrl+R", Order = 100)] + internal sealed class AnalyzeCommand : SimpleCommand, IContextMenuEntry { public bool IsVisible(TextViewContext context) { @@ -63,5 +63,27 @@ namespace ICSharpCode.ILSpy.Analyzers AnalyzerTreeView.Instance.Analyze(entity); } } + + public override bool CanExecute(object parameter) + { + if (AnalyzerTreeView.Instance.IsKeyboardFocusWithin) { + return AnalyzerTreeView.Instance.SelectedItems.OfType().All(n => n is IMemberTreeNode); + } else { + return MainWindow.Instance.SelectedNodes.All(n => n is IMemberTreeNode); + } + } + + public override void Execute(object parameter) + { + if (AnalyzerTreeView.Instance.IsKeyboardFocusWithin) { + foreach (IMemberTreeNode node in AnalyzerTreeView.Instance.SelectedItems.OfType().ToArray()) { + AnalyzerTreeView.Instance.Analyze(node.Member); + } + } else { + foreach (IMemberTreeNode node in MainWindow.Instance.SelectedNodes) { + AnalyzerTreeView.Instance.Analyze(node.Member); + } + } + } } } diff --git a/ILSpy/Commands/ILSpyCommands.cs b/ILSpy/Commands/ILSpyCommands.cs new file mode 100644 index 000000000..4a2d7e98f --- /dev/null +++ b/ILSpy/Commands/ILSpyCommands.cs @@ -0,0 +1,33 @@ +// Copyright (c) 2018 Siegfried Pammer +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; +using ICSharpCode.ILSpy.Analyzers; + +namespace ICSharpCode.ILSpy +{ + static class ILSpyCommands + { + public static readonly AnalyzeCommand Analyze = new AnalyzeCommand(); + } +} diff --git a/ILSpy/ContextMenuEntry.cs b/ILSpy/ContextMenuEntry.cs index 91a22eef5..0bde81f81 100644 --- a/ILSpy/ContextMenuEntry.cs +++ b/ILSpy/ContextMenuEntry.cs @@ -98,7 +98,8 @@ namespace ICSharpCode.ILSpy string Icon { get; } string Header { get; } string Category { get; } - + string InputGestureText { get; } + double Order { get; } } @@ -116,6 +117,7 @@ namespace ICSharpCode.ILSpy public string Icon { get; set; } public string Header { get; set; } public string Category { get; set; } + public string InputGestureText { get; set; } public double Order { get; set; } } @@ -218,6 +220,7 @@ namespace ICSharpCode.ILSpy } MenuItem menuItem = new MenuItem(); menuItem.Header = entryPair.Metadata.Header; + menuItem.InputGestureText = entryPair.Metadata.InputGestureText; if (!string.IsNullOrEmpty(entryPair.Metadata.Icon)) { menuItem.Icon = new Image { Width = 16, diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj index ffb24b6f2..ef7211105 100644 --- a/ILSpy/ILSpy.csproj +++ b/ILSpy/ILSpy.csproj @@ -105,6 +105,7 @@ + @@ -212,7 +213,7 @@ - + diff --git a/ILSpy/MainWindow.xaml b/ILSpy/MainWindow.xaml index 9f958b4b9..100b259ba 100644 --- a/ILSpy/MainWindow.xaml +++ b/ILSpy/MainWindow.xaml @@ -39,6 +39,9 @@ Command="Search" Executed="SearchCommandExecuted" /> + + +