You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.2 KiB

  1. // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
  2. // This code is distributed under MIT X11 license (for details please see \doc\license.txt)
  3. using System.Linq;
  4. using ICSharpCode.ILSpy;
  5. using ICSharpCode.ILSpy.TreeNodes;
  6. using Microsoft.Win32;
  7. namespace TestPlugin
  8. {
  9. [ExportContextMenuEntryAttribute(Header = "_Save Assembly")]
  10. public class SaveAssembly : IContextMenuEntry
  11. {
  12. public bool IsVisible(TextViewContext context)
  13. {
  14. return context.SelectedTreeNodes != null && context.SelectedTreeNodes.All(n => n is AssemblyTreeNode);
  15. }
  16. public bool IsEnabled(TextViewContext context)
  17. {
  18. return context.SelectedTreeNodes != null && context.SelectedTreeNodes.Length == 1;
  19. }
  20. public void Execute(TextViewContext context)
  21. {
  22. if (context.SelectedTreeNodes == null)
  23. return;
  24. AssemblyTreeNode node = (AssemblyTreeNode)context.SelectedTreeNodes[0];
  25. var asm = node.LoadedAssembly.GetPEFileOrNull();
  26. if (asm != null)
  27. {
  28. /*SaveFileDialog dlg = new SaveFileDialog();
  29. dlg.FileName = node.LoadedAssembly.FileName;
  30. dlg.Filter = "Assembly|*.dll;*.exe";
  31. if (dlg.ShowDialog(MainWindow.Instance) == true) {
  32. asm.MainModule.Write(dlg.FileName);
  33. }*/
  34. }
  35. }
  36. }
  37. }