RadialLabel.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using FastReport.Utils;
  2. using System.Drawing;
  3. using System.ComponentModel;
  4. namespace FastReport.Gauge.Radial
  5. {
  6. #if !DEBUG
  7. [DesignTimeVisible(false)]
  8. #endif
  9. class RadialLabel : GaugeLabel
  10. {
  11. public RadialLabel(GaugeObject parent) : base(parent)
  12. {
  13. Parent = parent as RadialGauge;
  14. }
  15. public override void Draw(FRPaintEventArgs e)
  16. {
  17. if ((Parent as RadialGauge).Type == RadialGaugeType.Circle)
  18. {
  19. base.Draw(e);
  20. float x = (Parent.AbsLeft + Parent.Border.Width / 2) * e.ScaleX;
  21. float y = (Parent.AbsTop + Parent.Border.Width / 2) * e.ScaleY;
  22. float dx = (Parent.Width - Parent.Border.Width) * e.ScaleX - 1;
  23. float dy = (Parent.Height - Parent.Border.Width) * e.ScaleY - 1;
  24. PointF lblPt = new PointF(x + dx / 2, y + dy - ((Parent.Scale as RadialScale).AvrTick.Y - y));
  25. SizeF txtSize = RadialUtils.GetStringSize(e, Parent, Font, Text);
  26. Font font = RadialUtils.GetFont(e, Parent, Font);
  27. Brush brush = e.Cache.GetBrush(Color);
  28. e.Graphics.DrawString(Text, font, brush, lblPt.X - txtSize.Width / 2, lblPt.Y - txtSize.Height / 2);
  29. }
  30. }
  31. }
  32. }