/GammaJul.LgLcd/LcdGdiRectangle.cs
C# | 64 lines | 26 code | 8 blank | 30 comment | 4 complexity | d9fd0011be3f54aa9b960b4e336b46cb MD5 | raw file
Possible License(s): LGPL-2.1
1using System; 2using System.Drawing; 3 4namespace GammaJul.LgLcd { 5 6 /// <summary> 7 /// Represents a simple rectangle on a <see cref="LcdGdiPage"/>. 8 /// </summary> 9 public class LcdGdiRectangle : LcdGdiObject { 10 11 /// <summary> 12 /// Draws the rectangle. 13 /// </summary> 14 /// <param name="page">Page where this object will be drawn.</param> 15 /// <param name="graphics"><see cref="Graphics"/> to use for drawing.</param> 16 protected internal override void Draw(LcdGdiPage page, Graphics graphics) { 17 if (Brush != null) 18 graphics.FillRectangle(Brush, AbsolutePosition.X, AbsolutePosition.Y, FinalSize.Width - 1.0f, FinalSize.Height - 1.0f); 19 if (Pen != null) 20 graphics.DrawRectangle(Pen, AbsolutePosition.X, AbsolutePosition.Y, FinalSize.Width - 1.0f, FinalSize.Height - 1.0f); 21 } 22 23 /// <summary> 24 /// Creates a new <see cref="LcdGdiRectangle"/>. 25 /// </summary> 26 public LcdGdiRectangle() { 27 } 28 29 /// <summary> 30 /// Creates a new <see cref="LcdGdiRectangle"/> with no edge, 31 /// and specified brush for the fill and rectangle dimensions. 32 /// </summary> 33 /// <param name="brush">Brush to use to draw the fill of this object.</param> 34 /// <param name="rectangle">Rectangle dimensions.</param> 35 public LcdGdiRectangle(Brush brush, RectangleF rectangle) 36 : this(null, brush, rectangle) { 37 } 38 39 /// <summary> 40 /// Creates a new <see cref="LcdGdiRectangle"/> with the specified pen for the edge, 41 /// no fill brush and specified rectangle dimensions. 42 /// </summary> 43 /// <param name="pen">Pen to use to draw the edge of this object.</param> 44 /// <param name="rectangle">Rectangle dimensions.</param> 45 public LcdGdiRectangle(Pen pen, RectangleF rectangle) 46 : this(pen, null, rectangle) { 47 } 48 49 /// <summary> 50 /// Creates a new <see cref="LcdGdiRectangle"/> with the specified pen for the edge, 51 /// brush for the fill and rectangle dimensions. 52 /// </summary> 53 /// <param name="pen">Pen to use to draw the edge of this object.</param> 54 /// <param name="brush">Brush to use to draw the fill of this object.</param> 55 /// <param name="rectangle">Rectangle dimensions.</param> 56 public LcdGdiRectangle(Pen pen, Brush brush, RectangleF rectangle) { 57 Pen = pen; 58 Brush = brush; 59 Margin = new MarginF(rectangle.Location.X, rectangle.Location.Y, 0.0f, 0.0f); 60 Size = rectangle.Size; 61 } 62 } 63 64}