Style.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Drawing;
  5. using FastReport.Utils;
  6. namespace FastReport
  7. {
  8. /// <summary>
  9. /// Represents a style.
  10. /// </summary>
  11. /// <remarks>
  12. /// <para>
  13. /// Style class holds border, fill, text fill and font settings. It can be applied to any report object of
  14. /// <see cref="ReportComponentBase"/> type.
  15. /// </para>
  16. /// <para>
  17. /// The <b>Report</b> object holds list of styles in its <see cref="Report.Styles"/> property. Each style has
  18. /// unique name. To apply a style to the report component, set its <see cref="ReportComponentBase.Style"/>
  19. /// property to the style name.
  20. /// </para>
  21. /// </remarks>
  22. public class Style : StyleBase
  23. {
  24. private string name;
  25. /// <summary>
  26. /// Gets or sets a name of the style.
  27. /// </summary>
  28. /// <remarks>
  29. /// The name must be unique.
  30. /// </remarks>
  31. public string Name
  32. {
  33. get { return name; }
  34. set { name = value; }
  35. }
  36. /// <inheritdoc/>
  37. public override void Serialize(FRWriter writer)
  38. {
  39. writer.ItemName = "Style";
  40. writer.WriteStr("Name", Name);
  41. base.Serialize(writer);
  42. }
  43. /// <inheritdoc/>
  44. public override void Assign(StyleBase source)
  45. {
  46. base.Assign(source);
  47. Name = (source as Style).Name;
  48. }
  49. /// <summary>
  50. /// Creates exact copy of this <b>Style</b>.
  51. /// </summary>
  52. /// <returns>Copy of this style.</returns>
  53. public Style Clone()
  54. {
  55. Style result = new Style();
  56. result.Assign(this);
  57. return result;
  58. }
  59. /// <summary>
  60. /// Initializes a new instance of the <see cref="Style"/> class with default settings.
  61. /// </summary>
  62. public Style()
  63. {
  64. Name = "";
  65. ApplyBorder = true;
  66. ApplyFill = true;
  67. ApplyTextFill = true;
  68. ApplyFont = true;
  69. }
  70. }
  71. }