PageRenderTime 97ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/IZWebFileManager/BorderedPanel.cs

http://izwebfilemanager.googlecode.com/
C# | 603 lines | 472 code | 88 blank | 43 comment | 87 complexity | 27f17444d9c7a2e0e08812f7109c51fc MD5 | raw file
  1. // Copyright (C) 2006 Igor Zelmanovich <izwebfilemanager@gmail.com>
  2. //
  3. // This program is free software; you can redistribute it and/or modify
  4. // it under the terms of the GNU General Public License as published by
  5. // the Free Software Foundation; either version 2 of the License, or
  6. // (at your option) any later version.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program; if not, write to the Free Software
  15. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. using System;
  17. using System.Collections.Generic;
  18. using System.ComponentModel;
  19. using System.Text;
  20. using System.Web;
  21. using System.Web.UI;
  22. using System.Web.UI.WebControls;
  23. using System.Drawing.Design;
  24. using System.Diagnostics.CodeAnalysis;
  25. using System.Drawing;
  26. using System.Globalization;
  27. namespace IZ.WebFileManager
  28. {
  29. [ToolboxData ("<{0}:IZPanel runat=\"server\" width=\"125px\" height=\"50px\"></{0}:IZPanel>")]
  30. [PersistChildren (true)]
  31. [ParseChildren (false)]
  32. public class BorderedPanel : Panel
  33. {
  34. #region Fields
  35. BorderedPanelStyle _hoverSyle;
  36. BorderedPanelStyle _pressedSyle;
  37. string _hoverCssClass;
  38. string _pressedCssClass;
  39. #endregion
  40. #region Properties
  41. [Category ("Appearance")]
  42. [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
  43. public BorderedPanelStyle HoverSyle {
  44. get {
  45. if (_hoverSyle == null) {
  46. _hoverSyle = new BorderedPanelStyle ();
  47. if (IsTrackingViewState)
  48. ((IStateManager) _hoverSyle).TrackViewState ();
  49. }
  50. return _hoverSyle;
  51. }
  52. }
  53. [Category ("Appearance")]
  54. [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
  55. public BorderedPanelStyle PressedSyle {
  56. get {
  57. if (_pressedSyle == null) {
  58. _pressedSyle = new BorderedPanelStyle ();
  59. if (IsTrackingViewState)
  60. ((IStateManager) _pressedSyle).TrackViewState ();
  61. }
  62. return _pressedSyle;
  63. }
  64. }
  65. [DefaultValue (typeof (Color), "")]
  66. [Category ("Appearance")]
  67. public Color OuterBorderBackColor {
  68. get {
  69. if (ControlStyleCreated)
  70. return ((BorderedPanelStyle) ControlStyle).OuterBorderBackColor;
  71. return Color.Empty;
  72. }
  73. set { ((BorderedPanelStyle) ControlStyle).OuterBorderBackColor = value; }
  74. }
  75. [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
  76. [UrlProperty]
  77. [DefaultValue ("")]
  78. [Category ("Appearance")]
  79. [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))]
  80. public string OuterBorderBottomImageUrl {
  81. get { return !ControlStyleCreated ? String.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderBottomImageUrl; }
  82. set { ((BorderedPanelStyle) ControlStyle).OuterBorderBottomImageUrl = value; }
  83. }
  84. [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
  85. [UrlProperty]
  86. [DefaultValue ("")]
  87. [Category ("Appearance")]
  88. [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))]
  89. public string OuterBorderLeftImageUrl {
  90. get { return !ControlStyleCreated ? String.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderLeftImageUrl; }
  91. set { ((BorderedPanelStyle) ControlStyle).OuterBorderLeftImageUrl = value; }
  92. }
  93. [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
  94. [UrlProperty]
  95. [DefaultValue ("")]
  96. [Category ("Appearance")]
  97. [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))]
  98. public string OuterBorderLeftBottomCornerImageUrl {
  99. get { return !ControlStyleCreated ? String.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderLeftBottomCornerImageUrl; }
  100. set { ((BorderedPanelStyle) ControlStyle).OuterBorderLeftBottomCornerImageUrl = value; }
  101. }
  102. [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
  103. [UrlProperty]
  104. [DefaultValue ("")]
  105. [Category ("Appearance")]
  106. [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))]
  107. public string OuterBorderLeftTopCornerImageUrl {
  108. get { return !ControlStyleCreated ? String.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderLeftTopCornerImageUrl; }
  109. set { ((BorderedPanelStyle) ControlStyle).OuterBorderLeftTopCornerImageUrl = value; }
  110. }
  111. [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
  112. [UrlProperty]
  113. [DefaultValue ("")]
  114. [Category ("Appearance")]
  115. [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))]
  116. public string OuterBorderRightImageUrl {
  117. get { return !ControlStyleCreated ? String.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderRightImageUrl; }
  118. set { ((BorderedPanelStyle) ControlStyle).OuterBorderRightImageUrl = value; }
  119. }
  120. [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
  121. [UrlProperty]
  122. [DefaultValue ("")]
  123. [Category ("Appearance")]
  124. [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))]
  125. public string OuterBorderRightBottomCornerImageUrl {
  126. get { return !ControlStyleCreated ? String.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderRightBottomCornerImageUrl; }
  127. set { ((BorderedPanelStyle) ControlStyle).OuterBorderRightBottomCornerImageUrl = value; }
  128. }
  129. [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
  130. [UrlProperty]
  131. [DefaultValue ("")]
  132. [Category ("Appearance")]
  133. [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))]
  134. public string OuterBorderRightTopCornerImageUrl {
  135. get { return !ControlStyleCreated ? String.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderRightTopCornerImageUrl; }
  136. set { ((BorderedPanelStyle) ControlStyle).OuterBorderRightTopCornerImageUrl = value; }
  137. }
  138. [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
  139. [UrlProperty]
  140. [DefaultValue ("")]
  141. [Category ("Appearance")]
  142. [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))]
  143. public string OuterBorderTopImageUrl {
  144. get { return !ControlStyleCreated ? String.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderTopImageUrl; }
  145. set { ((BorderedPanelStyle) ControlStyle).OuterBorderTopImageUrl = value; }
  146. }
  147. [DefaultValue (OuterBorderStyle.None)]
  148. [Category ("Layout")]
  149. public OuterBorderStyle OuterBorderStyle {
  150. get { return !ControlStyleCreated ? OuterBorderStyle.None : ((BorderedPanelStyle) ControlStyle).OuterBorderStyle; }
  151. set { ((BorderedPanelStyle) ControlStyle).OuterBorderStyle = value; }
  152. }
  153. [DefaultValue (typeof (Unit), "")]
  154. [Category ("Layout")]
  155. public Unit OuterBorderBottomWidth {
  156. get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderBottomWidth; }
  157. set { ((BorderedPanelStyle) ControlStyle).OuterBorderBottomWidth = value; }
  158. }
  159. [DefaultValue (typeof (Unit), "")]
  160. [Category ("Layout")]
  161. public Unit OuterBorderTopWidth {
  162. get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderTopWidth; }
  163. set { ((BorderedPanelStyle) ControlStyle).OuterBorderTopWidth = value; }
  164. }
  165. [DefaultValue (typeof (Unit), "")]
  166. [Category ("Layout")]
  167. public Unit OuterBorderLeftWidth {
  168. get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderLeftWidth; }
  169. set { ((BorderedPanelStyle) ControlStyle).OuterBorderLeftWidth = value; }
  170. }
  171. [DefaultValue (typeof (Unit), "")]
  172. [Category ("Layout")]
  173. public Unit OuterBorderRightWidth {
  174. get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderRightWidth; }
  175. set { ((BorderedPanelStyle) ControlStyle).OuterBorderRightWidth = value; }
  176. }
  177. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  178. [Category ("Layout")]
  179. [NotifyParentProperty (true)]
  180. public Unit PaddingTop {
  181. get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).PaddingTop; }
  182. set { ((BorderedPanelStyle) ControlStyle).PaddingTop = value; }
  183. }
  184. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  185. [Category ("Layout")]
  186. [NotifyParentProperty (true)]
  187. public Unit PaddingLeft {
  188. get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).PaddingLeft; }
  189. set { ((BorderedPanelStyle) ControlStyle).PaddingLeft = value; }
  190. }
  191. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  192. [Category ("Layout")]
  193. [NotifyParentProperty (true)]
  194. public Unit PaddingBottom {
  195. get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).PaddingBottom; }
  196. set { ((BorderedPanelStyle) ControlStyle).PaddingBottom = value; }
  197. }
  198. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  199. [Category ("Layout")]
  200. [NotifyParentProperty (true)]
  201. public Unit PaddingRight {
  202. get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).PaddingRight; }
  203. set { ((BorderedPanelStyle) ControlStyle).PaddingRight = value; }
  204. }
  205. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  206. [Category ("Appearance")]
  207. [NotifyParentProperty (true)]
  208. public Unit MarginBottom {
  209. get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).MarginBottom; }
  210. set { ((BorderedPanelStyle) ControlStyle).MarginBottom = value; }
  211. }
  212. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  213. [Category ("Appearance")]
  214. [NotifyParentProperty (true)]
  215. public Unit MarginLeft {
  216. get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).MarginLeft; }
  217. set { ((BorderedPanelStyle) ControlStyle).MarginLeft = value; }
  218. }
  219. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  220. [Category ("Appearance")]
  221. [NotifyParentProperty (true)]
  222. public Unit MarginRight {
  223. get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).MarginRight; }
  224. set { ((BorderedPanelStyle) ControlStyle).MarginRight = value; }
  225. }
  226. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  227. [Category ("Appearance")]
  228. [NotifyParentProperty (true)]
  229. public Unit MarginTop {
  230. get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).MarginTop; }
  231. set { ((BorderedPanelStyle) ControlStyle).MarginTop = value; }
  232. }
  233. string OuterBorderImagesArrayName {
  234. get { return ClientID + "OuterBorder"; }
  235. }
  236. string OuterBorderHoverImagesArrayName {
  237. get { return ClientID + "OuterBorderHover"; }
  238. }
  239. string OuterBorderPressedImagesArrayName {
  240. get { return ClientID + "OuterBorderPressed"; }
  241. }
  242. #endregion
  243. protected override void OnPreRender (EventArgs e) {
  244. base.OnPreRender (e);
  245. Page.ClientScript.RegisterClientScriptResource (typeof (BorderedPanel), "IZ.WebFileManager.resources.BorderedPanel.js");
  246. bool isHeader = Page.Header != null;
  247. if (_hoverSyle != null) {
  248. if (!isHeader)
  249. throw new InvalidOperationException ("Using BorderedPanel.HoverStyle requires Page.Header to be non-null (e.g. <head runat=\"server\" />).");
  250. BorderedPanelStyle s = new BorderedPanelStyle ();
  251. s.CopyFrom (_hoverSyle);
  252. if (ControlStyleCreated)
  253. s.MergeWith (ControlStyle);
  254. Page.Header.StyleSheet.RegisterStyle (s, this);
  255. _hoverCssClass = s.RegisteredCssClass;
  256. RegisterBorderImagesArray (s, OuterBorderHoverImagesArrayName);
  257. }
  258. if (_pressedSyle != null) {
  259. if (!isHeader)
  260. throw new InvalidOperationException ("Using BorderedPanel.PressedSyle requires Page.Header to be non-null (e.g. <head runat=\"server\" />).");
  261. BorderedPanelStyle s = new BorderedPanelStyle ();
  262. s.CopyFrom (_pressedSyle);
  263. if (_hoverSyle != null)
  264. s.MergeWith (_hoverSyle);
  265. if (ControlStyleCreated)
  266. s.MergeWith (ControlStyle);
  267. Page.Header.StyleSheet.RegisterStyle (s, this);
  268. _pressedCssClass = s.RegisteredCssClass;
  269. RegisterBorderImagesArray (s, OuterBorderPressedImagesArrayName);
  270. }
  271. if (ControlStyleCreated) {
  272. if (isHeader)
  273. Page.Header.StyleSheet.RegisterStyle (ControlStyle, this);
  274. }
  275. }
  276. void RegisterBorderImagesArray (BorderedPanelStyle style, String arrayName) {
  277. Page.ClientScript.RegisterArrayDeclaration (arrayName,
  278. "'" + String.Join ("','", new string []{
  279. ResolveUrl(style.OuterBorderTopImageUrl),
  280. ResolveUrl(style.OuterBorderLeftImageUrl),
  281. ResolveUrl(style.OuterBorderRightImageUrl),
  282. ResolveUrl(style.OuterBorderBottomImageUrl),
  283. ResolveUrl(style.OuterBorderLeftTopCornerImageUrl),
  284. ResolveUrl(style.OuterBorderLeftBottomCornerImageUrl),
  285. ResolveUrl(style.OuterBorderRightTopCornerImageUrl),
  286. ResolveUrl(style.OuterBorderRightBottomCornerImageUrl)
  287. }) + "'");
  288. }
  289. protected override void AddAttributesToRender (HtmlTextWriter writer) {
  290. base.AddAttributesToRender (writer);
  291. if (OuterBorderStyle == OuterBorderStyle.None)
  292. AddClientScriptAttributes (writer);
  293. }
  294. void AddClientScriptAttributes (HtmlTextWriter writer) {
  295. if (_hoverSyle != null) {
  296. writer.AddAttribute ("onmouseover", "BorderedPanel_SetStyle('" + ClientID + "'," + OuterBorderHoverImagesArrayName + ",'" + _hoverCssClass + "')");
  297. writer.AddAttribute ("onmouseout", "BorderedPanel_RestoreStyle('" + ClientID + "')");
  298. }
  299. if (_pressedSyle != null) {
  300. writer.AddAttribute ("onmousedown", "BorderedPanel_SetStyle('" + ClientID + "'," + OuterBorderPressedImagesArrayName + ",'" + _pressedCssClass + "')");
  301. if (_hoverSyle != null)
  302. writer.AddAttribute ("onmouseup", "BorderedPanel_SetStyle('" + ClientID + "'," + OuterBorderHoverImagesArrayName + ",'" + _hoverCssClass + "')");
  303. else
  304. writer.AddAttribute ("onmouseup", "BorderedPanel_RestoreStyle('" + ClientID + "')");
  305. }
  306. }
  307. protected override void TrackViewState () {
  308. base.TrackViewState ();
  309. if (_hoverSyle != null)
  310. ((IStateManager) _hoverSyle).TrackViewState ();
  311. if (_pressedSyle != null)
  312. ((IStateManager) _pressedSyle).TrackViewState ();
  313. }
  314. protected override void LoadViewState (object savedState) {
  315. if (savedState == null)
  316. return;
  317. object [] states = (object []) savedState;
  318. base.LoadViewState (states [0]);
  319. if (states [1] != null)
  320. ((IStateManager) HoverSyle).LoadViewState (states [1]);
  321. if (states [2] != null)
  322. ((IStateManager) PressedSyle).LoadViewState (states [2]);
  323. }
  324. protected override object SaveControlState () {
  325. object [] states = new object [3];
  326. states [0] = base.SaveViewState ();
  327. if (_hoverSyle != null)
  328. states [1] = ((IStateManager) _hoverSyle).SaveViewState ();
  329. if (_pressedSyle != null)
  330. states [2] = ((IStateManager) _pressedSyle).SaveViewState ();
  331. for (int i = 0; i < states.Length; i++) {
  332. if (states [i] != null)
  333. return states;
  334. }
  335. return null;
  336. }
  337. protected override Style CreateControlStyle () {
  338. return new BorderedPanelStyle (ViewState);
  339. }
  340. public override void RenderBeginTag (HtmlTextWriter writer) {
  341. RenderBeginOuterBorder (writer);
  342. base.RenderBeginTag (writer);
  343. }
  344. public override void RenderEndTag (HtmlTextWriter writer) {
  345. base.RenderEndTag (writer);
  346. RenderEndOuterBorder (writer);
  347. }
  348. void RenderBeginOuterBorder (System.Web.UI.HtmlTextWriter writer) {
  349. if (OuterBorderStyle == OuterBorderStyle.None)
  350. return;
  351. AddClientScriptAttributes (writer);
  352. if (writer == null)
  353. throw new ArgumentNullException ("writer");
  354. if (OuterBorderBackColor != Color.Empty)
  355. writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundColor, ColorTranslator.ToHtml (OuterBorderBackColor));
  356. writer.AddStyleAttribute (HtmlTextWriterStyle.Direction, "ltr");
  357. writer.AddAttribute (HtmlTextWriterAttribute.Cellspacing, "0");
  358. writer.AddAttribute (HtmlTextWriterAttribute.Cellpadding, "0");
  359. writer.RenderBeginTag (HtmlTextWriterTag.Table);
  360. if ((OuterBorderStyle & OuterBorderStyle.Top) > 0)
  361. RenderOuterBorderTopRow (writer);
  362. writer.RenderBeginTag (HtmlTextWriterTag.Tr);
  363. if ((OuterBorderStyle & OuterBorderStyle.Left) > 0)
  364. RenderOuterBorderLeft (writer);
  365. writer.RenderBeginTag (HtmlTextWriterTag.Td);
  366. }
  367. void RenderOuterBorderTopRow (System.Web.UI.HtmlTextWriter writer) {
  368. writer.RenderBeginTag (HtmlTextWriterTag.Tr);
  369. if ((OuterBorderStyle & OuterBorderStyle.Left) > 0)
  370. RenderOuterBorderLeftTopCorner (writer);
  371. RenderOuterBorderTop (writer);
  372. if ((OuterBorderStyle & OuterBorderStyle.Right) > 0)
  373. RenderOuterBorderRightTopCorner (writer);
  374. writer.RenderEndTag ();
  375. }
  376. void RenderOuterBorderLeft (System.Web.UI.HtmlTextWriter writer) {
  377. writer.AddStyleAttribute ("background-repeat", "repeat-y");
  378. writer.AddStyleAttribute ("background-position", "center left");
  379. if (OuterBorderLeftWidth != Unit.Empty)
  380. writer.AddStyleAttribute (HtmlTextWriterStyle.Width, OuterBorderLeftWidth.ToString ());
  381. if (OuterBorderLeftImageUrl.Length > 0)
  382. writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveClientUrl (OuterBorderLeftImageUrl) + ")");
  383. if (!String.IsNullOrEmpty (ClientID))
  384. writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_BorderL");
  385. writer.RenderBeginTag (HtmlTextWriterTag.Td);
  386. writer.RenderEndTag ();
  387. }
  388. void RenderOuterBorderRightTopCorner (System.Web.UI.HtmlTextWriter writer) {
  389. writer.AddStyleAttribute ("background-repeat", "no-repeat");
  390. writer.AddStyleAttribute ("background-position", "top right");
  391. if (OuterBorderRightTopCornerImageUrl.Length > 0)
  392. writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveClientUrl (OuterBorderRightTopCornerImageUrl) + ")");
  393. if (!String.IsNullOrEmpty (ClientID))
  394. writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_BorderRT");
  395. writer.RenderBeginTag (HtmlTextWriterTag.Td);
  396. //if (OuterBorderRightTopCornerImageUrl.Length > 0)
  397. //{
  398. // writer.AddAttribute(HtmlTextWriterAttribute.Src, _urlResolver.ResolveClientUrl(OuterBorderRightTopCornerImageUrl));
  399. // writer.AddAttribute(HtmlTextWriterAttribute.Alt, "");
  400. // writer.RenderBeginTag(HtmlTextWriterTag.Img);
  401. // writer.RenderEndTag();
  402. //}
  403. writer.RenderEndTag ();
  404. }
  405. void RenderOuterBorderTop (System.Web.UI.HtmlTextWriter writer) {
  406. writer.AddStyleAttribute ("background-repeat", "repeat-x");
  407. writer.AddStyleAttribute ("background-position", "top center");
  408. if (OuterBorderTopWidth != Unit.Empty)
  409. writer.AddStyleAttribute (HtmlTextWriterStyle.Height, OuterBorderTopWidth.ToString ());
  410. if (OuterBorderTopImageUrl.Length > 0)
  411. writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveClientUrl (OuterBorderTopImageUrl) + ")");
  412. if (!String.IsNullOrEmpty (ClientID))
  413. writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_BorderT");
  414. writer.RenderBeginTag (HtmlTextWriterTag.Td);
  415. writer.RenderEndTag ();
  416. }
  417. void RenderOuterBorderLeftTopCorner (System.Web.UI.HtmlTextWriter writer) {
  418. writer.AddStyleAttribute ("background-repeat", "no-repeat");
  419. writer.AddStyleAttribute ("background-position", "top left");
  420. if (OuterBorderLeftTopCornerImageUrl.Length > 0)
  421. writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveClientUrl (OuterBorderLeftTopCornerImageUrl) + ")");
  422. if (!String.IsNullOrEmpty (ClientID))
  423. writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_BorderLT");
  424. writer.RenderBeginTag (HtmlTextWriterTag.Td);
  425. //if (OuterBorderLeftTopCornerImageUrl.Length > 0)
  426. //{
  427. // writer.AddAttribute(HtmlTextWriterAttribute.Src, _urlResolver.ResolveClientUrl(OuterBorderLeftTopCornerImageUrl));
  428. // writer.AddAttribute(HtmlTextWriterAttribute.Alt, "");
  429. // writer.RenderBeginTag(HtmlTextWriterTag.Img);
  430. // writer.RenderEndTag();
  431. //}
  432. writer.RenderEndTag ();
  433. }
  434. void RenderEndOuterBorder (System.Web.UI.HtmlTextWriter writer) {
  435. if (OuterBorderStyle == OuterBorderStyle.None)
  436. return;
  437. if (writer == null)
  438. throw new ArgumentNullException ("writer");
  439. writer.RenderEndTag ();
  440. if ((OuterBorderStyle & OuterBorderStyle.Right) > 0)
  441. RenderOuterBorderRight (writer);
  442. writer.RenderEndTag ();
  443. if ((OuterBorderStyle & OuterBorderStyle.Bottom) > 0)
  444. RenderOuterBorderBottomRow (writer);
  445. writer.RenderEndTag ();
  446. }
  447. void RenderOuterBorderBottomRow (System.Web.UI.HtmlTextWriter writer) {
  448. writer.RenderBeginTag (HtmlTextWriterTag.Tr);
  449. if ((OuterBorderStyle & OuterBorderStyle.Left) > 0)
  450. RenderOuterBorderLeftBottomCorner (writer);
  451. RenderOuterBorderBottom (writer);
  452. if ((OuterBorderStyle & OuterBorderStyle.Right) > 0)
  453. RenderOuterBorderRightBottomCorner (writer);
  454. writer.RenderEndTag ();
  455. }
  456. void RenderOuterBorderRightBottomCorner (System.Web.UI.HtmlTextWriter writer) {
  457. writer.AddStyleAttribute ("background-repeat", "no-repeat");
  458. writer.AddStyleAttribute ("background-position", "bottom right");
  459. if (OuterBorderRightBottomCornerImageUrl.Length > 0)
  460. writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveClientUrl (OuterBorderRightBottomCornerImageUrl) + ")");
  461. if (!String.IsNullOrEmpty (ClientID))
  462. writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_BorderRB");
  463. writer.RenderBeginTag (HtmlTextWriterTag.Td);
  464. //if (OuterBorderRightBottomCornerImageUrl.Length > 0)
  465. //{
  466. // writer.AddAttribute(HtmlTextWriterAttribute.Src, _urlResolver.ResolveClientUrl(OuterBorderRightBottomCornerImageUrl));
  467. // writer.AddAttribute(HtmlTextWriterAttribute.Alt, "");
  468. // writer.RenderBeginTag(HtmlTextWriterTag.Img);
  469. // writer.RenderEndTag();
  470. //}
  471. writer.RenderEndTag ();
  472. }
  473. void RenderOuterBorderBottom (System.Web.UI.HtmlTextWriter writer) {
  474. writer.AddStyleAttribute ("background-repeat", "repeat-x");
  475. writer.AddStyleAttribute ("background-position", "bottom center");
  476. if (OuterBorderBottomWidth != Unit.Empty)
  477. writer.AddStyleAttribute (HtmlTextWriterStyle.Height, OuterBorderBottomWidth.ToString ());
  478. if (OuterBorderBottomImageUrl.Length > 0)
  479. writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveClientUrl (OuterBorderBottomImageUrl) + ")");
  480. if (!String.IsNullOrEmpty (ClientID))
  481. writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_BorderB");
  482. writer.RenderBeginTag (HtmlTextWriterTag.Td);
  483. writer.RenderEndTag ();
  484. }
  485. void RenderOuterBorderLeftBottomCorner (System.Web.UI.HtmlTextWriter writer) {
  486. writer.AddStyleAttribute ("background-repeat", "no-repeat");
  487. writer.AddStyleAttribute ("background-position", "bottom left");
  488. if (OuterBorderLeftBottomCornerImageUrl.Length > 0)
  489. writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveClientUrl (OuterBorderLeftBottomCornerImageUrl) + ")");
  490. if (!String.IsNullOrEmpty (ClientID))
  491. writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_BorderLB");
  492. writer.RenderBeginTag (HtmlTextWriterTag.Td);
  493. //if (OuterBorderLeftBottomCornerImageUrl.Length > 0)
  494. //{
  495. // writer.AddAttribute(HtmlTextWriterAttribute.Src, _urlResolver.ResolveClientUrl(OuterBorderLeftBottomCornerImageUrl));
  496. // writer.AddAttribute(HtmlTextWriterAttribute.Alt, "");
  497. // writer.RenderBeginTag(HtmlTextWriterTag.Img);
  498. // writer.RenderEndTag();
  499. //}
  500. writer.RenderEndTag ();
  501. }
  502. void RenderOuterBorderRight (System.Web.UI.HtmlTextWriter writer) {
  503. writer.AddStyleAttribute ("background-repeat", "repeat-y");
  504. writer.AddStyleAttribute ("background-position", "center right");
  505. if (OuterBorderRightWidth != Unit.Empty)
  506. writer.AddStyleAttribute (HtmlTextWriterStyle.Width, OuterBorderRightWidth.ToString ());
  507. if (OuterBorderRightImageUrl.Length > 0)
  508. writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveClientUrl (OuterBorderRightImageUrl) + ")");
  509. if (!String.IsNullOrEmpty (ClientID))
  510. writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_BorderR");
  511. writer.RenderBeginTag (HtmlTextWriterTag.Td);
  512. writer.RenderEndTag ();
  513. }
  514. }
  515. }