Beispiel #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");
        }
Beispiel #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");
        }
Beispiel #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();
        }
Beispiel #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);
        }
Beispiel #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();
        }
Beispiel #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);
        }
Beispiel #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();
        }
Beispiel #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();
        }
Beispiel #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;
            }
        }
Beispiel #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);
         }
     }
 }
Beispiel #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;
        }
Beispiel #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;
            }
        }
Beispiel #13
0
 public GUIFlowEdge(GUIVertex start, GUIVertex end, FlowEdge fe)
     : base(start, end, fe)
 {
     this.fe = fe;
 }
Beispiel #14
0
 public GUIFlowEdge(GUIVertex start, GUIVertex end, FlowEdge fe)
     : base(start, end, fe)
 {
     this.fe = fe;
 }
Beispiel #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();
        }
Beispiel #16
0
 private void RemoveVertex(GUIVertex gv, GraphApp app)
 {
     app.RemoveVertex(gv.Vertex);
     verts.Remove(gv);
     selectables.Remove(gv);
 }
Beispiel #17
0
 private void RemoveVertex(GUIVertex gv, GraphApp app)
 {
     app.RemoveVertex(gv.Vertex);
     verts.Remove(gv);
     selectables.Remove(gv);
 }