public override void Execute(object parameter = null) { IList <DiagramView> topDiagramViews = Current.MainWindow.DiagramTabManager.GetTopDiagramViews(); /* there must be two diagrams, each with one selected component, both components must be of the * same type and they must not be linked already */ DiagramView diagramView1 = topDiagramViews[0]; DiagramView diagramView2 = topDiagramViews[1]; IEnumerable <Component> selectedComponents1 = diagramView1.GetSelectedComponents(); IEnumerable <Component> selectedComponents2 = diagramView2.GetSelectedComponents(); Component component1 = selectedComponents1.First(); Component component2 = selectedComponents2.First(); cmdCreateVersionLink cmdCreateVersionLink = new cmdCreateVersionLink(Current.Controller); cmdCreateVersionLink.Set(component1, component2); cmdCreateVersionLink.Execute(); Current.InvokeSelectionChanged(); }
public override void Execute(object parameter = null) { IList <DiagramView> topDiagramViews = Current.MainWindow.DiagramTabManager.GetTopDiagramViews(); /* there must be two diagrams, each with one selected component, both components must be of the * same type and they must not be linked already */ DiagramView diagramView1 = topDiagramViews[0]; DiagramView diagramView2 = topDiagramViews[1]; cmdCreateVersionLink cmdCreateVersionLinkS = new cmdCreateVersionLink(Current.Controller); cmdCreateVersionLinkS.Set(diagramView1.Diagram.Schema, diagramView2.Diagram.Schema); cmdCreateVersionLink cmdCreateVersionLinkD = new cmdCreateVersionLink(Current.Controller); cmdCreateVersionLinkD.Set(diagramView1.Diagram, diagramView2.Diagram); MacroCommand m = new MacroCommand(Current.Controller); m.Commands.Add(cmdCreateVersionLinkS); m.Commands.Add(cmdCreateVersionLinkD); m.CheckFirstOnlyInCanExecute = true; m.Execute(); Current.InvokeSelectionChanged(); }