WebPart.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. //
  2. // System.Web.UI.WebControls.WebParts.Part.cs
  3. //
  4. // Authors:
  5. // Gaurav Vaish (gaurav[DOT]vaish[AT]gmail[DOT]com)
  6. // Sanjay Gupta ([email protected])
  7. //
  8. // (C) 2004 Gaurav Vaish (http://www.mastergaurav.org)
  9. // (C) 2004 Novell Inc., (http://www.novell.com)
  10. //
  11. //
  12. // Permission is hereby granted, free of charge, to any person obtaining
  13. // a copy of this software and associated documentation files (the
  14. // "Software"), to deal in the Software without restriction, including
  15. // without limitation the rights to use, copy, modify, merge, publish,
  16. // distribute, sublicense, and/or sell copies of the Software, and to
  17. // permit persons to whom the Software is furnished to do so, subject to
  18. // the following conditions:
  19. //
  20. // The above copyright notice and this permission notice shall be
  21. // included in all copies or substantial portions of the Software.
  22. //
  23. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  27. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  28. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  29. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  30. //
  31. #if NET_2_0
  32. using System;
  33. using System.ComponentModel;
  34. using System.Web;
  35. using System.Web.UI.WebControls;
  36. namespace System.Web.UI.WebControls.WebParts
  37. {
  38. [DesignerAttribute ("System.Web.UI.Design.WebControls.WebParts.WebPartDesigner, System.Design",
  39. "System.ComponentModel.Design.IDesigner")]
  40. public class WebPart : Part, IWebPart, IWebActionable
  41. {
  42. private bool allowClose = true;
  43. private bool allowEdit = true;
  44. private bool allowHide = true;
  45. private bool allowMinimize = true;
  46. private bool allowZoneChange = true;
  47. private bool allowHelp = true;
  48. private bool isStatic = true;
  49. private bool isStandalone = true;
  50. private bool isClosed = true;
  51. private PartChromeState chromeState = PartChromeState.Normal;
  52. private PartChromeType chromeType = PartChromeType.Default;
  53. private WebPartExportMode exportMode = WebPartExportMode.None;
  54. private WebPartHelpMode helpMode = WebPartHelpMode.Navigate;
  55. private string subtitle;
  56. private string catalogIconImageUrl;
  57. private string description;
  58. private string titleIconImageUrl;
  59. private string title;
  60. private string titleUrl;
  61. private WebPartVerbCollection verbCollection;
  62. protected WebPart()
  63. {
  64. }
  65. [WebSysDescriptionAttribute ("Determines Whether the Web Part can be closed."),
  66. DefaultValueAttribute (true), WebCategoryAttribute ("Behavior of Web Part")]
  67. //, PersonalizableAttribute
  68. public virtual bool AllowClose {
  69. get { return allowClose; }
  70. set { allowClose = value; }
  71. }
  72. [WebSysDescriptionAttribute ("Determines Whether properties of the Web Part can be changed using the EditorZone."),
  73. DefaultValueAttribute (true), WebCategoryAttribute ("Behavior of Web Part")]
  74. //, PersonalizableAttribute
  75. public virtual bool AllowEdit {
  76. get { return allowEdit; }
  77. set { allowEdit = value; }
  78. }
  79. [WebSysDescriptionAttribute ("Determines Whether properties of the Web Part can be changed using the EditorZone."),
  80. DefaultValueAttribute (true), WebCategoryAttribute ("Behavior of Web Part")]
  81. //, PersonalizableAttribute
  82. public virtual bool AllowHelp {
  83. get { return AllowHelp; }
  84. set { allowHelp = value; }
  85. }
  86. [WebSysDescriptionAttribute ("Determines Whether the Web Part can be minimized."),
  87. DefaultValueAttribute (true), WebCategoryAttribute ("Behavior of Web Part")]
  88. //, PersonalizableAttribute
  89. public virtual bool AllowMinimize {
  90. get { return allowMinimize; }
  91. set { allowMinimize = value; }
  92. }
  93. [WebSysDescriptionAttribute ("Determines Whether the Web Part can be moved to some other zone."),
  94. DefaultValueAttribute (true), WebCategoryAttribute ("Behavior of Web Part")]
  95. //, PersonalizableAttribute
  96. public virtual bool AllowZoneChange {
  97. get { return allowZoneChange; }
  98. set { allowZoneChange = value; }
  99. }
  100. [BrowsableAttribute (false),
  101. DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
  102. public bool IsClosed {
  103. get { return isClosed; }
  104. }
  105. [BrowsableAttribute (false),
  106. DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
  107. public bool IsStandalone
  108. {
  109. get { return isStandalone; }
  110. }
  111. //[PersonalizableAttribute ]
  112. public override PartChromeState ChromeState {
  113. get { return chromeState; }
  114. set {
  115. if(!Enum.IsDefined (typeof (PartChromeState), value))
  116. throw new ArgumentException ("value");
  117. chromeState = value;
  118. }
  119. }
  120. //[PersonalizableAttribute ]
  121. public override PartChromeType ChromeType {
  122. get { return chromeType; }
  123. set {
  124. if(!Enum.IsDefined (typeof (PartChromeType), value))
  125. throw new ArgumentException ("value");
  126. chromeType = value;
  127. }
  128. }
  129. [BrowsableAttribute (false),
  130. DesignerSerializationVisibilityAttribute (System.ComponentModel.DesignerSerializationVisibility.Hidden),
  131. LocalizableAttribute (true)]
  132. string IWebPart.Subtitle {
  133. get { return subtitle; }
  134. }
  135. [DefaultValueAttribute (""),
  136. EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, System.Design",
  137. "System.Drawing.Design.UITypeEditor, System.Drawing") ,
  138. WebCategoryAttribute ("Appearance of the Web Part"),
  139. WebSysDescriptionAttribute ("Specifies URL of image which is displayed in WebPart's Catalog.")]
  140. //UrlPropertyAttribute, PersonalizableAttribute
  141. string IWebPart.CatalogIconImageUrl {
  142. get { return catalogIconImageUrl; }
  143. set { catalogIconImageUrl = value; }
  144. }
  145. string IWebPart.Description {
  146. get { return description; }
  147. set { description = value; }
  148. }
  149. string IWebPart.Title {
  150. get { return title; }
  151. set { title = value; }
  152. }
  153. [DefaultValueAttribute (""),
  154. EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, System.Design",
  155. "System.Drawing.Design.UITypeEditor, System.Drawing"),
  156. WebCategoryAttribute ("Appearance of the Web Part"),
  157. WebSysDescriptionAttribute ("Specifies URL of image which is displayed in WebPart's title bar.")]
  158. //UrlPropertyAttribute, PersonalizableAttribute
  159. string IWebPart.TitleIconImageUrl
  160. {
  161. get { return titleIconImageUrl; }
  162. set { titleIconImageUrl = value; }
  163. }
  164. [DefaultValueAttribute (""),
  165. EditorAttribute ("System.Web.UI.Design.UrlEditor, System.Design",
  166. "System.Drawing.Design.UITypeEditor, System.Drawing"),
  167. WebCategoryAttribute ("Behavior of the Web Part"),
  168. WebSysDescriptionAttribute ("Specifies URL of page, containing additional information about this WebPart.")]
  169. //UrlPropertyAttribute, PersonalizableAttribute
  170. string IWebPart.TitleUrl {
  171. get { return titleUrl; }
  172. set { titleUrl = value; }
  173. }
  174. [BrowsableAttribute (false),
  175. DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
  176. WebPartVerbCollection IWebActionable.Verbs {
  177. get {
  178. if (verbCollection == null) {
  179. verbCollection = new WebPartVerbCollection ();
  180. }
  181. return verbCollection;
  182. }
  183. }
  184. }
  185. }
  186. #endif