public void FillRectangle(Point location, Size size, Color color) { var rectangle = new RectangleF(location.ToPointF(), size.ToSizeF()); using (var brush = new SolidBrush(color.ToColor())) { m_Graphics.FillRectangle(brush, rectangle); } }
public void DrawRectangle(Point location, Size size, Color color, LineStyle lineStyle) { var rectangle = new RectangleF(location.ToPointF(), size.ToSizeF()); using (var pen = new Pen(color.ToColor())) { Point topLeft = location; Point topRight = location.Offset(size.Width, 0); Point bottomLeft = location.Offset(0, size.Height); Point bottomRight = location.Offset(size.Width, size.Height); DrawLineCore(topLeft, topRight, pen.Width, color, lineStyle); DrawLineCore(topRight, bottomRight, pen.Width, color, lineStyle); DrawLineCore(bottomRight, bottomLeft, pen.Width, color, lineStyle); DrawLineCore(bottomLeft, topLeft, pen.Width, color, lineStyle); } }
public void DrawText(Point location, Size size, string text, Font font, float fontSize, Color color, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) { using (var drawFont = CreateFont(font, fontSize)) { var rectangle = new RectangleF(location.ToPointF(), size.ToSizeF()); using (var stringFormat = new StringFormat()) { stringFormat.Alignment = horizontalAlignment.ToStringAlignment(); stringFormat.LineAlignment = verticalAlignment.ToStringAlignment(); using (var brush = new SolidBrush(System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B))) { string stringToDraw = ReplaceLineBreaks(text); m_Graphics.DrawString(stringToDraw, drawFont, brush, rectangle, stringFormat); } } } }