Esempio n. 1
0
        public void PopulatePanel(Graphics g)
        {
            // add shapes
            foreach (IVertex v in VisitedGraph.Vertices)
            {
                // do not add vertex if already in panel
                if (VertexShapes.Contains(v))
                {
                    continue;
                }
                AttachShape(v);
            }

            // udpate shape sizes if possible and build size dictionary
            NetronGraphvizLayouter layout = new NetronGraphvizLayouter(this);

            layout.Layouter.DpiX          = g.DpiX;
            layout.Layouter.DpiY          = g.DpiY;
            layout.Layouter.RankDirection = this.RankDirection;
            foreach (DictionaryEntry de in this.ShapeVertices)
            {
                if (de.Key is Netron.Shape)
                {
                    Netron.Shape shape = (Netron.Shape)de.Key;
                    layout.VertexSizes[(IVertex)de.Value] = shape.Size;
                }
                else
                {
                    throw new Exception("Shapes must derive from Netron.Shape");
                }
            }
            layout.Compute();
            layout.PositionVertices();

            foreach (IEdge e in VisitedGraph.Edges)
            {
                // check if edge alreay in graph
                if (EdgeConnections.Contains(e))
                {
                    continue;
                }
                AttachConnection(layout, e);
            }

            // reposition connections
            //	layout.PositionConnections();

            // redraw panel
            this.Panel.Invalidate();
            this.graphDirty = false;
        }
        public void PopulatePanel(Graphics g)
        {
            // add shapes
            foreach(IVertex v in VisitedGraph.Vertices)
            {
                // do not add vertex if already in panel
                if (VertexShapes.Contains(v))
                    continue;
                AttachShape(v);
            }

            // udpate shape sizes if possible and build size dictionary
            NetronGraphvizLayouter layout = new NetronGraphvizLayouter(this);
            layout.Layouter.DpiX = g.DpiX;
            layout.Layouter.DpiY = g.DpiY;
            layout.Layouter.RankDirection = this.RankDirection;
            foreach(DictionaryEntry de in this.ShapeVertices)
            {
                if (de.Key is Netron.Shape)
                {
                    Netron.Shape shape = (Netron.Shape)de.Key;
                    layout.VertexSizes[(IVertex)de.Value] = shape.Size;
                }
                else
                    throw new Exception("Shapes must derive from Netron.Shape");
            }
            layout.Compute();
            layout.PositionVertices();

            foreach(IEdge e in VisitedGraph.Edges)
            {
                // check if edge alreay in graph
                if (EdgeConnections.Contains(e))
                    continue;
                AttachConnection(layout,e);
            }

            // reposition connections
            //	layout.PositionConnections();

            // redraw panel
            this.Panel.Invalidate();
            this.graphDirty = false;
        }