123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- using FastReport.Controls;
- using FastReport.Forms;
- using FastReport.Utils;
- using System.ComponentModel;
- namespace FastReport.Design.Toolbars
- {
- /// <summary>
- /// Base class for all designer toolbars.
- /// </summary>
- /// <remarks>
- /// Use this class to write own designer's toolbar. To do this:
- /// <para>- in the constructor, set the <b>Name</b> property and create toolbar buttons.
- /// The <b>Name</b> will be used to restore toolbar's state;</para>
- /// <para>- override the <b>SelectionChanged</b> method. This method is called when current selection
- /// is changed. In this method, you should update buttons state to reflect the current selection.
- /// Selected objects can be accessed via <b>Designer.SelectedObjects</b> property;</para>
- /// <para>- override the <b>UpdateContent</b> method. This method is called when the report
- /// content was changed. Typically you need to do the same actions in <b>SelectionChanged</b> and
- /// <b>UpdateContent</b> methods;</para>
- /// <para>- to register a toolbar, add its type to the <see cref="DesignerPlugins"/> global collection:
- /// <code>
- /// DesignerPlugins.Add(typeof(MyToolbar));
- /// </code>
- /// </para>
- /// </remarks>
- [ToolboxItem(false)]
- public class DesignerToolbarBase : ToolbarBase, IDesignerPlugin
- {
- #region Properties
- /// <inheritdoc/>
- public string PluginName => Name;
- private ControlStorageService storage;
-
- /// <summary>
- /// Gets storage service.
- /// </summary>
- public ControlStorageService Storage
- {
- get
- {
- if (storage == null)
- storage = new ControlStorageService(this, "Designer," + Name);
- return storage;
- }
- }
-
- #endregion
- #region IDesignerPlugin
- /// <inheritdoc/>
- public virtual void SaveState()
- {
- Storage.SetBool("Visible", Visible);
- Storage.SetDip("Left", Left);
- Storage.SetDip("Top", Top);
- }
- /// <inheritdoc/>
- public virtual void RestoreState()
- {
- Visible = Storage.GetBool("Visible", true);
- if (Storage.HasProperties)
- {
- Left = Storage.GetDip("Left");
- Top = Storage.GetDip("Top");
- }
- }
- /// <inheritdoc/>
- public virtual void SelectionChanged()
- {
- }
- /// <inheritdoc/>
- public virtual void UpdateContent()
- {
- }
- /// <inheritdoc/>
- public void Lock()
- {
- }
- /// <inheritdoc/>
- public void Unlock()
- {
- UpdateContent();
- }
- /// <inheritdoc/>
- public virtual void Localize()
- {
- }
- /// <inheritdoc/>
- public virtual DesignerOptionsPage GetOptionsPage()
- {
- return null;
- }
- #endregion
- /// <summary>
- /// Initializes a new instance of the <see cref="DesignerToolbarBase"/> class with default settings.
- /// </summary>
- /// <param name="designer">The report designer.</param>
- /// <remarks>
- /// You don't need to call this constructor. The designer will do this automatically.
- /// </remarks>
- public DesignerToolbarBase(Designer designer) : base(designer)
- {
- }
- }
- }
|