Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new <see cref="LcdGdiRectangle"/> with the specified pen for the edge,
 /// brush for the fill and rectangle dimensions.
 /// </summary>
 /// <param name="pen">Pen to use to draw the edge of this object.</param>
 /// <param name="brush">Brush to use to draw the fill of this object.</param>
 /// <param name="rectangle">Rectangle dimensions.</param>
 public LcdGdiRectangle(Pen pen, Brush brush, RectangleF rectangle)
 {
     Pen    = pen;
     Brush  = brush;
     Margin = new MarginF(rectangle.Location.X, rectangle.Location.Y, 0.0f, 0.0f);
     Size   = rectangle.Size;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new <see cref="LcdGdiArc"/> with the specified pen, dimensions, start angle and sweep angle.
 /// </summary>
 /// <param name="pen">Pen to use to draw the edge of this object.</param>
 /// <param name="rectangle">Rectangle dimensions.</param>
 /// <param name="startAngle">Angle in degrees measured clockwise from the x-axis to the starting point of the arc.</param>
 /// <param name="sweepAngle">Angle in degrees measured clockwise from <paramref name="startAngle"/> to ending point of the arc.</param>
 public LcdGdiArc(Pen pen, RectangleF rectangle, float startAngle, float sweepAngle)
 {
     Pen         = pen;
     Margin      = new MarginF(rectangle.Location.X, rectangle.Location.Y, 0.0f, 0.0f);
     Size        = rectangle.Size;
     _startAngle = startAngle;
     _sweepAngle = sweepAngle;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Calculates the size of the objects from the points, computes margin and makes points relative if needed.
        /// </summary>
        /// <param name="points">Points defining the object.</param>
        /// <param name="keepAbsolute">Whether the given points are left untouched.
        /// <see cref="LcdGdiAbsObject.KeepAbsolute"/> for details.</param>
        protected void CalcAndSetPoints(PointF[] points, bool keepAbsolute)
        {
            if (points == null)
            {
                throw new ArgumentNullException("points");
            }
            if (points.Length == 0)
            {
                throw new ArgumentOutOfRangeException("points", "There must be at least 1 point in the points array.");
            }
            PointF firstPoint = points[0];
            float  minX       = firstPoint.X;
            float  minY       = firstPoint.Y;
            float  maxX       = firstPoint.X;
            float  maxY       = firstPoint.Y;

            for (int i = 1; i < points.Length; ++i)
            {
                PointF point = points[i];
                minX = Math.Min(minX, point.X);
                minY = Math.Min(minY, point.Y);
                maxX = Math.Max(maxX, point.X);
                maxY = Math.Max(maxY, point.Y);
            }
            if (!keepAbsolute)
            {
                Margin = new MarginF(minX, minY, 0.0f, 0.0f);
                maxX  -= minX;
                maxY  -= minY;
                for (int i = 0; i < points.Length; ++i)
                {
                    PointF point = points[i];
                    point.X  -= minX;
                    point.Y  -= minY;
                    points[i] = point;
                }
            }
            _points       = points;
            _keepAbsolute = keepAbsolute;
            Size          = new SizeF(maxX, maxY);
            HasChanged    = true;
        }
 /// <summary>
 /// Changes both the starting point and the ending point of this line.
 /// </summary>
 /// <param name="startPoint">Starting point of this line.</param>
 /// <param name="endPoint">Ending point of this line.</param>
 public void SetPoints(PointF startPoint, PointF endPoint)
 {
     Margin = new MarginF(Math.Min(startPoint.X, endPoint.X), Math.Min(startPoint.Y, endPoint.Y), 0.0f, 0.0f);
     Size   = new SizeF(endPoint.X - startPoint.X, endPoint.Y - startPoint.Y);
 }