Ejemplo n.º 1
0
        /// <summary>
        /// Execution of the operation
        /// </summary>
        public void Do()
        {
            GraphElement initialElement = this.initialConnector.Parent;
            GraphElement finalElement   = this.finalConnector.Parent;

            graphArrow = new GraphArrow(initialConnector, finalConnector, this.diagramLayer.GetGridPoints());
            if (initialElement is GraphConditional)
            {
                if ((this.conditionalOut == ConditionalOut.True) && (((GraphConditional)initialElement).NextTrue != null))
                {
                    if (DialogResult.Yes == MowayMessageBox.Show(InsertArrowMessages.REPLACE_TRUE + InsertArrowMessages.CONTINUE, InsertArrowMessages.INSERT_ARROW, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                    {
                        this.graphArrowToDelete = (GraphArrow)((GraphConditional)initialElement).NextTrue;
                        GraphDiagram.DeleteElement(this.diagramLayer, this.diagram, this.graphArrowToDelete);
                    }
                    else
                    {
                        this.Cancel();
                        return;
                    }
                }
                else if ((this.conditionalOut == ConditionalOut.False) && (((GraphConditional)initialElement).NextFalse != null))
                {
                    if (DialogResult.Yes == MowayMessageBox.Show(InsertArrowMessages.REPLACE_FALSE + InsertArrowMessages.CONTINUE, InsertArrowMessages.INSERT_ARROW, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                    {
                        this.graphArrowToDelete = (GraphArrow)((GraphConditional)initialElement).NextFalse;
                        GraphDiagram.DeleteElement(this.diagramLayer, this.diagram, this.graphArrowToDelete);
                    }
                    else
                    {
                        this.Cancel();
                        return;
                    }
                }
                ((GraphConditional)initialElement).AddNext(initialConnector, graphArrow, this.conditionalOut);
            }
            else
            {
                if (initialElement.Next != null)
                {
                    if (DialogResult.Yes == MowayMessageBox.Show(InsertArrowMessages.REPLACE_OUT + InsertArrowMessages.CONTINUE, InsertArrowMessages.INSERT_ARROW, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                    {
                        this.graphArrowToDelete = (GraphArrow)initialElement.Next;
                        GraphDiagram.DeleteElement(this.diagramLayer, this.diagram, this.graphArrowToDelete);
                    }
                    else
                    {
                        this.Cancel();
                        return;
                    }
                }
                initialElement.AddNext(initialConnector, graphArrow);
            }
            finalElement.AddPrevious(finalConnector, graphArrow);
            this.diagramLayer.AddElement(graphArrow);
            //Elements in the context of the operation are deleted
            foreach (GraphElement element in this.tempLayer.Elements)
            {
                element.DisableConnectors();
            }
            this.tempLayer.ClearAndHide();
            this.diagramLayer.UpdateSurface();
            if (this.DiagramChanged != null)
            {
                this.DiagramChanged(this, new EventArgs());
            }
            if (this.OperationFinished != null)
            {
                this.OperationFinished(this, new OperationEventArgs(Operation.Connect));
            }
        }
Ejemplo n.º 2
0
        public void Do()
        {
            GraphElement initialElement = initialConnector.Parent;
            GraphElement finalElement   = finalConnector.Parent;

            this.graphArrow = new GraphArrow(initialConnector, finalConnector, gridStatus);
            if (initialElement is GraphConditional)
            {
                if ((conditionalOut == ConditionalOut.True) && (((GraphConditional)initialElement).NextTrue != null))
                {
                    if (DialogResult.Yes == MowayMessageBox.Show(InsertArrowMessages.REPLACE_TRUE + "\r\n" + InsertArrowMessages.CONTINUE, InsertArrowMessages.INSERT_ARROW, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                    {
                        this.graphArrowToDelete = (GraphArrow)((GraphConditional)initialElement).NextTrue;
                        GraphDiagram.DeleteElement(diagramLayer, diagram, this.graphArrowToDelete);
                    }
                    else
                    {
                        this.Cancel();
                        return;
                    }
                }
                else if ((conditionalOut == ConditionalOut.False) && (((GraphConditional)initialElement).NextFalse != null))
                {
                    if (DialogResult.Yes == MowayMessageBox.Show(InsertArrowMessages.REPLACE_FALSE + "\r\n" + InsertArrowMessages.CONTINUE, InsertArrowMessages.INSERT_ARROW, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                    {
                        this.graphArrowToDelete = (GraphArrow)((GraphConditional)initialElement).NextFalse;
                        GraphDiagram.DeleteElement(diagramLayer, diagram, this.graphArrowToDelete);
                    }
                    else
                    {
                        this.Cancel();
                        return;
                    }
                }
                ((GraphConditional)initialElement).AddNext(initialConnector, this.graphArrow, conditionalOut);
            }
            else
            {
                if (initialElement.Next != null)
                {
                    if (DialogResult.Yes == MowayMessageBox.Show(InsertArrowMessages.REPLACE_OUT + "\r\n" + InsertArrowMessages.CONTINUE, InsertArrowMessages.INSERT_ARROW, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                    {
                        this.graphArrowToDelete = (GraphArrow)initialElement.Next;
                        GraphDiagram.DeleteElement(diagramLayer, diagram, this.graphArrowToDelete);
                    }
                    else
                    {
                        this.Cancel();
                        return;
                    }
                }
                initialElement.AddNext(initialConnector, this.graphArrow);
            }
            finalElement.AddPrevious(finalConnector, this.graphArrow);
            diagramLayer.AddElement(this.graphArrow);
            this.diagram.AddElement(this.graphArrow.Element);
            //Elements in the context of the operation are deleted
            this.PreCancel();
            this.diagramLayer.UpdateSurface();
            if (this.DiagramChanged != null)
            {
                this.DiagramChanged(this, new EventArgs());
            }
            if (this.OperationFinished != null)
            {
                this.OperationFinished(this, new OperationEventArgs(Operation.InsertArrow));
            }
        }