DesignerToolbarBase.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using FastReport.Controls;
  2. using FastReport.DevComponents.DotNetBar;
  3. using FastReport.Forms;
  4. using FastReport.Utils;
  5. using System.ComponentModel;
  6. namespace FastReport.Design.Toolbars
  7. {
  8. /// <summary>
  9. /// Base class for all designer toolbars.
  10. /// </summary>
  11. /// <remarks>
  12. /// Use this class to write own designer's toolbar. To do this:
  13. /// <para>- in the constructor, set the <b>Name</b> property and create toolbar buttons.
  14. /// The <b>Name</b> will be used to restore toolbar's state;</para>
  15. /// <para>- override the <b>SelectionChanged</b> method. This method is called when current selection
  16. /// is changed. In this method, you should update buttons state to reflect the current selection.
  17. /// Selected objects can be accessed via <b>Designer.SelectedObjects</b> property;</para>
  18. /// <para>- override the <b>UpdateContent</b> method. This method is called when the report
  19. /// content was changed. Typically you need to do the same actions in <b>SelectionChanged</b> and
  20. /// <b>UpdateContent</b> methods;</para>
  21. /// <para>- to register a toolbar, add its type to the <see cref="DesignerPlugins"/> global collection:
  22. /// <code>
  23. /// DesignerPlugins.Add(typeof(MyToolbar));
  24. /// </code>
  25. /// </para>
  26. /// </remarks>
  27. [ToolboxItem(false)]
  28. public class DesignerToolbarBase : ToolbarBase, IDesignerPlugin
  29. {
  30. #region Properties
  31. /// <inheritdoc/>
  32. public string PluginName => Name;
  33. private ControlStorageService storage;
  34. public ControlStorageService Storage => storage ?? new ControlStorageService(this, "Designer," + Name);
  35. #endregion
  36. #region IDesignerPlugin
  37. /// <inheritdoc/>
  38. public virtual void SaveState()
  39. {
  40. }
  41. /// <inheritdoc/>
  42. public virtual void RestoreState()
  43. {
  44. }
  45. /// <inheritdoc/>
  46. public virtual void SelectionChanged()
  47. {
  48. }
  49. /// <inheritdoc/>
  50. public virtual void UpdateContent()
  51. {
  52. }
  53. /// <inheritdoc/>
  54. public void Lock()
  55. {
  56. }
  57. /// <inheritdoc/>
  58. public void Unlock()
  59. {
  60. UpdateContent();
  61. }
  62. /// <inheritdoc/>
  63. public virtual void Localize()
  64. {
  65. CustomizeItem.Text = Res.Get("Designer,Toolbar,AddOrRemove");
  66. }
  67. /// <inheritdoc/>
  68. public virtual DesignerOptionsPage GetOptionsPage()
  69. {
  70. return null;
  71. }
  72. #endregion
  73. /// <summary>
  74. /// Initializes a new instance of the <see cref="DesignerToolbarBase"/> class with default settings.
  75. /// </summary>
  76. /// <param name="designer">The report designer.</param>
  77. /// <remarks>
  78. /// You don't need to call this constructor. The designer will do this automatically.
  79. /// </remarks>
  80. public DesignerToolbarBase(Designer designer) : base(designer)
  81. {
  82. }
  83. }
  84. }