DeviceSpecific.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /**
  2. * Project : Mono
  3. * Namespace : System.Web.UI.MobileControls
  4. * Class : DeviceSpecific
  5. * Author : Gaurav Vaish
  6. *
  7. * Copyright : 2003 with Gaurav Vaish, and with
  8. * Ximian Inc
  9. */
  10. using System.Collections;
  11. using System.Web.UI;
  12. using System.Web.Mobile;
  13. namespace System.Web.UI.MobileControls
  14. {
  15. public class DeviceSpecific : Control
  16. {
  17. private DeviceSpecificChoiceCollection choices;
  18. private TemplateControl closestTemplateControl = null;
  19. private bool haveSelectedChoice = false;
  20. private object owner;
  21. private DeviceSpecificChoice selectedChoice;
  22. public DeviceSpecific()
  23. {
  24. }
  25. internal void SetOwner(object owner)
  26. {
  27. this.owner = owner;
  28. }
  29. internal void SetDesignerChoice(DeviceSpecificChoice choice)
  30. {
  31. this.selectedChoice = choice;
  32. this.haveSelectedChoice = true;
  33. }
  34. internal void ApplyProperties()
  35. {
  36. if(SelectedChoice != null)
  37. {
  38. SelectedChoice.ApplyProperties();
  39. }
  40. }
  41. public new event EventHandler DataBinding
  42. {
  43. add
  44. {
  45. base.DataBinding += value;
  46. }
  47. remove
  48. {
  49. base.DataBinding -= value;
  50. }
  51. }
  52. public new event EventHandler Disposed
  53. {
  54. add
  55. {
  56. base.Disposed += value;
  57. }
  58. remove
  59. {
  60. base.Disposed -= value;
  61. }
  62. }
  63. public new event EventHandler Init
  64. {
  65. add
  66. {
  67. base.Init += value;
  68. }
  69. remove
  70. {
  71. base.Init -= value;
  72. }
  73. }
  74. public new event EventHandler Load
  75. {
  76. add
  77. {
  78. base.Load += value;
  79. }
  80. remove
  81. {
  82. base.Load -= value;
  83. }
  84. }
  85. public new event EventHandler PreRender
  86. {
  87. add
  88. {
  89. base.PreRender += value;
  90. }
  91. remove
  92. {
  93. base.PreRender -= value;
  94. }
  95. }
  96. public new event EventHandler Unload
  97. {
  98. add
  99. {
  100. base.Unload += value;
  101. }
  102. remove
  103. {
  104. base.Unload -= value;
  105. }
  106. }
  107. public DeviceSpecificChoiceCollection Choices
  108. {
  109. get
  110. {
  111. if(choices == null)
  112. {
  113. choices = new DeviceSpecificChoiceCollection(this);
  114. }
  115. return choices;
  116. }
  117. }
  118. public TemplateControl ClosestTemplateControl
  119. {
  120. get
  121. {
  122. if(closestTemplateControl == null)
  123. {
  124. MobileControl ctrl = null;
  125. if(Owner is System.Web.UI.MobileControls.Style)
  126. {
  127. ctrl = ((System.Web.UI.MobileControls.Style)Owner).Control;
  128. } else
  129. {
  130. ctrl = (MobileControl) Owner;
  131. }
  132. closestTemplateControl = ctrl.FindClosestTemplateControl();
  133. }
  134. return closestTemplateControl;
  135. }
  136. }
  137. public override bool EnableViewState
  138. {
  139. get
  140. {
  141. return base.EnableViewState;
  142. }
  143. }
  144. public bool HasTemplates
  145. {
  146. get
  147. {
  148. if(SelectedChoice != null)
  149. {
  150. return SelectedChoice.HasTemplates;
  151. }
  152. return false;
  153. }
  154. }
  155. public MobilePage MobilePage
  156. {
  157. get
  158. {
  159. throw new NotImplementedException();
  160. }
  161. }
  162. public object Owner
  163. {
  164. get
  165. {
  166. return this.owner;
  167. }
  168. }
  169. public DeviceSpecificChoice SelectedChoice
  170. {
  171. get
  172. {
  173. throw new NotImplementedException();
  174. }
  175. }
  176. public override bool Visible
  177. {
  178. get
  179. {
  180. return base.Visible;
  181. }
  182. }
  183. protected override void AddParsedSubObject(object obj)
  184. {
  185. if(obj is DeviceSpecificChoice)
  186. {
  187. DeviceSpecificChoice dsc = (DeviceSpecificChoice)obj;
  188. Choices.Add(dsc);
  189. }
  190. }
  191. public ITemplate GetTemplate(string templateName)
  192. {
  193. ITemplate retVal = null;
  194. if(SelectedChoice != null)
  195. {
  196. retVal = (ITemplate) SelectedChoice.Templates[templateName];
  197. }
  198. return retVal;
  199. }
  200. }
  201. }