ComponentDesigner.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. //
  2. // System.ComponentModel.Design.ComponentDesigner
  3. //
  4. // Authors:
  5. // Martin Willemoes Hansen ([email protected])
  6. //
  7. // (C) 2003 Martin Willemoes Hansen
  8. //
  9. // An implementation should be derived from the description here:
  10. // "Writing Custom Designers for .NET Components"
  11. //
  12. // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/custdsgnrdotnet.asp
  13. //
  14. //
  15. //
  16. // Permission is hereby granted, free of charge, to any person obtaining
  17. // a copy of this software and associated documentation files (the
  18. // "Software"), to deal in the Software without restriction, including
  19. // without limitation the rights to use, copy, modify, merge, publish,
  20. // distribute, sublicense, and/or sell copies of the Software, and to
  21. // permit persons to whom the Software is furnished to do so, subject to
  22. // the following conditions:
  23. //
  24. // The above copyright notice and this permission notice shall be
  25. // included in all copies or substantial portions of the Software.
  26. //
  27. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  28. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  29. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  30. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  31. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  32. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  33. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  34. //
  35. using System.Collections;
  36. namespace System.ComponentModel.Design
  37. {
  38. public class ComponentDesigner : IDesigner, IDisposable, IDesignerFilter
  39. {
  40. protected sealed class ShadowPropertyCollection
  41. {
  42. Hashtable collection;
  43. public object this[string propertyName] {
  44. get {
  45. if (collection == null)
  46. return null;
  47. return collection [propertyName];
  48. }
  49. set {
  50. if (collection == null)
  51. collection = new Hashtable ();
  52. collection [propertyName] = value;
  53. }
  54. }
  55. public bool Contains (string propertyName)
  56. {
  57. if (collection == null)
  58. return false;
  59. return collection.Contains (propertyName);
  60. }
  61. }
  62. IComponent component;
  63. ShadowPropertyCollection shadow_property_collection;
  64. DesignerVerbCollection verbs;
  65. public ComponentDesigner ()
  66. {
  67. }
  68. #region Implementation of IDesignerFilter
  69. void IDesignerFilter.PostFilterAttributes (IDictionary attributes)
  70. {
  71. PostFilterAttributes (attributes);
  72. }
  73. void IDesignerFilter.PostFilterEvents (IDictionary events)
  74. {
  75. PostFilterEvents (events);
  76. }
  77. void IDesignerFilter.PostFilterProperties (IDictionary properties)
  78. {
  79. PostFilterProperties (properties);
  80. }
  81. void IDesignerFilter.PreFilterAttributes (IDictionary attributes)
  82. {
  83. PreFilterAttributes (attributes);
  84. }
  85. void IDesignerFilter.PreFilterEvents (IDictionary events)
  86. {
  87. PreFilterEvents (events);
  88. }
  89. void IDesignerFilter.PreFilterProperties (IDictionary properties)
  90. {
  91. PreFilterProperties (properties);
  92. }
  93. #endregion Implementation of IDesignerFilter
  94. public virtual ICollection AssociatedComponents
  95. {
  96. [MonoTODO]
  97. get { throw new NotImplementedException (); }
  98. }
  99. public IComponent Component
  100. {
  101. get {
  102. return component;
  103. }
  104. }
  105. public virtual DesignerVerbCollection Verbs
  106. {
  107. [MonoTODO]
  108. get {
  109. if (verbs == null)
  110. verbs = new DesignerVerbCollection();
  111. return verbs;
  112. }
  113. }
  114. public void Dispose ()
  115. {
  116. Dispose (true);
  117. GC.SuppressFinalize (this);
  118. }
  119. protected virtual void Dispose (bool disposing)
  120. {
  121. }
  122. [MonoTODO("Not implemented, currently does nothing")]
  123. public virtual void DoDefaultAction ()
  124. {
  125. }
  126. public virtual void Initialize (IComponent component)
  127. {
  128. this.component = component;
  129. }
  130. [MonoTODO]
  131. public virtual void InitializeNonDefault ()
  132. {
  133. throw new NotImplementedException ();
  134. }
  135. [MonoTODO]
  136. public virtual void OnSetComponentDefaults ()
  137. {
  138. throw new NotImplementedException ();
  139. }
  140. protected InheritanceAttribute InheritanceAttribute
  141. {
  142. [MonoTODO]
  143. get { throw new NotImplementedException (); }
  144. }
  145. protected bool Inherited
  146. {
  147. [MonoTODO]
  148. get { throw new NotImplementedException (); }
  149. }
  150. protected ShadowPropertyCollection ShadowProperties
  151. {
  152. get {
  153. if (shadow_property_collection == null)
  154. shadow_property_collection = new ShadowPropertyCollection ();
  155. return shadow_property_collection;
  156. }
  157. }
  158. [MonoTODO("No designers services are provided in Mono")]
  159. protected virtual object GetService (Type serviceType)
  160. {
  161. return null;
  162. }
  163. [MonoTODO]
  164. protected InheritanceAttribute InvokeGetInheritanceAttribute (ComponentDesigner toInvoke)
  165. {
  166. throw new NotImplementedException ();
  167. }
  168. [MonoTODO]
  169. protected virtual void PostFilterAttributes (IDictionary attributes)
  170. {
  171. throw new NotImplementedException ();
  172. }
  173. [MonoTODO]
  174. protected virtual void PostFilterEvents (IDictionary events)
  175. {
  176. throw new NotImplementedException ();
  177. }
  178. [MonoTODO]
  179. protected virtual void PostFilterProperties (IDictionary properties)
  180. {
  181. throw new NotImplementedException ();
  182. }
  183. [MonoTODO]
  184. protected virtual void PreFilterAttributes (IDictionary attributes)
  185. {
  186. throw new NotImplementedException ();
  187. }
  188. [MonoTODO]
  189. protected virtual void PreFilterEvents (IDictionary events)
  190. {
  191. throw new NotImplementedException ();
  192. }
  193. [MonoTODO]
  194. protected virtual void PreFilterProperties (IDictionary properties)
  195. {
  196. throw new NotImplementedException ();
  197. }
  198. [MonoTODO("Currently no event is raised")]
  199. protected void RaiseComponentChanged (MemberDescriptor member, object oldValue, object newValue)
  200. {
  201. // FIXME: Should notify the IComponentChangeService
  202. // that this component has changed
  203. }
  204. [MonoTODO("Currently no event is raised")]
  205. protected void RaiseComponentChanging (MemberDescriptor member)
  206. {
  207. }
  208. ~ComponentDesigner ()
  209. {
  210. }
  211. }
  212. }