WebPartVerb.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. //
  2. // System.Web.UI.WebControls.WebParts.WebPartVerb.cs
  3. //
  4. // Authors:
  5. // Sanjay Gupta ([email protected])
  6. //
  7. // (C) 2004 Novell, Inc (http://www.novell.com)
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. using System.Web;
  30. using System.Web.UI;
  31. using System.ComponentModel;
  32. using System;
  33. namespace System.Web.UI.WebControls.WebParts
  34. {
  35. [TypeConverterAttribute ("System.Web.UI.WebControls.WebParts.WebPartVerbConverter, System.Web")]
  36. public class WebPartVerb : IStateManager
  37. {
  38. string clientClickHandler;
  39. WebPartEventHandler serverClickHandler;
  40. StateBag stateBag;
  41. bool isChecked = false;
  42. string description = string.Empty;
  43. bool enabled = true;
  44. string imageUrl = string.Empty;
  45. string text = string.Empty;
  46. bool visible = true;
  47. string id;
  48. public string ID {
  49. get { return id;}
  50. }
  51. public WebPartVerb (string id, string clientHandler) {
  52. this.id = id;
  53. this.clientClickHandler = clientHandler;
  54. stateBag = new StateBag ();
  55. stateBag.Add ("clientClickHandler", clientHandler);
  56. }
  57. public WebPartVerb (string id, WebPartEventHandler serverClickHandler) {
  58. this.id = id;
  59. this.serverClickHandler = serverClickHandler;
  60. stateBag = new StateBag ();
  61. stateBag.Add ("serverClickHandler", serverClickHandler);
  62. }
  63. public WebPartVerb (string id, WebPartEventHandler serverClickHandler, string clientClickHandler) {
  64. this.id = id;
  65. this.serverClickHandler = serverClickHandler;
  66. this.clientClickHandler = clientClickHandler;
  67. stateBag = new StateBag ();
  68. stateBag.Add ("serverClickHandler", serverClickHandler);
  69. stateBag.Add ("clientClickHandler", clientClickHandler);
  70. }
  71. [MonoTODO("Not implemented")]
  72. protected virtual void LoadViewState (object savedState)
  73. {
  74. throw new NotImplementedException ();
  75. }
  76. [MonoTODO("Not implemented")]
  77. protected virtual object SaveViewState()
  78. {
  79. throw new NotImplementedException ();
  80. }
  81. [MonoTODO("Not implemented")]
  82. protected virtual void TrackViewState()
  83. {
  84. throw new NotImplementedException();
  85. }
  86. [MonoTODO("Not implemented")]
  87. void IStateManager.LoadViewState (object savedState)
  88. {
  89. throw new NotImplementedException ();
  90. }
  91. [MonoTODO("Not implemented")]
  92. object IStateManager.SaveViewState ()
  93. {
  94. throw new NotImplementedException ();
  95. }
  96. [MonoTODO("Not implemented")]
  97. void IStateManager.TrackViewState ()
  98. {
  99. throw new NotImplementedException ();
  100. }
  101. [MonoTODO("Not implemented")]
  102. bool IStateManager.IsTrackingViewState {
  103. get {
  104. throw new NotImplementedException ();
  105. }
  106. }
  107. [WebSysDescriptionAttribute ("Denotes verb is checked or not."),
  108. DefaultValueAttribute (false),
  109. NotifyParentPropertyAttribute (true) ]
  110. public virtual bool Checked {
  111. get { return isChecked; }
  112. set { isChecked = value; }
  113. }
  114. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden),
  115. BrowsableAttribute (false)]
  116. public string ClientClickHandler {
  117. get { return clientClickHandler; }
  118. }
  119. [LocalizableAttribute (true),
  120. WebSysDescriptionAttribute ("Gives descriptive information about the verb"),
  121. NotifyParentPropertyAttribute (true)]
  122. //WebSysDefaultValueAttribute (string.Empty)]
  123. public virtual string Description {
  124. get { return description; }
  125. set { description = value; }
  126. }
  127. [NotifyParentPropertyAttribute (true),
  128. DefaultValueAttribute (true),
  129. WebSysDescriptionAttribute ("Determines whether verb is enabled.")]
  130. public virtual bool Enabled {
  131. get { return enabled; }
  132. set { enabled = value; }
  133. }
  134. [WebSysDescriptionAttribute ("Denotes URL of the image to be displayed for the verb"),
  135. EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, System.Design",
  136. "UITypeEditor, System.Drawing"),
  137. LocalizableAttribute (true), NotifyParentPropertyAttribute (true)]
  138. //UrlPropertyAttribute, DefaultValueAttribute (String.Empty)
  139. public string ImageUrl {
  140. get { return imageUrl; }
  141. set { imageUrl = value; }
  142. }
  143. protected virtual bool IsTrackingViewState {
  144. get { throw new NotImplementedException (); }
  145. }
  146. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden),
  147. BrowsableAttribute (false)]
  148. public WebPartEventHandler ServerClickHandler
  149. {
  150. get { return serverClickHandler; }
  151. }
  152. [WebSysDescriptionAttribute ("Denotes text to be displayed for the verb"),
  153. LocalizableAttribute (true), NotifyParentPropertyAttribute (true)]
  154. //DefaultValueAttribute (String.Empty)
  155. public virtual string Text
  156. {
  157. get { return text; }
  158. set { text = value; }
  159. }
  160. protected StateBag ViewState {
  161. get { return stateBag; }
  162. }
  163. [DefaultValueAttribute (true),
  164. WebSysDescriptionAttribute ("Denotes whether the verb is visible"),
  165. LocalizableAttribute (true), NotifyParentPropertyAttribute (true)]
  166. public bool Visible
  167. {
  168. get { return visible; }
  169. set { visible = value; }
  170. }
  171. }
  172. }