Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Assembly node menu #1

Merged
6 commits merged into from
Feb 10, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ILSpy/ILSpy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
<Resource Include="Images\OK.png" />
<Resource Include="Images\ClearSearch.png" />
<Resource Include="Images\Search.png" />
<Resource Include="Images\Delete.png" />
<None Include="Properties\AssemblyInfo.template.cs" />
<Compile Include="Properties\WPFAssemblyInfo.cs" />
<Compile Include="MainWindow.xaml.cs">
Expand Down
Binary file added ILSpy/Images/Delete.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions ILSpy/Images/Images.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,7 @@ static BitmapImage LoadBitmap(string name)
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");
}
}
23 changes: 23 additions & 0 deletions ILSpy/TreeNodes/AssemblyTreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

using ICSharpCode.Decompiler;
using ICSharpCode.TreeView;
Expand All @@ -37,6 +38,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
/// </summary>
sealed class AssemblyTreeNode : ILSpyTreeNode<ILSpyTreeNodeBase>
{

readonly AssemblyList assemblyList;
readonly string fileName;
string shortName;
Expand Down Expand Up @@ -122,6 +124,18 @@ void OnAssemblyLoaded(Task<AssemblyDefinition> assemblyTask)
}
}

MenuItem CreateRemoveAssemblyItem()
{
MenuItem item = new MenuItem() {
Header = "Remove assembly",
Icon = new Image() { Source = Images.Delete }
};

item.Click += delegate { Delete(); };

return item;
}

sealed class MyAssemblyResolver : IAssemblyResolver
{
readonly AssemblyTreeNode parent;
Expand Down Expand Up @@ -156,6 +170,15 @@ public AssemblyDefinition Resolve(string fullName, ReaderParameters parameters)
}
}

public override ContextMenu GetContextMenu()
{
// specific to AssemblyTreeNode
var menu = new ContextMenu();
menu.Items.Add(CreateRemoveAssemblyItem());

return menu;
}

protected override void LoadChildren()
{
try {
Expand Down