Esempio n. 1
0
        /// <summary>测试点击的位置(并设置SelectedPart值)</summary>
        /// <param name="ctrls">需要测试的控制部件</param>
        public void HitTest(PointF p, BazierPointPart ctrls = BazierPointPart.PrevControl | BazierPointPart.NextControl)
        {
            this.HitPart = BazierPointPart.None;
            if (HitTestPoint(this.Point, p))
            {
                this.HitPart = BazierPointPart.Point;
            }

            if (ctrls.HasFlag(BazierPointPart.PrevControl) && HitTestPoint(this.PrevControl, p))
            {
                this.HitPart = BazierPointPart.PrevControl;
            }

            if (ctrls.HasFlag(BazierPointPart.NextControl) && HitTestPoint(this.NextControl, p))
            {
                this.HitPart = BazierPointPart.NextControl;
            }
        }
Esempio n. 2
0
        /// <summary>绘制贝塞尔曲线控制点</summary>
        /// <param name="ctrls">要显示的控制点</param>
        public void Draw(Graphics g, BazierPointPart ctrls = BazierPointPart.PrevControl | BazierPointPart.NextControl)
        {
            var pen = new Pen(Color.Black);

            if (HitPart == BazierPointPart.None)
            {
                Painter.DrawDot(g, this.Point, Color.Black, false);
            }
            else
            {
                Painter.DrawDot(g, this.Point, Color.Black, HitPart == BazierPointPart.Point);
                if (ctrls.HasFlag(BazierPointPart.PrevControl))
                {
                    g.DrawLine(pen, this.Point, this.PrevControl);
                    Painter.DrawDot(g, this.PrevControl, Color.Black, HitPart == BazierPointPart.PrevControl);
                }
                if (ctrls.HasFlag(BazierPointPart.NextControl))
                {
                    g.DrawLine(pen, this.Point, this.NextControl);
                    Painter.DrawDot(g, this.NextControl, Color.Black, HitPart == BazierPointPart.NextControl);
                }
            }
        }