From 7be3277a1b48b210da2ab544775132bb042c8c57 Mon Sep 17 00:00:00 2001 From: Eusebiu Marcu Date: Tue, 8 Feb 2011 11:23:46 +0200 Subject: [PATCH] Add "Remove assembly" item in AssemblyTreeNode context menu. --- ILSpy/ILSpy.csproj | 1 + ILSpy/Images/Delete.png | Bin 0 -> 575 bytes ILSpy/Images/Images.cs | 2 ++ ILSpy/TreeNodes/AssemblyTreeNode.cs | 29 ++++++++++++++++++++++++++++ 4 files changed, 32 insertions(+) create mode 100644 ILSpy/Images/Delete.png 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 0000000000000000000000000000000000000000..824d938dd67435984f22217cceab55e0c4438e15 GIT binary patch literal 575 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9EWV9eN~w38hu$dc~p z>&U>cv9IQL;A9|QA=x9ymw};5m4Tt5nStTwe<1ymfuYoZf#FpG1B2BJ1_tr`N%2SB z7#JA0db&7e#t z!M*2y`Qtr|CtQ~#G%zIn*qvE-NME__e*%vQ%aP+N8CAqH3*;hs6dDd3nSc4W?7o|v zd;Vvg_#od>pYLM)Q+?m_{EBq18;_&$6 z-g5A#yu$Uj@$wDtv>F(k9{ypz^~LbcgFn^_7#033)l2-RuJHG!*a}Ja9}Fx4Vf*XW z`Of$sHUFVK&;Mh>I~W*`w8&}i&yO?sQTD6huztd)hKKsz>dzi`xdP2He0zAyueRe= zJpUbkq^>yl^L+PjZn-|#KZ99vEsoCF$X>XBb&j~ L)z4*}Q$iB}*vs=~ literal 0 HcmV?d00001 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 {