示例#1
0
        public void End(GraphApp app, GraphAppGUI appGUI, Point p)
        {
            if (!HasBegun)
            {
                return;
            }
            GraphPanel       gp        = appGUI.CurrentGraphPanel;
            List <GUIVertex> verts     = gp.Vertices;
            bool             foundVert = false;

            foreach (GUIVertex v in verts)
            {
                if (GeometryHelper.Intersects(p, new Circle(v.Pos, v.Radius)))
                {
                    endVert = v;
                    Console.WriteLine("Edge tool ended on vertex " + v.Vertex.Label);
                    foundVert = true;
                    //Add vertex
                    if (isFlowNetwork)
                    {
                        FlowEdge fe = app.AddFlowEdge(startVert.Vertex, endVert.Vertex);
                        gp.AddEdge(startVert, endVert, fe);
                    }
                    else
                    {
                        //Change to add two edges, for both directions
                        Edge e = app.AddEdge(startVert.Vertex, endVert.Vertex);
                        gp.AddEdge(startVert, endVert, e);
                    }

                    break;
                }
            }

            HasBegun = false;

            if (!foundVert)
            {
                startVert = null;
                endVert   = null;
                return;
            }
        }