Style.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /**
  2. * Project : Mono
  3. * Namespace : System.Web.UI.MobileControls
  4. * Class : Style
  5. * Author : Gaurav Vaish
  6. *
  7. * Copyright : 2003 with Gaurav Vaish, and with
  8. * Ximian Inc
  9. */
  10. using System.Drawing;
  11. using System.Web.UI;
  12. using System.Web.Mobile;
  13. namespace System.Web.UI.MobileControls
  14. {
  15. public class Style : IParserAccessor, ITemplateable, IStateManager,
  16. ICloneable
  17. {
  18. private BooleanOption bold = BooleanOption.NotSet;
  19. private BooleanOption italic = BooleanOption.NotSet;
  20. private Alignment alignment = Alignment.NotSet;
  21. private Color backColor = Color.Empty;
  22. private Color foreColor = Color.Empty;
  23. private string fontName = String.Empty;
  24. private FontSize fontSize = FontSize.NotSet;
  25. private Wrapping wrapping = Wrapping.NotSet;
  26. private bool marked = false;
  27. private bool checkedStyleRef = false;
  28. private MobileControl control = null;
  29. private DeviceSpecific deviceSpecific;
  30. private FontInfo font;
  31. private Style referredStyle;
  32. private StateBag state;
  33. public Style()
  34. {
  35. }
  36. public object this[object key]
  37. {
  38. get
  39. {
  40. throw new NotImplementedException();
  41. }
  42. set
  43. {
  44. throw new NotImplementedException();
  45. }
  46. }
  47. public object this[object key, bool inherit]
  48. {
  49. get
  50. {
  51. throw new NotImplementedException();
  52. }
  53. }
  54. public Alignment Alignment
  55. {
  56. get
  57. {
  58. return this.alignment;
  59. }
  60. set
  61. {
  62. this.alignment = value;
  63. }
  64. }
  65. public Color BackColor
  66. {
  67. get
  68. {
  69. return this.backColor;
  70. }
  71. set
  72. {
  73. this.backColor = value;
  74. }
  75. }
  76. public DeviceSpecific DeviceSpecific
  77. {
  78. get
  79. {
  80. return deviceSpecific;
  81. }
  82. set
  83. {
  84. deviceSpecific = value;
  85. }
  86. }
  87. public FontInfo Font
  88. {
  89. get
  90. {
  91. if(font == null)
  92. {
  93. font = new FontInfo(this);
  94. }
  95. return font;
  96. }
  97. }
  98. public Color ForeColor
  99. {
  100. get
  101. {
  102. return this.foreColor;
  103. }
  104. set
  105. {
  106. this.foreColor = value;
  107. }
  108. }
  109. public bool IsTemlpated
  110. {
  111. get
  112. {
  113. if(this.deviceSpecific != null)
  114. {
  115. return deviceSpecific.HasTemplates;
  116. } else if(ReferredStyle != null)
  117. {
  118. return ReferredStyle.IsTemlpated;
  119. }
  120. return false;
  121. }
  122. }
  123. internal Style ReferredStyle
  124. {
  125. get
  126. {
  127. throw new NotImplementedException();
  128. }
  129. }
  130. internal BooleanOption Bold
  131. {
  132. get
  133. {
  134. return this.bold;
  135. }
  136. set
  137. {
  138. this.bold = value;
  139. }
  140. }
  141. internal BooleanOption Italic
  142. {
  143. get
  144. {
  145. return this.italic;
  146. }
  147. set
  148. {
  149. this.italic = value;
  150. }
  151. }
  152. internal string FontName
  153. {
  154. get
  155. {
  156. return this.fontName;
  157. }
  158. set
  159. {
  160. this.fontName = value;
  161. }
  162. }
  163. internal FontSize FontSize
  164. {
  165. get
  166. {
  167. return this.fontSize;
  168. }
  169. set
  170. {
  171. this.fontSize = value;
  172. }
  173. }
  174. public MobileControl Control
  175. {
  176. get
  177. {
  178. return this.control;
  179. }
  180. set
  181. {
  182. this.control = value;
  183. }
  184. }
  185. protected internal StateBag State
  186. {
  187. get
  188. {
  189. if(this.state == null)
  190. {
  191. this.state = new StateBag();
  192. if(((IStateManager)this).IsTrackingViewState)
  193. {
  194. ((IStateManager)state).TrackViewState();
  195. }
  196. }
  197. return this.state;
  198. }
  199. }
  200. internal void Refresh()
  201. {
  202. this.referredStyle = null;
  203. this.checkedStyleRef = false;
  204. }
  205. void IParserAccessor.AddParsedSubObject(object obj)
  206. {
  207. if(obj is DeviceSpecific)
  208. {
  209. DeviceSpecific ds = (DeviceSpecific) obj;
  210. if(this.DeviceSpecific == null)
  211. this.DeviceSpecific = ds;
  212. else
  213. {
  214. throw new ArgumentException("MobileControl" +
  215. "_NoMultipleDeviceSpecifics");
  216. }
  217. }
  218. }
  219. void IStateManager.LoadViewState(object state)
  220. {
  221. if(state != null)
  222. {
  223. this.Refresh();
  224. ((IStateManager)State).LoadViewState(state);
  225. }
  226. }
  227. object IStateManager.SaveViewState()
  228. {
  229. if(this.state != null)
  230. {
  231. return ((IStateManager)state).SaveViewState();
  232. }
  233. return null;
  234. }
  235. bool IStateManager.IsTrackingViewState
  236. {
  237. get
  238. {
  239. return this.marked;
  240. }
  241. }
  242. void IStateManager.TrackViewState()
  243. {
  244. this.marked = true;
  245. }
  246. public object Clone()
  247. {
  248. throw new NotImplementedException();
  249. }
  250. }
  251. }