Example #1
0
        protected void DrawNodes(Graphics g, Pen p)
        {
            PointF[] renderPoints = new PointF[4];
            Vector2D v;

            foreach (KeyValuePair <Node, List <NodeLink> > kvp in network.nodeDict)
            {
                ShapeNode n = kvp.Key as ShapeNode;

                PointF centre       = n.GetCentre();
                bool   bBezierDrawn = false;

                for (int edgeIndex1 = 0; edgeIndex1 < n.points.Count; edgeIndex1++)
                {
                    NodeLink link1 = n.LinkList[edgeIndex1];

                    if (link1 != null && link1.visited == true)
                    {
                        renderPoints[0] = n.GetEdgeCentre(edgeIndex1);

                        v = new Vector2D(renderPoints[0], centre);
                        v.Scale((float)curveTension.Value);

                        renderPoints[1] = v.b;

                        renderPoints[0].X *= (int)nodeSize.Value;
                        renderPoints[0].Y *= (int)nodeSize.Value;

                        renderPoints[1].X *= (int)nodeSize.Value;
                        renderPoints[1].Y *= (int)nodeSize.Value;

                        DrawCircle(g, renderPoints[0], p.Width, p.Color);

                        for (int edgeIndex2 = (edgeIndex1 + 1); edgeIndex2 < n.points.Count; edgeIndex2++)
                        {
                            NodeLink link2 = n.LinkList[edgeIndex2];
                            if (link2 != null && link2 != link1 && link2.visited == true)
                            {
                                renderPoints[3] = n.GetEdgeCentre(edgeIndex2);

                                v = new Vector2D(renderPoints[3], centre);
                                v.Scale((float)curveTension.Value);

                                renderPoints[3].X *= (int)nodeSize.Value;
                                renderPoints[3].Y *= (int)nodeSize.Value;

                                renderPoints[2]    = v.b;
                                renderPoints[2].X *= (int)nodeSize.Value;
                                renderPoints[2].Y *= (int)nodeSize.Value;

                                g.DrawBeziers(p, renderPoints);
                                bBezierDrawn = true;
                            }
                        }

                        if (bBezierDrawn == false)
                        {
                            // A dead end
                            renderPoints[1]    = centre;
                            renderPoints[1].X *= (int)nodeSize.Value;
                            renderPoints[1].Y *= (int)nodeSize.Value;

                            g.DrawLine(p, renderPoints[0], renderPoints[1]);
                            DrawCircle(g, renderPoints[1], p.Width, p.Color);
                        }
                    }
                }
            }
        }