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