ComponentEditorPage.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. // Permission is hereby granted, free of charge, to any person obtaining
  2. // a copy of this software and associated documentation files (the
  3. // "Software"), to deal in the Software without restriction, including
  4. // without limitation the rights to use, copy, modify, merge, publish,
  5. // distribute, sublicense, and/or sell copies of the Software, and to
  6. // permit persons to whom the Software is furnished to do so, subject to
  7. // the following conditions:
  8. //
  9. // The above copyright notice and this permission notice shall be
  10. // included in all copies or substantial portions of the Software.
  11. //
  12. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  13. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  15. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  16. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  17. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  18. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19. //
  20. // Copyright (c) 2004 Novell, Inc.
  21. //
  22. // Authors:
  23. // Andreas Nahr ([email protected])
  24. //
  25. using System.ComponentModel;
  26. using System.Drawing;
  27. namespace System.Windows.Forms.Design
  28. {
  29. public abstract class ComponentEditorPage : Panel
  30. {
  31. private bool commitOnDeactivate = false;
  32. private IComponent component;
  33. private bool firstActivate = true;
  34. private Icon icon;
  35. private int loading = 0;
  36. private bool loadRequired = false;
  37. private IComponentEditorPageSite pageSite;
  38. public ComponentEditorPage ()
  39. {
  40. }
  41. public bool CommitOnDeactivate {
  42. get { return commitOnDeactivate; }
  43. set { commitOnDeactivate = value; }
  44. }
  45. protected IComponent Component {
  46. get { return component; }
  47. set { component = value; }
  48. }
  49. [MonoTODO ("Find out what this does.")]
  50. protected override CreateParams CreateParams {
  51. get {
  52. throw new NotImplementedException ();
  53. }
  54. }
  55. protected bool FirstActivate {
  56. get { return firstActivate; }
  57. set { firstActivate = value; }
  58. }
  59. public Icon Icon {
  60. get { return icon; }
  61. set { icon = value; }
  62. }
  63. protected int Loading {
  64. get { return loading; }
  65. set { loading = value; }
  66. }
  67. protected bool LoadRequired {
  68. get { return loadRequired; }
  69. set { loadRequired = value; }
  70. }
  71. protected IComponentEditorPageSite PageSite {
  72. get { return pageSite; }
  73. set { pageSite = value; }
  74. }
  75. public virtual string Title {
  76. get { return base.Text; }
  77. }
  78. public virtual void Activate ()
  79. {
  80. Visible = true;
  81. firstActivate = false;
  82. if (loadRequired) {
  83. EnterLoadingMode ();
  84. LoadComponent ();
  85. ExitLoadingMode ();
  86. }
  87. }
  88. public virtual void ApplyChanges ()
  89. {
  90. SaveComponent ();
  91. }
  92. public virtual void Deactivate ()
  93. {
  94. Visible = false;
  95. }
  96. protected void EnterLoadingMode ()
  97. {
  98. loading++;
  99. }
  100. protected void ExitLoadingMode ()
  101. {
  102. loading--;
  103. }
  104. public virtual Control GetControl ()
  105. {
  106. return this;
  107. }
  108. protected IComponent GetSelectedComponent ()
  109. {
  110. return component;
  111. }
  112. protected bool IsFirstActivate ()
  113. {
  114. return firstActivate;
  115. }
  116. protected bool IsLoading ()
  117. {
  118. return (loading != 0);
  119. }
  120. public virtual bool IsPageMessage (ref Message msg)
  121. {
  122. return PreProcessMessage (ref msg);
  123. }
  124. protected abstract void LoadComponent ();
  125. [MonoTODO ("Find out what this does.")]
  126. public virtual void OnApplyComplete ()
  127. {
  128. }
  129. protected virtual void ReloadComponent ()
  130. {
  131. loadRequired = true;
  132. }
  133. protected abstract void SaveComponent ();
  134. public virtual void SetComponent (IComponent component)
  135. {
  136. this.component = component;
  137. ReloadComponent ();
  138. }
  139. [MonoTODO ("Find out what this does.")]
  140. protected virtual void SetDirty ()
  141. {
  142. }
  143. public virtual void SetSite (IComponentEditorPageSite site)
  144. {
  145. pageSite = site;
  146. pageSite.GetControl ().Controls.Add (this);
  147. }
  148. public virtual void ShowHelp ()
  149. {
  150. }
  151. public virtual bool SupportsHelp ()
  152. {
  153. return false;
  154. }
  155. }
  156. }