示例#1
0
        protected void DrawLine(SharpDXRenderer renderer, Vector2 center, float distance, float length, float angle, float width, bool outline)
        {
            ExternalUtilsCSharp.MathObjects.Vector2 vecCenter  = SharpDXConverter.Vector2SDXtoEUC(center);
            ExternalUtilsCSharp.MathObjects.Vector2 vecRotateA = new MathObjects.Vector2(vecCenter.X + distance, vecCenter.Y);
            ExternalUtilsCSharp.MathObjects.Vector2 vecRotateB = new MathObjects.Vector2(vecCenter.X + distance + length, vecCenter.Y);
            vecRotateA = ExternalUtilsCSharp.MathUtils.RotatePoint(vecRotateA, vecCenter, angle);
            vecRotateB = ExternalUtilsCSharp.MathUtils.RotatePoint(vecRotateB, vecCenter, angle);
            Vector2 _vecRotateA = SharpDXConverter.Vector2EUCtoSDX(vecRotateA);
            Vector2 _vecRotateB = SharpDXConverter.Vector2EUCtoSDX(vecRotateB);

            if (outline)
            {
                renderer.DrawLine(this.SecondaryColor, _vecRotateA, _vecRotateB, width + 2f);
            }
            renderer.DrawLine(this.PrimaryColor, _vecRotateA, _vecRotateB, width);
        }
        public override void Draw(SharpDXRenderer renderer)
        {
            Vector2 center = this.LastCursorPoint;
            Vector2 right  = this.LastCursorPoint + Vector2.UnitX * this.Width;
            Vector2 left   = SharpDXConverter.Vector2EUCtoSDX(MathUtils.RotatePoint(
                                                                  SharpDXConverter.Vector2SDXtoEUC(right),
                                                                  SharpDXConverter.Vector2SDXtoEUC(center),
                                                                  Angle));

            right = SharpDXConverter.Vector2EUCtoSDX(MathUtils.RotatePoint(
                                                         SharpDXConverter.Vector2SDXtoEUC(right),
                                                         SharpDXConverter.Vector2SDXtoEUC(center),
                                                         AngleRotation));
            left = SharpDXConverter.Vector2EUCtoSDX(MathUtils.RotatePoint(
                                                        SharpDXConverter.Vector2SDXtoEUC(left),
                                                        SharpDXConverter.Vector2SDXtoEUC(center),
                                                        AngleRotation));

            renderer.FillPolygon(this.BackColor, left, center, right);
            renderer.DrawPolygon(this.ForeColor, left, center, right);
            base.Draw(renderer);
        }
        protected virtual void DrawDot(SharpDXRenderer renderer, Vector2 coordinate, Color color, Vector2 controlCenter, Vector2 dotSize)
        {
            Vector2 delta = (coordinate - CenterCoordinate) * Scaling;

            delta.X *= -1;
            if (Rotating)
            {
                delta = SharpDXConverter.Vector2EUCtoSDX(
                    MathUtils.RotatePoint(
                        SharpDXConverter.Vector2SDXtoEUC(delta),
                        ExternalUtilsCSharp.MathObjects.Vector2.Zero,
                        RotationDegrees));
            }
            if (Math.Abs(delta.X) + DotRadius > this.Width / 2f)
            {
                if (delta.X > 0)
                {
                    delta.X = this.Width / 2f - DotRadius;
                }
                else
                {
                    delta.X = -this.Width / 2f + DotRadius;
                }
            }
            if (Math.Abs(delta.Y) + DotRadius > this.Height / 2f)
            {
                if (delta.Y > 0)
                {
                    delta.Y = this.Height / 2f - DotRadius;
                }
                else
                {
                    delta.Y = -this.Height / 2f + DotRadius;
                }
            }

            renderer.FillEllipse(color, controlCenter + delta, dotSize, true);
            renderer.DrawEllipse(this.ForeColor, controlCenter + delta, dotSize, true);
        }