DialogPageDesigner.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using FastReport.Dialog;
  2. using FastReport.Forms;
  3. using System.Drawing;
  4. namespace FastReport.Design.PageDesigners.Dialog
  5. {
  6. internal partial class DialogPageDesigner : PageDesignerBase
  7. {
  8. #region Fields
  9. private DialogWorkspace workspace;
  10. #endregion
  11. #region Properties
  12. public DialogPage DialogPage
  13. {
  14. get { return Page as DialogPage; }
  15. }
  16. #endregion
  17. #region Private Methods
  18. private void UpdateName()
  19. {
  20. if (Page != null)//need refactor
  21. {
  22. if (Page.Name == "")
  23. Text = Page.ClassName + (Page.ZOrder + 1).ToString();
  24. else
  25. Text = Page.Name;
  26. }
  27. }
  28. #endregion
  29. #region Public Methods
  30. public override void PageActivated()
  31. {
  32. base.PageActivated();
  33. UpdatePageFormLocation();
  34. }
  35. public override void PageDeactivated()
  36. {
  37. base.PageDeactivated();
  38. HidePageForm();
  39. }
  40. public override void Paste(ObjectCollection list, InsertFrom source)
  41. {
  42. workspace.Paste(list, source);
  43. }
  44. public override void CancelPaste()
  45. {
  46. workspace.CancelPaste();
  47. }
  48. public override void SelectAll()
  49. {
  50. Designer.SelectedObjects.Clear();
  51. foreach (Base c in Page.AllObjects)
  52. {
  53. Designer.SelectedObjects.Add(c);
  54. }
  55. if (Designer.SelectedObjects.Count == 0)
  56. Designer.SelectedObjects.Add(Page);
  57. Designer.SelectionChanged(null);
  58. }
  59. #endregion
  60. #region IDesignerPlugin
  61. public override void SaveState()
  62. {
  63. Storage.SetBool("ShowGrid", DialogWorkspace.ShowGrid);
  64. Storage.SetBool("SnapToGrid", DialogWorkspace.SnapToGrid);
  65. Storage.SetFloat("SnapSize", DialogWorkspace.Grid.SnapSize);
  66. }
  67. public override void RestoreState()
  68. {
  69. DialogWorkspace.ShowGrid = Storage.GetBool("ShowGrid");
  70. DialogWorkspace.SnapToGrid = Storage.GetBool("SnapToGrid", true);
  71. DialogWorkspace.Grid.SnapSize = Storage.GetFloat("SnapSize", 4);
  72. }
  73. public override void SelectionChanged()
  74. {
  75. base.SelectionChanged();
  76. UpdateContent();
  77. }
  78. public override void UpdateContent()
  79. {
  80. if (Locked)
  81. return;
  82. base.UpdateContent();
  83. UpdateName();
  84. workspace.Refresh();
  85. }
  86. public override DesignerOptionsPage GetOptionsPage()
  87. {
  88. return new DialogPageOptions(this);
  89. }
  90. public override void UpdateDpiDependencies()
  91. {
  92. base.UpdateDpiDependencies();
  93. if (!Locked)
  94. UpdatePageFormLocation();
  95. workspace.Refresh();
  96. }
  97. #endregion
  98. public DialogPageDesigner(Designer designer) : base(designer)
  99. {
  100. Name = "Dialog";
  101. workspace = new DialogWorkspace(this);
  102. // Avalonia: need some positive size to start draw. Actual size will be set during the draw
  103. workspace.Size = new Size(1, 1);
  104. Controls.Add(workspace);
  105. BackColor = SystemColors.Window;
  106. AutoScroll = true;
  107. }
  108. }
  109. }