Browse Source

Add "Remove assembly" item in AssemblyTreeNode context menu.

pull/1/head
Eusebiu Marcu 15 years ago
parent
commit
7be3277a1b
  1. 1
      ILSpy/ILSpy.csproj
  2. BIN
      ILSpy/Images/Delete.png
  3. 2
      ILSpy/Images/Images.cs
  4. 29
      ILSpy/TreeNodes/AssemblyTreeNode.cs

1
ILSpy/ILSpy.csproj

@ -109,6 +109,7 @@
<Resource Include="Images\OK.png" /> <Resource Include="Images\OK.png" />
<Resource Include="Images\ClearSearch.png" /> <Resource Include="Images\ClearSearch.png" />
<Resource Include="Images\Search.png" /> <Resource Include="Images\Search.png" />
<Resource Include="Images\Delete.png" />
<None Include="Properties\AssemblyInfo.template.cs" /> <None Include="Properties\AssemblyInfo.template.cs" />
<Compile Include="Properties\WPFAssemblyInfo.cs" /> <Compile Include="Properties\WPFAssemblyInfo.cs" />
<Compile Include="MainWindow.xaml.cs"> <Compile Include="MainWindow.xaml.cs">

BIN
ILSpy/Images/Delete.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 B

2
ILSpy/Images/Images.cs

@ -65,5 +65,7 @@ namespace ICSharpCode.ILSpy
public static readonly BitmapImage ProtectedEnum = LoadBitmap("ProtectedEnum"); public static readonly BitmapImage ProtectedEnum = LoadBitmap("ProtectedEnum");
public static readonly BitmapImage ProtectedInterface = LoadBitmap("ProtectedInterface"); public static readonly BitmapImage ProtectedInterface = LoadBitmap("ProtectedInterface");
public static readonly BitmapImage ProtectedStruct = LoadBitmap("ProtectedStruct"); public static readonly BitmapImage ProtectedStruct = LoadBitmap("ProtectedStruct");
public static readonly BitmapImage Delete = LoadBitmap("Delete");
} }
} }

29
ILSpy/TreeNodes/AssemblyTreeNode.cs

@ -24,6 +24,7 @@ using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using ICSharpCode.Decompiler; using ICSharpCode.Decompiler;
using ICSharpCode.TreeView; using ICSharpCode.TreeView;
@ -37,6 +38,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
/// </summary> /// </summary>
sealed class AssemblyTreeNode : ILSpyTreeNode<ILSpyTreeNodeBase> sealed class AssemblyTreeNode : ILSpyTreeNode<ILSpyTreeNodeBase>
{ {
readonly AssemblyList assemblyList; readonly AssemblyList assemblyList;
readonly string fileName; readonly string fileName;
string shortName; string shortName;
@ -44,6 +46,9 @@ namespace ICSharpCode.ILSpy.TreeNodes
readonly List<TypeTreeNode> classes = new List<TypeTreeNode>(); readonly List<TypeTreeNode> classes = new List<TypeTreeNode>();
readonly Dictionary<string, NamespaceTreeNode> namespaces = new Dictionary<string, NamespaceTreeNode>(); readonly Dictionary<string, NamespaceTreeNode> namespaces = new Dictionary<string, NamespaceTreeNode>();
// UI
ContextMenu menu;
public AssemblyTreeNode(string fileName, AssemblyList assemblyList) public AssemblyTreeNode(string fileName, AssemblyList assemblyList)
{ {
if (fileName == null) if (fileName == null)
@ -57,6 +62,8 @@ namespace ICSharpCode.ILSpy.TreeNodes
assemblyTask.ContinueWith(OnAssemblyLoaded, TaskScheduler.FromCurrentSynchronizationContext()); assemblyTask.ContinueWith(OnAssemblyLoaded, TaskScheduler.FromCurrentSynchronizationContext());
this.LazyLoading = true; this.LazyLoading = true;
CreateRemoveItemContextMenu();
} }
public string FileName { 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 sealed class MyAssemblyResolver : IAssemblyResolver
{ {
readonly AssemblyTreeNode parent; 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() protected override void LoadChildren()
{ {
try { try {

Loading…
Cancel
Save