Пример #1
0
        public void DrawSelf(Brush b, Pen p)
        {
            NodeShapeType shape = NodeShape;

            if (shape == NodeShapeType.圆角矩形)
            {
                ShapeHelper.FillRoundRectangle(nodeGraphics, b, SelfOutRect, 8);
                ShapeHelper.DrawRoundRectangle(nodeGraphics, p, SelfOutRect, 8);
            }
            else if (shape == NodeShapeType.椭圆形)
            {
                nodeGraphics.FillEllipse(b, SelfOutRect);
                nodeGraphics.DrawEllipse(p, SelfOutRect);
            }
            else if (shape == NodeShapeType.菱形)
            {
                ShapeHelper.FillDiamond(nodeGraphics, b, SelfOutRect);
                ShapeHelper.DrawDiamond(nodeGraphics, p, SelfOutRect);
            }
            else if (shape == NodeShapeType.直角矩形)
            {
                nodeGraphics.FillRectangle(b, SelfOutRect);
                nodeGraphics.DrawRectangle(p, SelfOutRect);
            }
            else if (shape == NodeShapeType.六边形)
            {
                ShapeHelper.FillHexagon(nodeGraphics, b, SelfOutRect);
                ShapeHelper.DrawHexagon(nodeGraphics, p, SelfOutRect);
            }
            nodeGraphics.DrawString(NodeName, textFont, Brushes.Black, new Point(SelfOutRect.X + 4, SelfOutRect.Y + 4));
        }
Пример #2
0
        public void DrawNode()
        {
            Brush b = new SolidBrush(NodeColor);
            Pen   p = new Pen(Color.Black, 2);

            DrawSelf(b, p);

            //calc point
            Point begin = new Point(SelfOutRect.Right, SelfOutRect.Top + SelfOutRect.Height / 2);
            Point end   = new Point();

            foreach (var child in Children)
            {
                end.X = child.SelfOutRect.Left;
                end.Y = child.SelfOutRect.Top + child.SelfOutRect.Height / 2;
                ShapeHelper.DrawConnectLine(nodeGraphics, p, begin, end);
                child.DrawNode();
            }
        }
Пример #3
0
        public override void OnPaint(PaintEventArgs e)
        {
            Init();

            //绘制原图
            Root.SetGraphics(e.Graphics);
            Root.CalcNodeHeight();
            Root.CalcNodeWidth();
            Root.SelfOutRect.X = ClientSize.Width / 2 - Root.NodeOutRect.Width / 2;
            Root.SelfOutRect.Y = ClientSize.Height / 2;

            Root.AutoLayout();
            Root.DrawNode();
            if (CurrentSelectNode != null)
            {
                CurrentSelectNode.DrawOutLine(outlinePen);
            }

            if (!IsMoving || CurrentMoveNode == null)
            {
                return;
            }
            //绘制移动的节点
            CurrentMoveNode.SelfOutRect.X = MovingPos.X - CurrentMoveNode.SelfOutRect.Width / 2;
            CurrentMoveNode.SelfOutRect.Y = MovingPos.Y - CurrentMoveNode.SelfOutRect.Height / 2;
            CurrentMoveNode.DrawSelf(moveBrush, movePen);

            if (MoveToParentNode == null)
            {
                return;
            }
            //绘制父节点连线
            MoveToParentNode.DrawOutLine(outlinePen);
            CurrentMoveNode.DrawOutLine(outlinePen);
            ShapeHelper.DrawConnectLine(e.Graphics, outlinePen, MoveToParentNode.ConnectOutPos, CurrentMoveNode.ConnectInPos);
        }
Пример #4
0
        public static void DrawConnectLine(Graphics g, Pen p, Point begin, Point end)
        {
            //begin.x<end.x
            Point ctrl1 = new Point(begin.X + 50, begin.Y);
            Point ctrl2 = new Point(end.X - 50, end.Y);

            if (begin.X > end.X)
            {
                ctrl1.X = begin.X - 50;
                ctrl2.X = end.X + 50;
            }
            g.DrawBeziers(p, new[] { begin, ctrl1, ctrl2, end });

            if (begin.X < end.X)
            {
                ShapeHelper.FillRightArrow(g, new SolidBrush(p.Color), end, 4);
            }
            else
            {
                ShapeHelper.FillLeftArrow(g, new SolidBrush(p.Color), end, 4);
            }

            //DrawBeziersPoint(g);
        }
Пример #5
0
 public override void OnPaint(PaintEventArgs e)
 {
     ShapeHelper.FillDiamond(e.Graphics, drawBrush, new Rectangle(200, 200, 200, 150));
     ShapeHelper.DrawDiamond(e.Graphics, drawPen, new Rectangle(200, 200, 200, 150));
 }
Пример #6
0
 public override void OnPaint(PaintEventArgs e)
 {
     ShapeHelper.FillRoundRectangle(e.Graphics, drawBrush, new Rectangle(150, 150, 100, 50), 10);
     ShapeHelper.DrawRoundRectangle(e.Graphics, drawPen, new Rectangle(150, 150, 100, 50), 10);
 }
Пример #7
0
 public override void OnPaint(PaintEventArgs e)
 {
     ShapeHelper.DrawConnectLine(e.Graphics, drawPen, ConnectBegin, ConnectEnd);
 }
Пример #8
0
        public void DrawOutLine(Pen p)
        {
            var rect = new Rectangle(SelfOutRect.X - 1, SelfOutRect.Y - 1, SelfOutRect.Width + 2, SelfOutRect.Height + 2);

            ShapeHelper.DrawRoundRectangle(nodeGraphics, p, rect, 8);
        }