Esempio n. 1
0
        public void Begin(GraphAppGUI appGUI, Point p)
        {
            if (HasBegun)
            {
                return;
            }

            isFlowNetwork = false;

            GraphPanel gp = appGUI.CurrentGraphPanel;

            isFlowNetwork = (gp.Graph as FlowNetwork) != null;
            List <GUIVertex> verts = gp.Vertices;

            foreach (GUIVertex v in verts)
            {
                if (GeometryHelper.Intersects(p, new Circle(v.Pos, v.Radius)))
                {
                    startVert = v;
                    Console.WriteLine("Edge tool selected vertex " + v.Vertex.Label);
                    HasBegun = true;
                    return;
                }
            }

            startVert = null;
            HasBegun  = false;
            Console.WriteLine("Edge tool selected null");
        }
Esempio n. 2
0
        public void Begin(GraphAppGUI appGUI, Point p)
        {
            if (HasBegun)
            {
                return;
            }

            isFlowNetwork = false;

            GraphPanel gp = appGUI.CurrentGraphPanel;
            isFlowNetwork = (gp.Graph as FlowNetwork) != null;
            List<GUIVertex> verts = gp.Vertices;

            foreach (GUIVertex v in verts)
            {
                if (GeometryHelper.Intersects(p, new Circle(v.Pos, v.Radius)))
                {
                    startVert = v;
                    Console.WriteLine("Edge tool selected vertex " + v.Vertex.Label);
                    HasBegun = true;
                    return;
                }
            }

            startVert = null;
            HasBegun = false;
            Console.WriteLine("Edge tool selected null");
        }
Esempio n. 3
0
        public void DeleteSelection(GraphApp app)
        {
            List <GUIEdge> localEdges = new List <GUIEdge>();

            foreach (ISelectable i in currentSelection)
            {
                GUIVertex gv = i as GUIVertex;
                if (gv != null)
                {
                    RemoveVertex(gv, app);
                    foreach (GUIEdge ge in gv.GetEdges())
                    {
                        localEdges.Add(ge);
                    }
                    continue;
                }

                GUIEdge e = i as GUIEdge;
                if (e != null)
                {
                    RemoveEdge(e, app);
                    continue;
                }
            }

            foreach (GUIEdge connected in localEdges)
            {
                RemoveEdge(connected, app);
            }

            Refresh();
        }
Esempio n. 4
0
        public GUIEdge(GUIVertex start, GUIVertex end, Edge e)
        {
            this.e = e;
            this.start = start;
            this.end = end;
            start.AddEdge(this);
            end.AddEdge(this);

            font = new Font(new FontFamily("Arial"), 12f, FontStyle.Regular);
        }
Esempio n. 5
0
        public void AddEdge(GUIVertex start, GUIVertex end, Edge e)
        {
            GUIEdge edge = new GUIEdge(start, end, e);
            edge.Brush = GUIEdge.DefaultBrush;
            edge.LineWidth = GUIEdge.DefaultLineWidth;
            edges.Add(edge);
            selectables.Add(edge);

            Refresh();
        }
Esempio n. 6
0
        public GUIEdge(GUIVertex start, GUIVertex end, Edge e)
        {
            this.e     = e;
            this.start = start;
            this.end   = end;
            start.AddEdge(this);
            end.AddEdge(this);

            font = new Font(new FontFamily("Arial"), 12f, FontStyle.Regular);
        }
Esempio n. 7
0
        public void AddEdge(GUIVertex start, GUIVertex end, FlowEdge fe)
        {
            GUIFlowEdge edge = new GUIFlowEdge(start, end, fe);

            edge.Brush     = GUIEdge.DefaultBrush;
            edge.LineWidth = GUIEdge.DefaultLineWidth;
            edges.Add(edge);
            selectables.Add(edge);

            Refresh();
        }
Esempio n. 8
0
        public void AddVertex(Vertex v, Point pos)
        {
            GUIVertex gv = new GUIVertex(v, pos);

            gv.Brush     = GUIVertex.DefaultBrush;
            gv.Radius    = GUIVertex.DefaultRadius;
            gv.LineWidth = GUIVertex.DefaultLineWidth;
            verts.Add(gv);
            selectables.Add(gv);

            //Refresh to draw new vertices
            Refresh();
        }
Esempio n. 9
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;
            }
        }
Esempio n. 10
0
 public override void Draw(Graphics g)
 {
     if (!hasBegun)
     {
         return;
     }
     if (selection != null)
     {
         foreach (ISelectable i in selection)
         {
             GUIVertex gv = i as GUIVertex;
             if (gv == null)
             {
                 continue;
             }
             gv.Draw(g, delta);
         }
     }
 }
Esempio n. 11
0
        public void End(Point p)
        {
            delta = new Point(p.X - start.X, p.Y - start.Y);

            if (selection != null)
            {
                foreach (ISelectable i in selection)
                {
                    GUIVertex gv = i as GUIVertex;
                    if (gv == null)
                    {
                        continue;
                    }
                    gv.Pos = new Point(gv.Pos.X + delta.X, gv.Pos.Y + delta.Y);
                }
            }

            hasBegun  = false;
            selection = null;
        }
Esempio n. 12
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;
            }
        }
Esempio n. 13
0
 public GUIFlowEdge(GUIVertex start, GUIVertex end, FlowEdge fe)
     : base(start, end, fe)
 {
     this.fe = fe;
 }
Esempio n. 14
0
 public GUIFlowEdge(GUIVertex start, GUIVertex end, FlowEdge fe)
     : base(start, end, fe)
 {
     this.fe = fe;
 }
Esempio n. 15
0
        public void AddVertex(Vertex v, Point pos)
        {
            GUIVertex gv = new GUIVertex(v, pos);
            gv.Brush = GUIVertex.DefaultBrush;
            gv.Radius = GUIVertex.DefaultRadius;
            gv.LineWidth = GUIVertex.DefaultLineWidth;
            verts.Add(gv);
            selectables.Add(gv);

            //Refresh to draw new vertices
            Refresh();
        }
Esempio n. 16
0
 private void RemoveVertex(GUIVertex gv, GraphApp app)
 {
     app.RemoveVertex(gv.Vertex);
     verts.Remove(gv);
     selectables.Remove(gv);
 }
Esempio n. 17
0
 private void RemoveVertex(GUIVertex gv, GraphApp app)
 {
     app.RemoveVertex(gv.Vertex);
     verts.Remove(gv);
     selectables.Remove(gv);
 }