Exemplo n.º 1
0
 public void CreateLine(NodeBase fromNode, NodeBase toNode)
 {
     if (fromNode.CanConnectLineAsParent() && toNode.CanConnectLineAsChild())
     {
         fromNode.AddChildNode(toNode);
         toNode.ParentNode = fromNode;
         ConnectLine line = new ConnectLine(fromNode, toNode, DestoryLine);
         _lineList.Add(line);
     }
 }
Exemplo n.º 2
0
    public void ReloadLine(NodeBase fromNode, NodeBase toNode)
    {
        if (toNode.Name == "根节点" ||
            (fromNode is ActionNode && toNode is ActionNode))
        {
            return;
        }
        ConnectLine line = new ConnectLine(fromNode, toNode, DestoryLine);

        _lineList.Add(line);
    }
Exemplo n.º 3
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "ConnectLine")
     {
         ConnectLine otherLine = collision.GetComponent <ConnectLine>();
         if (otherLine)
         {
             //交点を求める.
             Vector2 intersection;
             if (Math2d.LineSegmentsIntersection(this.point1.position, this.point2.position, otherLine.point1.position, otherLine.point2.position, out intersection))
             {
                 Instantiate(this.CrossedEffect, intersection, Quaternion.identity);
             }
         }
     }
 }
