Ejemplo n.º 1
0
        protected void Connect(IVertex v, Shape shape)
        {
            // storing in hashtable
            VertexShapes.Add(v, shape);
            ShapeVertices.Add(shape, v);

            OnConnectVertex(shape, v);
        }
Ejemplo n.º 2
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;
        }