LinearGauge.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using System.ComponentModel;
  2. using System.Drawing;
  3. using System.Drawing.Drawing2D;
  4. using FastReport.Utils;
  5. namespace FastReport.Gauge.Linear
  6. {
  7. /// <summary>
  8. /// Represents a linear gauge.
  9. /// </summary>
  10. public partial class LinearGauge : GaugeObject
  11. {
  12. #region Fields
  13. private bool inverted;
  14. #endregion // Fields
  15. #region Properties
  16. /// <summary>
  17. /// Gets or sets the value that specifies inverted gauge or not.
  18. /// </summary>
  19. [Category("Appearance")]
  20. public bool Inverted
  21. {
  22. get { return inverted; }
  23. set { inverted = value; }
  24. }
  25. /// <summary>
  26. /// Gets or sets gauge label.
  27. /// </summary>
  28. [Browsable(false)]
  29. public override GaugeLabel Label
  30. {
  31. get { return base.Label; }
  32. set { base.Label = value; }
  33. }
  34. #endregion // Properties
  35. #region Constructors
  36. /// <summary>
  37. /// Initializes a new instance of the <see cref="LinearGauge"/> class.
  38. /// </summary>
  39. public LinearGauge() : base()
  40. {
  41. InitializeComponent();
  42. Scale = new LinearScale(this);
  43. Pointer = new LinearPointer(this);
  44. Height = 2.0f * Units.Centimeters;
  45. Width = 8.0f * Units.Centimeters;
  46. inverted = false;
  47. }
  48. #endregion // Constructors
  49. #region Public Methods
  50. /// <inheritdoc/>
  51. public override void Assign(Base source)
  52. {
  53. base.Assign(source);
  54. LinearGauge src = source as LinearGauge;
  55. Inverted = src.Inverted;
  56. }
  57. /// <inheritdoc/>
  58. public override void Draw(FRPaintEventArgs e)
  59. {
  60. IGraphics g = e.Graphics;
  61. if (Report != null && Report.SmoothGraphics)
  62. {
  63. g.InterpolationMode = InterpolationMode.HighQualityBicubic;
  64. g.SmoothingMode = SmoothingMode.AntiAlias;
  65. }
  66. base.Draw(e);
  67. Scale.Draw(e);
  68. Pointer.Draw(e);
  69. Border.Draw(e, new RectangleF(AbsLeft, AbsTop, Width, Height));
  70. }
  71. /// <inheritdoc/>
  72. public override void Serialize(FRWriter writer)
  73. {
  74. LinearGauge c = writer.DiffObject as LinearGauge;
  75. base.Serialize(writer);
  76. if (Inverted != c.Inverted)
  77. {
  78. writer.WriteBool("Inverted", Inverted);
  79. }
  80. }
  81. #endregion // Public Methods
  82. }
  83. }