LabelControl.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. /// Represents a standard Windows label.
  9. /// Wraps the <see cref="System.Windows.Forms.Label"/> control.
  10. /// </summary>
  11. public partial class LabelControl : DialogControl
  12. {
  13. private Label label;
  14. #region Properties
  15. /// <summary>
  16. /// Gets an internal <b>Label</b>.
  17. /// </summary>
  18. [Browsable(false)]
  19. public Label Label
  20. {
  21. get { return label; }
  22. }
  23. /// <summary>
  24. /// Gets or sets a value indicating whether the control is automatically resized to display its entire contents.
  25. /// Wraps the <see cref="System.Windows.Forms.Label.AutoSize"/> property.
  26. /// </summary>
  27. [DefaultValue(true)]
  28. [Category("Layout")]
  29. public bool AutoSize
  30. {
  31. get { return Label.AutoSize; }
  32. set { Label.AutoSize = value; }
  33. }
  34. /// <summary>
  35. /// Gets or sets the alignment of text in the label.
  36. /// Wraps the <see cref="System.Windows.Forms.Label.TextAlign"/> property.
  37. /// </summary>
  38. [DefaultValue(ContentAlignment.TopLeft)]
  39. [Category("Appearance")]
  40. public ContentAlignment TextAlign
  41. {
  42. get { return Label.TextAlign; }
  43. set { Label.TextAlign = value; }
  44. }
  45. #endregion
  46. #region Public Methods
  47. /// <inheritdoc/>
  48. public override void Serialize(FRWriter writer)
  49. {
  50. LabelControl c = writer.DiffObject as LabelControl;
  51. base.Serialize(writer);
  52. if (AutoSize != c.AutoSize)
  53. writer.WriteBool("AutoSize", AutoSize);
  54. if (TextAlign != c.TextAlign)
  55. writer.WriteValue("TextAlign", TextAlign);
  56. }
  57. #endregion
  58. /// <summary>
  59. /// Initializes a new instance of the <b>LabelControl</b> class with default settings.
  60. /// </summary>
  61. public LabelControl()
  62. {
  63. label = new Label();
  64. Control = label;
  65. Label.AutoSize = true;
  66. }
  67. }
  68. }