RadialLabel.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 Assign(GaugeLabel src)
  16. {
  17. base.Assign(src);
  18. }
  19. public override void Serialize(FRWriter writer, string prefix, GaugeLabel diff)
  20. {
  21. base.Serialize(writer, prefix, diff);
  22. }
  23. public override void Draw(FRPaintEventArgs e)
  24. {
  25. if ((Parent as RadialGauge).Type == RadialGaugeType.Circle)
  26. {
  27. base.Draw(e);
  28. float x = (Parent.AbsLeft + Parent.Border.Width / 2) * e.ScaleX;
  29. float y = (Parent.AbsTop + Parent.Border.Width / 2) * e.ScaleY;
  30. float dx = (Parent.Width - Parent.Border.Width) * e.ScaleX - 1;
  31. float dy = (Parent.Height - Parent.Border.Width) * e.ScaleY - 1;
  32. PointF lblPt = new PointF(x + dx / 2, y + dy - ((Parent.Scale as RadialScale).AvrTick.Y - y));
  33. SizeF txtSize = RadialUtils.GetStringSize(e, Parent, Font, Text);
  34. Font font = RadialUtils.GetFont(e, Parent, Font);
  35. Brush brush = e.Cache.GetBrush(Color);
  36. e.Graphics.DrawString(Text, font, brush, lblPt.X - txtSize.Width / 2, lblPt.Y - txtSize.Height / 2);
  37. }
  38. }
  39. }
  40. }