/// <summary> /// This method executes the insert operation after the insertion position has been set /// </summary> public void Do() { if (!GraphDiagram.ValidateCopy(this.selectLayer.Elements)) { MowayMessageBox.Show(CutMessages.CUT_START, CutMessages.CUT, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Cancel(); return; } //The items to be copied are loaded List <GraphElement> elementsToCut = GraphDiagram.GetElementsToCopy(this.selectLayer); List <GraphElement> cloneElements = GraphDiagram.CloneElements(elementsToCut); GraphManager.Clipboard.SetElements(cloneElements); this.elementsToDelete = GraphDiagram.GetElementsToDelete(this.selectLayer); GraphDiagram.DeleteElements(this.diagramLayer, this.diagram, this.elementsToDelete); //Cleans and hides the selection layer this.selectLayer.ClearAndHide(); //Updates the diagram layer this.diagramLayer.UpdateSurface(); if (this.DiagramChanged != null) { this.DiagramChanged(this, new EventArgs()); } if (this.ElementSelectedChanged != null) { this.ElementSelectedChanged(this, new EventArgs()); } //Launch Event of operation completed if (this.OperationFinished != null) { this.OperationFinished(this, new OperationEventArgs(Operation.Cut)); } }
/// <summary> /// Insert Operation Builder /// </summary> /// <param name="diagram">Logical diagram del GraphDrawing</param> /// <param name="diagramLayer">GraphDrawing diagram Layer</param> /// <param name="tempLayer">Temporal layer of the GraphDrawing</param> /// <param name="element">Elements to insert</param> public Paste(Diagram diagram, GraphLayer diagramLayer, GraphLayer tempLayer) { this.diagram = diagram; this.diagramLayer = diagramLayer; this.tempLayer = tempLayer; this.tempLayer.Visible = true; this.displacement = new Point(0, 0); //You get the items to paste this.graphElements.AddRange(GraphDiagram.CloneElements(GraphManager.Clipboard.GetElements())); //Add the item to the temporary layer from the Clipboard this.tempLayer.AddElements(this.graphElements); foreach (GraphElement element in this.tempLayer.Elements) { if (!(element is GraphArrow)) { this.displacement = element.Center; break; } } this.tempLayer.UpdateSurface(); //The initial positions of the items to be moved are saved foreach (GraphElement element in this.tempLayer.Elements) { this.initLocations.Add(element, new Point(element.Center.X - this.displacement.X, element.Center.Y - displacement.Y)); } MenuItem miCancel = new MenuItem(PasteMessages.CANCEL); miCancel.Click += new EventHandler(MiCancel_Click); this.menu = new ContextMenu(new MenuItem[] { miCancel }); }
/// <summary> /// This method executes the insert operation after the insertion position has been set /// </summary> public void Do() { if (!GraphDiagram.ValidateCopy(this.selectLayer.Elements)) { MowayMessageBox.Show(CopyMessages.COPY_START, CopyMessages.COPY, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Cancel(); return; } //The items to be copied are loaded List <GraphElement> elementsToCopy = GraphDiagram.GetElementsToCopy(this.selectLayer); List <GraphElement> cloneElements = GraphDiagram.CloneElements(elementsToCopy); GraphManager.Clipboard.SetElements(cloneElements); //Launch Event of operation completed if (this.OperationFinished != null) { this.OperationFinished(this, new OperationEventArgs(Operation.Copy)); } }