123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- using FastReport.Dialog;
- using FastReport.Forms;
- using System.Drawing;
- namespace FastReport.Design.PageDesigners.Dialog
- {
- internal partial class DialogPageDesigner : PageDesignerBase
- {
- #region Fields
- private DialogWorkspace workspace;
- #endregion
- #region Properties
- public DialogPage DialogPage
- {
- get { return Page as DialogPage; }
- }
- #endregion
- #region Private Methods
- private void UpdateName()
- {
- if (Page != null)//need refactor
- {
- if (Page.Name == "")
- Text = Page.ClassName + (Page.ZOrder + 1).ToString();
- else
- Text = Page.Name;
- }
- }
- #endregion
- #region Public Methods
- public override void PageActivated()
- {
- base.PageActivated();
- UpdatePageFormLocation();
- }
- public override void PageDeactivated()
- {
- base.PageDeactivated();
- HidePageForm();
- }
- public override void Paste(ObjectCollection list, InsertFrom source)
- {
- workspace.Paste(list, source);
- }
- public override void CancelPaste()
- {
- workspace.CancelPaste();
- }
- public override void SelectAll()
- {
- Designer.SelectedObjects.Clear();
- foreach (Base c in Page.AllObjects)
- {
- Designer.SelectedObjects.Add(c);
- }
- if (Designer.SelectedObjects.Count == 0)
- Designer.SelectedObjects.Add(Page);
- Designer.SelectionChanged(null);
- }
- #endregion
- #region IDesignerPlugin
- public override void SaveState()
- {
- Storage.SetBool("ShowGrid", DialogWorkspace.ShowGrid);
- Storage.SetBool("SnapToGrid", DialogWorkspace.SnapToGrid);
- Storage.SetFloat("SnapSize", DialogWorkspace.Grid.SnapSize);
- }
- public override void RestoreState()
- {
- DialogWorkspace.ShowGrid = Storage.GetBool("ShowGrid");
- DialogWorkspace.SnapToGrid = Storage.GetBool("SnapToGrid", true);
- DialogWorkspace.Grid.SnapSize = Storage.GetFloat("SnapSize", 4);
- }
- public override void SelectionChanged()
- {
- base.SelectionChanged();
- UpdateContent();
- }
- public override void UpdateContent()
- {
- if (Locked)
- return;
- base.UpdateContent();
- UpdateName();
- workspace.Refresh();
- }
- public override DesignerOptionsPage GetOptionsPage()
- {
- return new DialogPageOptions(this);
- }
- public override void UpdateDpiDependencies()
- {
- base.UpdateDpiDependencies();
- if (!Locked)
- UpdatePageFormLocation();
- workspace.Refresh();
- }
- #endregion
- public DialogPageDesigner(Designer designer) : base(designer)
- {
- Name = "Dialog";
- workspace = new DialogWorkspace(this);
- // Avalonia: need some positive size to start draw. Actual size will be set during the draw
- workspace.Size = new Size(1, 1);
- Controls.Add(workspace);
- BackColor = SystemColors.Window;
- AutoScroll = true;
- }
- }
- }
|