ComponentEditorPage.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. //
  2. // System.Windows.Forms.Design.ComponentEditorPage.cs
  3. //
  4. // Author:
  5. // Andreas Nahr ([email protected])
  6. //
  7. using System.ComponentModel;
  8. using System.Drawing;
  9. namespace System.Windows.Forms.Design
  10. {
  11. public abstract class ComponentEditorPage : Panel
  12. {
  13. private bool commitOnDeactivate = false;
  14. private IComponent component;
  15. private bool firstActivate = true;
  16. private Icon icon;
  17. private int loading = 0;
  18. private bool loadRequired = false;
  19. private IComponentEditorPageSite pageSite;
  20. public ComponentEditorPage ()
  21. {
  22. }
  23. public bool CommitOnDeactivate {
  24. get { return commitOnDeactivate; }
  25. set { commitOnDeactivate = value; }
  26. }
  27. protected IComponent Component {
  28. get { return component; }
  29. set { component = value; }
  30. }
  31. [MonoTODO ("Find out what this does.")]
  32. protected override CreateParams CreateParams {
  33. get {
  34. throw new NotImplementedException ();
  35. }
  36. }
  37. protected bool FirstActivate {
  38. get { return firstActivate; }
  39. set { firstActivate = value; }
  40. }
  41. public Icon Icon {
  42. get { return icon; }
  43. set { icon = value; }
  44. }
  45. protected int Loading {
  46. get { return loading; }
  47. set { loading = value; }
  48. }
  49. protected bool LoadRequired {
  50. get { return loadRequired; }
  51. set { loadRequired = value; }
  52. }
  53. protected IComponentEditorPageSite PageSite {
  54. get { return pageSite; }
  55. set { pageSite = value; }
  56. }
  57. public virtual string Title {
  58. get { return base.Text; }
  59. }
  60. public virtual void Activate ()
  61. {
  62. Visible = true;
  63. firstActivate = false;
  64. if (loadRequired) {
  65. EnterLoadingMode ();
  66. LoadComponent ();
  67. ExitLoadingMode ();
  68. }
  69. }
  70. public virtual void ApplyChanges ()
  71. {
  72. SaveComponent ();
  73. }
  74. public virtual void Deactivate ()
  75. {
  76. Visible = false;
  77. }
  78. protected void EnterLoadingMode ()
  79. {
  80. loading++;
  81. }
  82. protected void ExitLoadingMode ()
  83. {
  84. loading--;
  85. }
  86. public virtual Control GetControl ()
  87. {
  88. return this;
  89. }
  90. protected IComponent GetSelectedComponent ()
  91. {
  92. return component;
  93. }
  94. protected bool IsFirstActivate ()
  95. {
  96. return firstActivate;
  97. }
  98. protected bool IsLoading ()
  99. {
  100. return (loading != 0);
  101. }
  102. public virtual bool IsPageMessage (ref Message msg)
  103. {
  104. return PreProcessMessage (ref msg);
  105. }
  106. protected abstract void LoadComponent ();
  107. [MonoTODO ("Find out what this does.")]
  108. public virtual void OnApplyComplete ()
  109. {
  110. }
  111. protected virtual void ReloadComponent ()
  112. {
  113. loadRequired = true;
  114. }
  115. protected abstract void SaveComponent ();
  116. public virtual void SetComponent (IComponent component)
  117. {
  118. this.component = component;
  119. ReloadComponent ();
  120. }
  121. [MonoTODO ("Find out what this does.")]
  122. protected virtual void SetDirty ()
  123. {
  124. }
  125. public virtual void SetSite (IComponentEditorPageSite site)
  126. {
  127. pageSite = site;
  128. pageSite.GetControl ().Controls.Add (this);
  129. }
  130. public virtual void ShowHelp ()
  131. {
  132. }
  133. public virtual bool SupportsHelp ()
  134. {
  135. return false;
  136. }
  137. }
  138. }