Exemplo n.º 4
0
        public void OnMouseUp(MouseEventArgs e)
        {
            this.tempPath.Reset();
            if (((this.graph != null) && (((SvgElement)this.graph).ParentNode != null)) && ((e.Button == MouseButtons.Left) && this.mousedown))
            {
                this.mousedown = false;
                if ((this.operate == PolyOperate.MovePoint) || (this.operate == PolyOperate.MovePath))
                {
                    PointF tf1     = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float)e.X, (float)e.Y));
                    SizeF  ef1     = this.mouseAreaControl.PicturePanel.GridSize;
                    float  single1 = ef1.Height;
                    float  single2 = ef1.Width;
                    if (this.mouseAreaControl.PicturePanel.SnapToGrid)
                    {
                        int num1 = (int)((tf1.X + (single2 / 2f)) / single2);
                        int num2 = (int)((tf1.Y + (single1 / 2f)) / single1);
                        tf1 = (PointF) new Point((int)(num1 * single2), (int)(num2 * single1));
                    }
                    tf1 = this.mouseAreaControl.PicturePanel.PointToSystem(tf1);
                    switch (this.operate)
                    {
                    case PolyOperate.MovePath:
                    {
                        PointF tf2     = this.mouseAreaControl.PicturePanel.PointToSystem(this.startpoint);
                        Matrix matrix1 = new Matrix();
                        matrix1.Translate(tf1.X - tf2.X, tf1.Y - tf2.Y);
                        matrix1.TransformPoints(this.points);
                        break;
                    }

                    case PolyOperate.MovePoint:
                    {
                        if ((this.moveindex >= 0) && (this.moveindex < this.points.Length))
                        {
                            this.points[this.moveindex] = tf1;

                            if (this.graph is ConnectLine)
                            {                                    //连接线
                                bool        flag2  = false;
                                ConnectLine cebfd1 = this.graph as ConnectLine;

                                if (this.connectGraph == null)
                                {
                                    if (this.moveindex == 0)
                                    {
                                        string text3 = cebfd1.GetAttribute("start");
                                        if ((text3 != null) && (text3.Length > 0))
                                        {
                                            if (cebfd1.StartGraph != null)
                                            {
                                                cebfd1.StartGraph.ConnectLines.Remove(cebfd1);
                                            }
                                            AttributeFunc.SetAttributeValue(cebfd1, "start", string.Empty);

                                            flag2 = true;
                                        }
                                        float single11 = tf1.X;
                                        if (cebfd1.GetAttribute("x1") != single11.ToString())
                                        {
                                            AttributeFunc.SetAttributeValue(cebfd1, "x1", single11.ToString());
                                            flag2 = true;
                                        }
                                        single11 = tf1.Y;
                                        if (cebfd1.GetAttribute("y1") != single11.ToString())
                                        {
                                            AttributeFunc.SetAttributeValue(cebfd1, "y1", single11.ToString());
                                            flag2 = true;
                                        }
                                    }
                                    else
                                    {
                                        string text2 = cebfd1.GetAttribute("end");
                                        if ((text2 != null) && (text2.Length > 0))
                                        {
                                            if (cebfd1.EndGraph != null)
                                            {
                                                cebfd1.EndGraph.ConnectLines.Remove(cebfd1);
                                            }
                                            AttributeFunc.SetAttributeValue(cebfd1, "end", string.Empty);

                                            flag2 = true;
                                        }
                                        float single12 = tf1.X;
                                        if (cebfd1.GetAttribute("x2") != single12.ToString())
                                        {
                                            AttributeFunc.SetAttributeValue(cebfd1, "x2", single12.ToString());
                                            flag2 = true;
                                        }
                                        single12 = tf1.Y;
                                        if (cebfd1.GetAttribute("y2") != single12.ToString())
                                        {
                                            AttributeFunc.SetAttributeValue(cebfd1, "y2", single12.ToString());
                                            flag2 = true;
                                        }
                                    }
                                }
                                else
                                {
                                    SvgElement ab1   = this.connectGraph as SvgElement;
                                    string     text3 = ab1.GetAttribute("id");
                                    if ((text3 == null) || (text3.Trim().Length == 0))
                                    {
                                        text3 = CodeFunc.CreateString(this.mouseAreaControl.SVGDocument, ab1.LocalName);
                                        AttributeFunc.SetAttributeValue(ab1, "id", text3);
                                    }
                                    if (this.moveindex == 0)
                                    {
                                        text3 = "#" + text3;
                                        using (Matrix matrix1 = ((IGraph)ab1).GraphTransform.Matrix.Clone())
                                        {
                                            PointF[] tfArray3 = ((IGraph)ab1).ConnectPoints.Clone() as PointF[];
                                            matrix1.TransformPoints(tfArray3);
                                            int num1 = Array.IndexOf(tfArray3, this.connectPoint);
                                            if ((num1 >= 0) && (num1 < tfArray3.Length))
                                            {
                                                text3 = text3 + "." + num1.ToString();
                                            }
                                            tfArray3 = null;
                                        }
                                        if (text3 != cebfd1.GetAttribute("start"))
                                        {
                                            IGraph oldgraph = cebfd1.StartGraph;
                                            if (oldgraph != null)
                                            {
                                                oldgraph.ConnectLines.Remove(cebfd1);
                                            }
                                            AttributeFunc.SetAttributeValue(cebfd1, "start", text3);
                                            flag2 = true;
                                        }
                                    }
                                    else
                                    {
                                        text3 = "#" + text3;
                                        using (Matrix matrix3 = ((IGraph)ab1).GraphTransform.Matrix.Clone())
                                        {
                                            PointF[] tfArray3 = ((IGraph)ab1).ConnectPoints.Clone() as PointF[];
                                            matrix3.TransformPoints(tfArray3);
                                            int num2 = Array.IndexOf(tfArray3, this.connectPoint);
                                            if ((num2 >= 0) && (num2 < tfArray3.Length))
                                            {
                                                text3 = text3 + "." + num2.ToString();
                                            }
                                            tfArray3 = null;
                                        }
                                        if (text3 != cebfd1.GetAttribute("end"))
                                        {
                                            IGraph oldgraph = cebfd1.EndGraph;
                                            if (oldgraph != null)
                                            {
                                                oldgraph.ConnectLines.Remove(cebfd1);
                                            }
                                            AttributeFunc.SetAttributeValue(cebfd1, "end", text3);
                                            flag2 = true;
                                        }
                                    }
                                }
                                if (flag2)
                                {
                                    this.mouseAreaControl.PicturePanel.InvalidateElement(this.connectGraph as SvgElement);
                                }
                            }
                        }
                        break;
                    }
                    }
                    Matrix matrix2 = this.graph.GraphTransform.Matrix.Clone();
                    matrix2.Invert();
                    if (this.points.Length > 0)
                    {
                        matrix2.TransformPoints(this.points);
                    }
                    SvgDocument document1 = this.mouseAreaControl.SVGDocument;
                    bool        flag1     = document1.AcceptChanges;
                    document1.AcceptChanges = true;
                    string   text1    = string.Empty;
                    int      num3     = 0;
                    PointF[] tfArray1 = this.points;
                    for (int num4 = 0; num4 < tfArray1.Length; num4++)
                    {
                        PointF tf3 = tfArray1[num4];
                        text1 = text1 + tf3.X.ToString() + " " + tf3.Y.ToString();
                        if (num3 < (this.points.Length - 1))
                        {
                            text1 = text1 + ",";
                        }
                        num3++;
                    }
                    this.mouseAreaControl.PicturePanel.InvalidateElement((SvgElement)this.graph);
                    document1.AcceptChanges = true;
                    this.UpdateGraph(text1);
                    document1.AcceptChanges          = flag1;
                    ((SvgElement)this.graph).pretime = -1;
                    this.mouseAreaControl.Invalidate();
                    this.mouseAreaControl.PicturePanel.InvalidateElement((SvgElement)this.graph);
                }
            }
        }
Exemplo n.º 5
0
 public void DestoryLine(ConnectLine line)
 {
     _lineList.Remove(line);
 }