using System; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; using FastReport.Utils; namespace FastReport.Controls { /// /// Represents the label with line. /// [ToolboxItem(false)] public class LabelLine : Control { /// protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; #if AVALONIA TextRenderer.FontScale = g.FontScale; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; #endif using (Pen pen = new Pen(Color.Silver, this.LogicalToDevice(1))) { int x = 0; if (RightToLeft == RightToLeft.Yes) { if (!String.IsNullOrEmpty(Text)) { x = Width - TextRenderer.MeasureText(Text, Font).Width; TextRenderer.DrawText(g, Text, Font, new Point(x, 0), ForeColor, TextFormatFlags.RightToLeft); x -= this.LogicalToDevice(4); } g.DrawLine(pen, 0, Height / 2, x, Height / 2); } else { if (!String.IsNullOrEmpty(Text)) { TextRenderer.DrawText(g, Text, Font, new Point(0, 0), ForeColor); x += TextRenderer.MeasureText(Text, Font).Width + this.LogicalToDevice(4); } g.DrawLine(pen, x, Height / 2, Width, Height / 2); } } } /// /// Initializes a new instance of the class. /// public LabelLine() { SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.OptimizedDoubleBuffer, true); SetStyle(ControlStyles.SupportsTransparentBackColor, true); } } }