ButtonBaseControl.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using System.Drawing;
  2. using System.ComponentModel;
  3. using FastReport.Utils;
  4. using System.Windows.Forms;
  5. namespace FastReport.Dialog
  6. {
  7. /// <summary>
  8. /// Implements base behavior of button controls.
  9. /// </summary>
  10. public partial class ButtonBaseControl : DataFilterBaseControl
  11. {
  12. #region Properties
  13. private ButtonBase Button
  14. {
  15. get { return Control as ButtonBase; }
  16. }
  17. /// <summary>
  18. /// Gets or sets a value that indicates whether the control resizes based on its contents.
  19. /// Wraps the <see cref="System.Windows.Forms.ButtonBase.AutoSize"/> property.
  20. /// </summary>
  21. [DefaultValue(true)]
  22. [Category("Behavior")]
  23. public virtual bool AutoSize
  24. {
  25. get { return Button.AutoSize; }
  26. set { Button.AutoSize = value; }
  27. }
  28. /// <summary>
  29. /// Gets or sets the image that is displayed on a button control.
  30. /// Wraps the <see cref="System.Windows.Forms.ButtonBase.Image"/> property.
  31. /// </summary>
  32. [Category("Appearance")]
  33. public Image Image
  34. {
  35. get { return Button.Image; }
  36. set { Button.Image = value; }
  37. }
  38. /// <summary>
  39. /// Gets or sets the alignment of the image on the button control.
  40. /// Wraps the <see cref="System.Windows.Forms.ButtonBase.ImageAlign"/> property.
  41. /// </summary>
  42. [DefaultValue(ContentAlignment.MiddleCenter)]
  43. [Category("Appearance")]
  44. public ContentAlignment ImageAlign
  45. {
  46. get { return Button.ImageAlign; }
  47. set { Button.ImageAlign = value; }
  48. }
  49. /// <summary>
  50. /// Gets or sets the alignment of the text on the button control.
  51. /// Wraps the <see cref="System.Windows.Forms.ButtonBase.TextAlign"/> property.
  52. /// </summary>
  53. [DefaultValue(ContentAlignment.MiddleLeft)]
  54. [Category("Appearance")]
  55. public virtual ContentAlignment TextAlign
  56. {
  57. get { return Button.TextAlign; }
  58. set { Button.TextAlign = value; }
  59. }
  60. /// <summary>
  61. /// Gets or sets the position of text and image relative to each other.
  62. /// Wraps the <see cref="System.Windows.Forms.ButtonBase.TextImageRelation"/> property.
  63. /// </summary>
  64. [DefaultValue(TextImageRelation.Overlay)]
  65. [Category("Appearance")]
  66. public TextImageRelation TextImageRelation
  67. {
  68. get { return Button.TextImageRelation; }
  69. set { Button.TextImageRelation = value; }
  70. }
  71. #endregion
  72. #region Protected Methods
  73. /// <inheritdoc/>
  74. protected override object GetValue()
  75. {
  76. return null;
  77. }
  78. #endregion
  79. #region Public Methods
  80. /// <inheritdoc/>
  81. public override void Serialize(FRWriter writer)
  82. {
  83. ButtonBaseControl c = writer.DiffObject as ButtonBaseControl;
  84. base.Serialize(writer);
  85. if (AutoSize != c.AutoSize)
  86. writer.WriteBool("AutoSize", AutoSize);
  87. if (!writer.AreEqual(Image, c.Image))
  88. writer.WriteValue("Image", Image);
  89. if (ImageAlign != c.ImageAlign)
  90. writer.WriteValue("ImageAlign", ImageAlign);
  91. if (TextAlign != c.TextAlign)
  92. writer.WriteValue("TextAlign", TextAlign);
  93. if (TextImageRelation != c.TextImageRelation)
  94. writer.WriteValue("TextImageRelation", TextImageRelation);
  95. }
  96. #endregion
  97. }
  98. }