public InsertArrow(Diagram diagram, GraphLayer diagramLayer, GraphLayer tempLayer, Point initialPoint)
        {
            this.diagram      = diagram;
            this.diagramLayer = diagramLayer;
            this.tempLayer    = tempLayer;
            MenuItem miCancel = new MenuItem("Cancelar");

            miCancel.Click += new EventHandler(MiCancel_Click);
            this.menu       = new ContextMenu(new MenuItem[] { miCancel });
            //You get the starting element and the initial connector
            this.initialConnector = this.tempLayer.Elements[0].GetConnector(initialPoint);
            //Only the connector selected for that element is enabled
            this.initialConnector.Parent.EnableConnector(this.initialConnector);
            if (this.initialConnector.Parent is GraphConditional)
            {
                this.conditionalOut = ((GraphConditional)this.initialConnector.Parent).GetPredefOut(this.initialConnector);
            }
            //Add the temporary arrow
            this.tempLayer.Add(this.tempGraphArrow);
            this.tempLayer.Visible = true;
            this.tempLayer.UpdateSurface();

            //You get the obstacles to avoid by the arrow of the diagram layer
            this.gridStatus = this.diagramLayer.GetGridPoints();
        }
Example #2
0
        /// <summary>
        /// Press one of the mouse buttons (at the moment of pressing)
        /// </summary>
        /// <param name="e">Mouse Properties</param>
        public void MouseDown(MouseEventArgs e)
        {
            //If the initial connector is empty...
            if (this.initialConnector == null)
            {
                //You look for if you clicked on a different element of an arrow or a finish
                GraphElement element = GraphDiagram.GetElement(this.diagramLayer, e.Location);
                if ((element != null) && !((element is GraphArrow) || (element is GraphFinish)))
                {
                    Connector connector = element.GetConnector(e.Location);
                    if (connector != null)
                    {
                        this.initialConnector = connector;
                        this.initFixed        = true;
                    }
                    else
                    {
                        this.initialConnector = this.GetConnector(element, e.Location);
                    }
                    if (this.initialConnector.Parent is GraphConditional)
                    {
                        this.conditionalOut = ((GraphConditional)this.initialConnector.Parent).GetPredefOut(this.initialConnector);
                    }
                    element.DisableConnectors();
                    element.EnableConnector(this.initialConnector);

                    this.tempGraphArrow.UpdateArrow(this.initialConnector.AbsCenter, e.Location);
                    this.tempLayer.UpdateSurface();
                }
            }
        }
 public void Do()
 {
     //If you are modifying the next of an item...
     if (this.nextEnable)
     {
         if (this.presentConnector.Parent is GraphConditional)
         {
             this.conditionalOut = ((GraphConditional)this.presentConnector.Parent).GetPredefOut(this.presentConnector);
             if ((conditionalOut == ConditionalOut.True) && (((GraphConditional)this.presentConnector.Parent).NextTrue != null))
             {
                 if (DialogResult.Yes != MowayMessageBox.Show(InsertArrowMessages.REPLACE_TRUE + "\r\n" + InsertArrowMessages.CONTINUE, InsertArrowMessages.INSERT_ARROW, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                 {
                     this.Cancel();
                     return;
                 }
                 else if ((conditionalOut == ConditionalOut.False) && (((GraphConditional)this.presentConnector.Parent).NextFalse != null))
                 {
                     if (DialogResult.Yes != MowayMessageBox.Show(InsertArrowMessages.REPLACE_FALSE + "\r\n" + InsertArrowMessages.CONTINUE, InsertArrowMessages.INSERT_ARROW, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                     {
                         this.Cancel();
                         return;
                     }
                 }
             }
         }
         GraphDiagram.DeleteElement(diagramLayer, diagram, this.graphArrowToDelete);
         this.graphArrow = GraphDiagram.InsertArrow(this.diagram, this.diagramLayer, this.presentConnector, this.fixedConnector, this.conditionalOut, this.gridStatus);
     }
     else        //If you are modifying an item's prev
     {
         if (fixedConnector.Parent is GraphConditional)
         {
             if (((GraphConditional)fixedConnector.Parent).NextTrue == this.graphArrowToDelete)
             {
                 this.conditionalOut = ConditionalOut.True;
             }
             else
             {
                 this.conditionalOut = ConditionalOut.False;
             }
         }
         GraphDiagram.DeleteElement(this.diagramLayer, this.diagram, this.graphArrowToDelete);
         this.graphArrow = GraphDiagram.InsertArrow(this.diagram, this.diagramLayer, this.fixedConnector, this.presentConnector, this.conditionalOut, this.gridStatus);
     }
     foreach (GraphElement element in this.tempLayer.Elements)
     {
         element.DisableConnectors();
     }
     this.tempLayer.ClearAndHide();
     this.diagramLayer.UpdateSurface();
     if (this.OperationFinished != null)
     {
         this.OperationFinished(this, new OperationEventArgs(Operation.Reconnect));
     }
 }
 /// <summary>
 /// Assign a following element
 /// </summary>
 /// <param name="element">Element to assign</param>
 /// <param name="nextOut">Output to which to assign it (true or false)</param>
 public void AddNext(Element element, ConditionalOut nextOut)
 {
     if (nextOut == ConditionalOut.True)
     {
         this.AddNextTrue(element);
     }
     else
     {
         this.AddNextFalse(element);
     }
 }
        public void AddNext(GraphSide side, GraphArrow arrow, ConditionalOut outLine)
        {
            Connector connector = (Connector)this.connectors[(int)side];

            if (outLine == ConditionalOut.True)
            {
                this.AddNextTrue(connector, arrow);
            }
            else
            {
                this.AddNextFalse(connector, arrow);
            }
            ((Conditional)this.element).AddNext(arrow.Element, outLine);
            arrow.Element.AddPrevious(this.element);
        }
 public void AddNext(Connector conector, GraphArrow arrow, ConditionalOut outLine)
 {
     if (!this.connectors.Contains(conector))
     {
         throw new GraphException("This element don't have the conector");
     }
     if (outLine == ConditionalOut.True)
     {
         this.AddNextTrue(conector, arrow);
     }
     else
     {
         this.AddNextFalse(conector, arrow);
     }
     ((Conditional)this.element).AddNext(arrow.Element, outLine);
     arrow.Element.AddPrevious(this.element);
 }
Example #7
0
        /// <summary>
        /// Mouse movement over the GraphDrawing
        /// </summary>
        /// <param name="e">Mouse Properties</param>
        public void MouseMove(MouseEventArgs e)
        {
            if (this.initialConnector == null)
            {
                GraphElement element = GraphDiagram.GetElement(this.diagramLayer, e.Location);
                if (element != null)
                {
                    if (element != this.presentElement)
                    {
                        if (this.presentElement != null)
                        {
                            this.presentElement.DisableConnectors();
                            this.tempLayer.RemoveElement(this.presentElement);
                            this.presentElement = null;
                        }
                        if (element.EnableNextConnectors())
                        {
                            this.presentElement = element;
                            this.tempLayer.Add(this.presentElement);
                            //The cursor is updated to default
                            if ((Cursor.Current != Cursors.Hand) && (this.CursorChanged != null))
                            {
                                this.CursorChanged(this, new CursorEventArgs(Cursors.Hand));
                            }
                        }
                        else
                        //The cursor is updated to default
                        if ((Cursor.Current != Cursors.Default) && (this.CursorChanged != null))
                        {
                            this.CursorChanged(this, new CursorEventArgs(Cursors.Default));
                        }

                        this.tempLayer.UpdateSurface();
                    }
                }
                else if (this.presentElement != null)
                {
                    this.presentElement.DisableConnectors();
                    this.tempLayer.RemoveElement(this.presentElement);
                    this.presentElement = null;
                    this.tempLayer.UpdateSurface();
                    //The cursor is updated to default
                    if ((Cursor.Current != Cursors.Default) && (this.CursorChanged != null))
                    {
                        this.CursorChanged(this, new CursorEventArgs(Cursors.Default));
                    }
                }
            }
            else
            {
                //The initial connector is updated if necessary
                if (!this.initFixed)
                {
                    Connector connector = this.GetConnector(this.initialConnector.Parent, e.Location);
                    if (this.initialConnector != connector)
                    {
                        this.initialConnector = connector;
                        this.initialConnector.Parent.DisableConnectors();
                        this.initialConnector.Parent.EnableConnector(this.initialConnector);
                        if (this.initialConnector.Parent is GraphConditional)
                        {
                            this.conditionalOut = ((GraphConditional)this.initialConnector.Parent).GetPredefOut(this.initialConnector);
                        }
                    }
                }
                //Looking for the final element
                GraphElement element = GraphDiagram.GetElement(this.diagramLayer, e.Location);
                if (element != null)
                {
                    if (this.presentElement != element)
                    {
                        if (this.presentElement != null)
                        {
                            this.presentElement.DisableConnectors();
                            if (this.presentElement == this.initialConnector.Parent)
                            {
                                this.presentElement.EnableConnector(this.initialConnector);
                            }
                            else
                            {
                                this.tempLayer.RemoveElement(this.presentElement);
                            }
                            this.presentElement = null;
                        }
                        if (this.initialConnector.Parent == element)
                        {
                            if ((this.initFixed) && (element.EnablePrevConnectors()))
                            {
                                this.presentElement = element;
                                this.tempLayer.Add(this.presentElement);
                            }
                        }
                        else if (element.EnablePrevConnectors())
                        {
                            this.presentElement = element;
                            this.tempLayer.Add(this.presentElement);
                        }
                    }
                    if (this.presentElement == null)
                    {
                        this.presentConnector = null;
                        this.tempGraphArrow.UpdateArrow(this.initialConnector.AbsCenter, e.Location);
                    }
                    else
                    {
                        Connector connector = this.presentElement.GetConnector(e.Location);
                        if (connector == null)
                        {
                            connector = this.GetPrevConnector(this.presentElement, e.Location);
                            if (connector != this.presentConnector)
                            {
                                this.presentConnector = connector;
                                this.tempGraphArrow.UpdateArrow(this.initialConnector.AbsCenter, this.presentConnector.AbsCenter);
                            }
                        }
                        else if (this.presentConnector != connector)
                        {
                            this.presentConnector = connector;
                            this.tempGraphArrow.UpdateArrow(this.initialConnector.AbsCenter, this.presentConnector.AbsCenter);
                        }
                    }
                }
                else
                {
                    if (this.presentElement != null)
                    {
                        this.presentElement.DisableConnectors();
                        if (this.presentElement == this.initialConnector.Parent)
                        {
                            this.presentElement.EnableConnector(this.initialConnector);
                        }
                        else
                        {
                            this.tempLayer.RemoveElement(this.presentElement);
                        }
                        this.presentElement = null;
                    }
                    this.tempGraphArrow.UpdateArrow(this.initialConnector.AbsCenter, e.Location);
                }
            }
            this.tempLayer.UpdateSurface();
        }