diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj index 61843f00b..90c83b900 100644 --- a/ILSpy/ILSpy.csproj +++ b/ILSpy/ILSpy.csproj @@ -109,6 +109,7 @@ + diff --git a/ILSpy/Images/Delete.png b/ILSpy/Images/Delete.png new file mode 100644 index 000000000..824d938dd Binary files /dev/null and b/ILSpy/Images/Delete.png differ diff --git a/ILSpy/Images/Images.cs b/ILSpy/Images/Images.cs index 684bbde32..6b3d33414 100644 --- a/ILSpy/Images/Images.cs +++ b/ILSpy/Images/Images.cs @@ -65,5 +65,7 @@ namespace ICSharpCode.ILSpy public static readonly BitmapImage ProtectedEnum = LoadBitmap("ProtectedEnum"); public static readonly BitmapImage ProtectedInterface = LoadBitmap("ProtectedInterface"); public static readonly BitmapImage ProtectedStruct = LoadBitmap("ProtectedStruct"); + + public static readonly BitmapImage Delete = LoadBitmap("Delete"); } } diff --git a/ILSpy/TreeNodes/AssemblyTreeNode.cs b/ILSpy/TreeNodes/AssemblyTreeNode.cs index 12de86963..7ad607f8d 100644 --- a/ILSpy/TreeNodes/AssemblyTreeNode.cs +++ b/ILSpy/TreeNodes/AssemblyTreeNode.cs @@ -24,6 +24,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using System.Windows; +using System.Windows.Controls; using ICSharpCode.Decompiler; using ICSharpCode.TreeView; @@ -37,6 +38,7 @@ namespace ICSharpCode.ILSpy.TreeNodes /// sealed class AssemblyTreeNode : ILSpyTreeNode { + readonly AssemblyList assemblyList; readonly string fileName; string shortName; @@ -44,6 +46,9 @@ namespace ICSharpCode.ILSpy.TreeNodes readonly List classes = new List(); readonly Dictionary namespaces = new Dictionary(); + // UI + ContextMenu menu; + public AssemblyTreeNode(string fileName, AssemblyList assemblyList) { if (fileName == null) @@ -57,6 +62,8 @@ namespace ICSharpCode.ILSpy.TreeNodes assemblyTask.ContinueWith(OnAssemblyLoaded, TaskScheduler.FromCurrentSynchronizationContext()); this.LazyLoading = true; + + CreateRemoveItemContextMenu(); } public string FileName { @@ -122,6 +129,20 @@ namespace ICSharpCode.ILSpy.TreeNodes } } + void CreateRemoveItemContextMenu() + { + var menu = GetContextMenu(); + + MenuItem item = new MenuItem() { + Header = "Remove assembly", + Icon = new Image() { Source = Images.Delete } + }; + + item.Click += delegate { Delete(); }; + + menu.Items.Add(item); + } + sealed class MyAssemblyResolver : IAssemblyResolver { readonly AssemblyTreeNode parent; @@ -156,6 +177,14 @@ namespace ICSharpCode.ILSpy.TreeNodes } } + public override ContextMenu GetContextMenu() + { + if (menu != null) + return menu; + + return (menu = new ContextMenu()); + } + protected override void LoadChildren() { try {