static void Execute(Lazy <IUndoCommandService> undoCommandService, IAppService appService, DocumentTreeNodeData[] nodes) { if (!CanExecute(nodes)) { return; } var ownerNode = nodes[0]; if (!(ownerNode is TypeNode)) { ownerNode = (DocumentTreeNodeData)ownerNode.TreeNode.Parent.Data; } var typeNode = ownerNode as TypeNode; Debug.Assert(typeNode != null); if (typeNode == null) { throw new InvalidOperationException(); } var module = typeNode.GetModule(); Debug.Assert(module != null); if (module == null) { throw new InvalidOperationException(); } var options = EventDefOptions.Create("MyEvent", module.CorLibTypes.GetTypeRef("System", "EventHandler")); var data = new EventOptionsVM(options, module, appService.DecompilerService, typeNode.TypeDef); var win = new EventOptionsDlg(); win.Title = dnSpy_AsmEditor_Resources.CreateEventCommand2; win.DataContext = data; win.Owner = appService.MainWindow; if (win.ShowDialog() != true) { return; } var cmd = new CreateEventDefCommand(typeNode, data.CreateEventDefOptions()); undoCommandService.Value.Add(cmd); appService.DocumentTabService.FollowReference(cmd.eventNode); }
static void Execute(ILSpyTreeNode[] nodes) { if (!CanExecute(nodes)) { return; } var ownerNode = nodes[0]; if (!(ownerNode is TypeTreeNode)) { ownerNode = (ILSpyTreeNode)ownerNode.Parent; } var typeNode = ownerNode as TypeTreeNode; Debug.Assert(typeNode != null); if (typeNode == null) { throw new InvalidOperationException(); } var module = ILSpyTreeNode.GetModule(typeNode); Debug.Assert(module != null); if (module == null) { throw new InvalidOperationException(); } var options = EventDefOptions.Create("MyEvent", module.CorLibTypes.GetTypeRef("System", "EventHandler")); var data = new EventOptionsVM(options, module, MainWindow.Instance.CurrentLanguage, typeNode.TypeDef); var win = new EventOptionsDlg(); win.Title = CMD_NAME; win.DataContext = data; win.Owner = MainWindow.Instance; if (win.ShowDialog() != true) { return; } var cmd = new CreateEventDefCommand(typeNode, data.CreateEventDefOptions()); UndoCommandManager.Instance.Add(cmd); MainWindow.Instance.JumpToReference(cmd.eventNode); }
protected override void Execute(Context ctx) { CreateEventDefCommand.Execute(ctx.Nodes); }
protected override void ExecuteInternal(ILSpyTreeNode[] nodes) { CreateEventDefCommand.Execute(nodes); }
protected override bool CanExecuteInternal(ILSpyTreeNode[] nodes) { return(CreateEventDefCommand.CanExecute(nodes)); }
public override void Execute(CodeContext context) => CreateEventDefCommand.Execute(undoCommandService, appService, context.Nodes);
public override bool IsVisible(AsmEditorContext context) => CreateEventDefCommand.CanExecute(context.Nodes);
static void Execute(Lazy<IUndoCommandService> undoCommandService, IAppService appService, DocumentTreeNodeData[] nodes) { if (!CanExecute(nodes)) return; var ownerNode = nodes[0]; if (!(ownerNode is TypeNode)) ownerNode = (DocumentTreeNodeData)ownerNode.TreeNode.Parent.Data; var typeNode = ownerNode as TypeNode; Debug.Assert(typeNode != null); if (typeNode == null) throw new InvalidOperationException(); var module = typeNode.GetModule(); Debug.Assert(module != null); if (module == null) throw new InvalidOperationException(); var options = EventDefOptions.Create("MyEvent", module.CorLibTypes.GetTypeRef("System", "EventHandler")); var data = new EventOptionsVM(options, module, appService.DecompilerService, typeNode.TypeDef); var win = new EventOptionsDlg(); win.Title = dnSpy_AsmEditor_Resources.CreateEventCommand2; win.DataContext = data; win.Owner = appService.MainWindow; if (win.ShowDialog() != true) return; var cmd = new CreateEventDefCommand(typeNode, data.CreateEventDefOptions()); undoCommandService.Value.Add(cmd); appService.DocumentTabService.FollowReference(cmd.eventNode); }
public override void Execute(CodeContext context) => CreateEventDefCommand.Execute(undoCommandManager, appWindow, context.Nodes);
static void Execute(ILSpyTreeNode[] nodes) { if (!CanExecute(nodes)) return; var ownerNode = nodes[0]; if (!(ownerNode is TypeTreeNode)) ownerNode = (ILSpyTreeNode)ownerNode.Parent; var typeNode = ownerNode as TypeTreeNode; Debug.Assert(typeNode != null); if (typeNode == null) throw new InvalidOperationException(); var module = ILSpyTreeNode.GetModule(typeNode); Debug.Assert(module != null); if (module == null) throw new InvalidOperationException(); var options = EventDefOptions.Create("MyEvent", module.CorLibTypes.GetTypeRef("System", "EventHandler")); var data = new EventOptionsVM(options, module, MainWindow.Instance.CurrentLanguage, typeNode.TypeDef); var win = new EventOptionsDlg(); win.Title = CMD_NAME; win.DataContext = data; win.Owner = MainWindow.Instance; if (win.ShowDialog() != true) return; var cmd = new CreateEventDefCommand(typeNode, data.CreateEventDefOptions()); UndoCommandManager.Instance.Add(cmd); MainWindow.Instance.JumpToReference(cmd.eventNode); }
public override void Execute(AsmEditorContext context) { CreateEventDefCommand.Execute(undoCommandManager, appWindow, context.Nodes); }