/// <summary> /// This method executes the insert operation after the insertion position has been set /// </summary> public void Do() { //If the operation is not precanceled and the mouse is within the workspace (when the temporary layer is visible) if ((!this.opPrecanceled) && (this.tempLayer.Visible)) { //It is checked if the position is valid for insertion if (this.ValidateLocation()) { //It checks if the action needs Inicilización if (this.graphElement.NeedInit) { ActionForm actionForm = ActionFactory.GetActionForm(this.graphElement.Element); if (DialogResult.OK != actionForm.ShowDialog()) { this.Cancel(); return; } } //The GraphElement is added to the diagram layer, and to the logical diagram this.diagramLayer.AddElement(this.graphElement); this.diagram.AddElement(this.graphElement.Element); //The temporary layer is cleaned and hidden this.tempLayer.ClearAndHide(); //The diagram layer is updated this.diagramLayer.UpdateSurface(); //It is indicated that the diagram has changed if (this.DiagramChanged != null) { this.DiagramChanged(this, new EventArgs()); } //The operation is terminated if (this.OperationFinished != null) { this.OperationFinished(this, new OperationEventArgs(Operation.Insert)); } } else { //If the position is invalid, it is precanceled to show notice to the user this.PreCancel(); if (GraphSettings.Default.InsertWarning == true) { bool showAgain = true; MowayMessageBox.Show(InsertElementMessages.DRAG_OBJECT, InsertElementMessages.INSERT_ELEMENT, MessageBoxButtons.OK, MessageBoxIcon.Error, ref showAgain); GraphSettings.Default.InsertWarning = showAgain; GraphSettings.Default.Save(); } this.Cancel(); } } else { this.Cancel(); } }