123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- using FastReport.Forms;
- using FastReport.Utils;
- using System.Windows.Forms;
- namespace FastReport.Design.PageDesigners
- {
- internal class PageDesignerBase : Panel, IDesignerPlugin
- {
- #region Properties
- public PageBase Page { get; set; }
- public Designer Designer { get; }
- public bool Locked { get; private set; }
- public bool IsInsertingObject { get; set; }
- public virtual Report Report => Page.Report;
- public string PluginName => Name;
- public virtual float Zoom
- {
- get { return 1; }
- set { }
- }
- private ControlStorageService storage;
- /// <summary>
- /// Gets storage service.
- /// </summary>
- public ControlStorageService Storage
- {
- get
- {
- if (storage == null)
- {
- // pass Designer as a control to get dpi from it (case: Avalonia can't get dpi correctly after disposing the control)
- storage = new ControlStorageService(Designer, "Designer," + Name);
- }
- return storage;
- }
- }
- #endregion
- #region Public Methods
- // this method is called when the page becomes active. You may, for example, modify the main menu
- // in this method.
- public virtual void PageActivated()
- {
- }
- // this method is called when the page becomes inactive. You should remove items added to the main menu
- // in this method.
- public virtual void PageDeactivated()
- {
- }
- public virtual void FillObjects(bool resetSelection)
- {
- Designer.Objects.Clear();
- Designer.Objects.Add(Page.Report);
- Designer.Objects.Add(Page);
- foreach (Base b in Page.AllObjects)
- {
- Designer.Objects.Add(b);
- }
- if (resetSelection)
- {
- Designer.SelectedObjects.Clear();
- Designer.SelectedObjects.Add(Page);
- }
- }
- public virtual bool CanCopy()
- {
- if (Designer.SelectedObjects.Count > 0)
- {
- // if at least one object can be copied, allow the operation
- foreach (Base c in Designer.SelectedObjects)
- {
- if (c.HasFlag(Flags.CanCopy))
- return true;
- }
- }
- return false;
- }
- public virtual void Copy()
- {
- Designer.Clipboard.Copy();
- }
- public virtual void Cut()
- {
- Designer.Clipboard.Cut();
- }
- public virtual bool CanPaste() => Designer.Clipboard.CanPaste;
- public virtual void Paste()
- {
- Designer.Clipboard.Paste();
- }
- public virtual bool CanUndo() => false;
- public virtual void Undo()
- {
- }
- public virtual bool CanRedo() => false;
- public virtual void Redo()
- {
- }
- public virtual void Paste(ObjectCollection list, InsertFrom source)
- {
- }
- public virtual void CancelPaste()
- {
- }
- public virtual void ResetModified()
- {
- }
- public virtual void SelectAll()
- {
- }
- public virtual void ZoomPageWidth()
- {
- }
- public virtual void ZoomWholePage()
- {
- }
- protected override void Dispose(bool disposing)
- {
- base.Dispose(disposing);
- if (disposing)
- SaveState();
- }
- #endregion
- #region IDesignerPlugin
- public virtual void Localize()
- {
- }
- public virtual void SaveState()
- {
- }
- public virtual void RestoreState()
- {
- }
- public virtual void SelectionChanged()
- {
- }
- public virtual void UpdateContent()
- {
- }
- public virtual void Lock()
- {
- Locked = true;
- }
- public virtual void Unlock()
- {
- Locked = false;
- UpdateContent();
- }
- public virtual DesignerOptionsPage GetOptionsPage()
- {
- return null;
- }
- public virtual void UpdateUIStyle()
- {
- }
- public virtual void UpdateDpiDependencies()
- {
- }
- #endregion
- public PageDesignerBase(Designer designer) : base()
- {
- Designer = designer;
- IsInsertingObject = false;
- }
- }
- }
|