using System.Windows.Forms;
using System.ComponentModel;
using FastReport.Forms;

namespace FastReport.Design.PageDesigners
{
#if !DEBUG
    [DesignTimeVisible(false)]
#endif
    internal class PageDesignerBase : Panel, IDesignerPlugin
    {
        #region Fields

        private Designer designer;
        private PageBase page;
        private bool locked;
        private bool isInsertingObject;

        #endregion

        #region Properties

        public PageBase Page
        {
            get { return page; }
            set { page = value; }
        }

        public Designer Designer
        {
            get { return designer; }
        }

        public bool Locked
        {
            get { return locked; }
        }

        public bool IsInsertingObject
        {
            get { return isInsertingObject; }
            set { isInsertingObject = value; }
        }

        public Report Report
        {
            get { return Page.Report; }
        }

        public string PluginName
        {
            get { return Name; }
        }

        public virtual float Zoom
        {
            get { return 1; }
            set { }
        }
        #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 void Paste(ObjectCollection list, InsertFrom source)
        {
        }

        public virtual void CancelPaste()
        {
        }

        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()
        {
            this.designer = designer;
            isInsertingObject = false;
        }
    }
}
