Beispiel #1
0
 private void DrawBezierMark(IBezierDrawContext context)
 {
     if (bezierControl1.Controller.BCPS != null && bezierControl1.Controller.BCPS.Length >= 2)
     {
         context.DrawString("S", Color.Black, Font.Height, bezierControl1.Controller.BCPS[0].Second);
         context.DrawString("T", Color.Black, Font.Height, bezierControl1.Controller.BCPS[bezierControl1.Controller.BCPS.Length - 1].Second);
     }
 }
Beispiel #2
0
        private void DrawTransData(IBezierDrawContext context)
        {
            context.DrawLines(Color.Black, new PointF[] { transBeziers.TransformRectange.TopLeft, transBeziers.TransformRectange.TopRight, transBeziers.TransformRectange.BottomRight, transBeziers.TransformRectange.BottomLeft, transBeziers.TransformRectange.TopLeft });
            DrawSquare(transBeziers.TransformRectange.TopLeft, context);
            DrawSquare(transBeziers.TransformRectange.TopRight, context);
            DrawSquare(transBeziers.TransformRectange.BottomLeft, context);
            DrawSquare(transBeziers.TransformRectange.BottomRight, context);
            DrawSquare(transBeziers.TransformRectange.TopMiddle, context);
            DrawSquare(transBeziers.TransformRectange.LeftMiddle, context);
            DrawSquare(transBeziers.TransformRectange.RightMiddle, context);
            DrawSquare(transBeziers.TransformRectange.BottomMiddle, context);
            PointF center = transBeziers.TransformRectange.Center;

            context.DrawEllipse(Color.Black, new RectangleF
            {
                X      = center.X - 3,
                Width  = 6,
                Y      = center.Y - 3,
                Height = 6
            });

            BezierControlPoint previous = null;

            foreach (BezierControlPoint bcp in transBeziers.BCPS)
            {
                if (previous != null)
                {
                    if (previous.ValidThird)
                    {
                        if (!bcp.ValidFirst)
                        {
                            //second bezier
                            DrawBezeier(previous.Second, previous.Third, bcp.Second, bcp.Second, context);
                        }
                        else
                        {
                            //third bezier
                            DrawBezeier(previous.Second, previous.Third, bcp.First, bcp.Second, context);
                        }
                    }
                    else
                    {
                        if (!bcp.ValidFirst)
                        {
                            //first bezier
                            context.DrawLine(Color.Black, previous.Second, bcp.Second);
                        }
                        else
                        {
                            //second bezier
                            DrawBezeier(previous.Second, previous.Second, bcp.First, bcp.Second, context);
                        }
                    }
                }
                previous = bcp;
            }
        }
Beispiel #3
0
 public void Draw(IBezierDrawContext context)
 {
     OnBeforePaint(context);
     if (tmode > TransformMode.None)
     {
         DrawTransData(context);
     }
     else
     {
         DrawNormalData(context);
     }
     OnAfterPaint(context);
 }
Beispiel #4
0
        private void DrawBezeier(PointF p1, PointF p2, PointF p3, PointF p4, IBezierDrawContext context)
        {
            PointF lastbezeirpoint, bezeirpoint;

            lastbezeirpoint = p1;
            var count = BezierCaliculate.AboutBezeirCount(ref p1, ref p2, ref p3, ref p4);

            for (int i = count; i >= 0; i--)
            {
                float t = (float)i / count;
                bezeirpoint = BezierCaliculate.GetBezeirPoint(ref p1, ref p2, ref p3, ref p4, ref t);
                context.DrawLine(Color.Black, lastbezeirpoint, bezeirpoint);
                lastbezeirpoint = bezeirpoint;
            }
        }
Beispiel #5
0
        private void DrawNormalData(IBezierDrawContext context)
        {
            BezierControlPoint previous = null;

            for (int i = 0; i < data.Count; i++)
            {
                var bcp = data[i] as BezierControlPoint;
                if ((dmode & DrawMode.Anchor) == DrawMode.Anchor)
                {
                    DrawAnchor(bcp, context);
                }
                if ((dmode & DrawMode.Line) == DrawMode.Line)
                {
                    if (previous != null)
                    {
                        if (previous.ValidThird)
                        {
                            if (!bcp.ValidFirst)
                            {
                                //second bezier
                                DrawBezeier(previous.Second, previous.Third, bcp.Second, bcp.Second, context);
                            }
                            else
                            {
                                //third bezier
                                DrawBezeier(previous.Second, previous.Third, bcp.First, bcp.Second, context);
                            }
                        }
                        else
                        {
                            if (!bcp.ValidFirst)
                            {
                                //first bezier
                                context.DrawLine(Color.Black, previous.Second, bcp.Second);
                            }
                            else
                            {
                                //second bezier
                                DrawBezeier(previous.Second, previous.Second, bcp.First, bcp.Second, context);
                            }
                        }
                    }
                }
                previous = bcp;
            }
        }
Beispiel #6
0
 private void DrawAnchor(BezierControlPoint bcp, IBezierDrawContext context)
 {
     if (SelectedPoint == bcp)
     {
         FillSquare(bcp.Second, context);
         if (bcp.ValidFirst)
         {
             FillSquare(bcp.First, context);
             context.DrawLine(Color.Black, bcp.First, bcp.Second);
         }
         if (bcp.ValidThird)
         {
             FillSquare(bcp.Third, context);
             context.DrawLine(Color.Black, bcp.Second, bcp.Third);
         }
     }
     else
     {
         DrawSquare(bcp.Second, context);
     }
 }
Beispiel #7
0
 private void DrawCenter(IBezierDrawContext context)
 {
     context.DrawLine(Color.FromArgb(128, 0, 0, 0), new Point(bezierControl1.Width / 2, 0), new Point(bezierControl1.Width / 2, bezierControl1.Height));
     context.DrawLine(Color.FromArgb(128, 0, 0, 0), new Point(0, bezierControl1.Height / 2), new Point(bezierControl1.Width, bezierControl1.Height / 2));
 }
Beispiel #8
0
 public UserPaintEventArgs(IBezierDrawContext context)
 {
     Context = context;
 }
Beispiel #9
0
 private void DrawSquare(PointF p, IBezierDrawContext context)
 {
     context.DrawRectangle(Color.Black, p.X - 3, p.Y - 3, 6, 6);
 }