2
0

DeviceSpecific.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. //
  2. // Permission is hereby granted, free of charge, to any person obtaining
  3. // a copy of this software and associated documentation files (the
  4. // "Software"), to deal in the Software without restriction, including
  5. // without limitation the rights to use, copy, modify, merge, publish,
  6. // distribute, sublicense, and/or sell copies of the Software, and to
  7. // permit persons to whom the Software is furnished to do so, subject to
  8. // the following conditions:
  9. //
  10. // The above copyright notice and this permission notice shall be
  11. // included in all copies or substantial portions of the Software.
  12. //
  13. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  15. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  17. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  18. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  19. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. //
  21. /**
  22. * Project : Mono
  23. * Namespace : System.Web.UI.MobileControls
  24. * Class : DeviceSpecific
  25. * Author : Gaurav Vaish
  26. *
  27. * Copyright : 2003 with Gaurav Vaish, and with
  28. * Ximian Inc
  29. */
  30. using System.Collections;
  31. using System.Web.UI;
  32. using System.Web.Mobile;
  33. namespace System.Web.UI.MobileControls
  34. {
  35. public class DeviceSpecific : Control
  36. {
  37. private DeviceSpecificChoiceCollection choices;
  38. private TemplateControl closestTemplateControl = null;
  39. private bool haveSelectedChoice = false;
  40. private object owner;
  41. private DeviceSpecificChoice selectedChoice;
  42. public DeviceSpecific()
  43. {
  44. }
  45. internal void SetOwner(object owner)
  46. {
  47. this.owner = owner;
  48. }
  49. internal void SetDesignerChoice(DeviceSpecificChoice choice)
  50. {
  51. this.selectedChoice = choice;
  52. this.haveSelectedChoice = true;
  53. }
  54. internal void ApplyProperties()
  55. {
  56. if(SelectedChoice != null)
  57. {
  58. SelectedChoice.ApplyProperties();
  59. }
  60. }
  61. public new event EventHandler DataBinding
  62. {
  63. add
  64. {
  65. base.DataBinding += value;
  66. }
  67. remove
  68. {
  69. base.DataBinding -= value;
  70. }
  71. }
  72. public new event EventHandler Disposed
  73. {
  74. add
  75. {
  76. base.Disposed += value;
  77. }
  78. remove
  79. {
  80. base.Disposed -= value;
  81. }
  82. }
  83. public new event EventHandler Init
  84. {
  85. add
  86. {
  87. base.Init += value;
  88. }
  89. remove
  90. {
  91. base.Init -= value;
  92. }
  93. }
  94. public new event EventHandler Load
  95. {
  96. add
  97. {
  98. base.Load += value;
  99. }
  100. remove
  101. {
  102. base.Load -= value;
  103. }
  104. }
  105. public new event EventHandler PreRender
  106. {
  107. add
  108. {
  109. base.PreRender += value;
  110. }
  111. remove
  112. {
  113. base.PreRender -= value;
  114. }
  115. }
  116. public new event EventHandler Unload
  117. {
  118. add
  119. {
  120. base.Unload += value;
  121. }
  122. remove
  123. {
  124. base.Unload -= value;
  125. }
  126. }
  127. public DeviceSpecificChoiceCollection Choices
  128. {
  129. get
  130. {
  131. if(choices == null)
  132. {
  133. choices = new DeviceSpecificChoiceCollection(this);
  134. }
  135. return choices;
  136. }
  137. }
  138. public TemplateControl ClosestTemplateControl
  139. {
  140. get
  141. {
  142. if(closestTemplateControl == null)
  143. {
  144. MobileControl ctrl = null;
  145. if(Owner is System.Web.UI.MobileControls.Style)
  146. {
  147. ctrl = ((System.Web.UI.MobileControls.Style)Owner).Control;
  148. } else
  149. {
  150. ctrl = (MobileControl) Owner;
  151. }
  152. closestTemplateControl = ctrl.FindClosestTemplateControl();
  153. }
  154. return closestTemplateControl;
  155. }
  156. }
  157. public override bool EnableViewState
  158. {
  159. get
  160. {
  161. return base.EnableViewState;
  162. }
  163. }
  164. public bool HasTemplates
  165. {
  166. get
  167. {
  168. if(SelectedChoice != null)
  169. {
  170. return SelectedChoice.HasTemplates;
  171. }
  172. return false;
  173. }
  174. }
  175. public MobilePage MobilePage
  176. {
  177. get
  178. {
  179. throw new NotImplementedException();
  180. }
  181. }
  182. public object Owner
  183. {
  184. get
  185. {
  186. return this.owner;
  187. }
  188. }
  189. public DeviceSpecificChoice SelectedChoice
  190. {
  191. get
  192. {
  193. throw new NotImplementedException();
  194. }
  195. }
  196. public override bool Visible
  197. {
  198. get
  199. {
  200. return base.Visible;
  201. }
  202. }
  203. protected override void AddParsedSubObject(object obj)
  204. {
  205. if(obj is DeviceSpecificChoice)
  206. {
  207. DeviceSpecificChoice dsc = (DeviceSpecificChoice)obj;
  208. Choices.Add(dsc);
  209. }
  210. }
  211. public ITemplate GetTemplate(string templateName)
  212. {
  213. ITemplate retVal = null;
  214. if(SelectedChoice != null)
  215. {
  216. retVal = (ITemplate) SelectedChoice.Templates[templateName];
  217. }
  218. return retVal;
  219. }
  220. }
  221. }