/IZWebFileManager/BorderedPanel.cs
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 17using System; 18using System.Collections.Generic; 19using System.ComponentModel; 20using System.Text; 21using System.Web; 22using System.Web.UI; 23using System.Web.UI.WebControls; 24using System.Drawing.Design; 25using System.Diagnostics.CodeAnalysis; 26using System.Drawing; 27using System.Globalization; 28 29namespace IZ.WebFileManager 30{ 31 [ToolboxData ("<{0}:IZPanel runat=\"server\" width=\"125px\" height=\"50px\"></{0}:IZPanel>")] 32 [PersistChildren (true)] 33 [ParseChildren (false)] 34 public class BorderedPanel : Panel 35 { 36 #region Fields 37 38 BorderedPanelStyle _hoverSyle; 39 BorderedPanelStyle _pressedSyle; 40 string _hoverCssClass; 41 string _pressedCssClass; 42 43 #endregion 44 45 #region Properties 46 47 [Category ("Appearance")] 48 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)] 49 public BorderedPanelStyle HoverSyle { 50 get { 51 if (_hoverSyle == null) { 52 _hoverSyle = new BorderedPanelStyle (); 53 if (IsTrackingViewState) 54 ((IStateManager) _hoverSyle).TrackViewState (); 55 } 56 return _hoverSyle; 57 } 58 59 } 60 61 [Category ("Appearance")] 62 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)] 63 public BorderedPanelStyle PressedSyle { 64 get { 65 if (_pressedSyle == null) { 66 _pressedSyle = new BorderedPanelStyle (); 67 if (IsTrackingViewState) 68 ((IStateManager) _pressedSyle).TrackViewState (); 69 } 70 return _pressedSyle; 71 } 72 73 } 74 75 [DefaultValue (typeof (Color), "")] 76 [Category ("Appearance")] 77 public Color OuterBorderBackColor { 78 get { 79 if (ControlStyleCreated) 80 return ((BorderedPanelStyle) ControlStyle).OuterBorderBackColor; 81 return Color.Empty; 82 } 83 set { ((BorderedPanelStyle) ControlStyle).OuterBorderBackColor = value; } 84 } 85 86 [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")] 87 [UrlProperty] 88 [DefaultValue ("")] 89 [Category ("Appearance")] 90 [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))] 91 public string OuterBorderBottomImageUrl { 92 get { return !ControlStyleCreated ? String.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderBottomImageUrl; } 93 set { ((BorderedPanelStyle) ControlStyle).OuterBorderBottomImageUrl = value; } 94 } 95 96 [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")] 97 [UrlProperty] 98 [DefaultValue ("")] 99 [Category ("Appearance")] 100 [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))] 101 public string OuterBorderLeftImageUrl { 102 get { return !ControlStyleCreated ? String.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderLeftImageUrl; } 103 set { ((BorderedPanelStyle) ControlStyle).OuterBorderLeftImageUrl = value; } 104 } 105 106 [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")] 107 [UrlProperty] 108 [DefaultValue ("")] 109 [Category ("Appearance")] 110 [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))] 111 public string OuterBorderLeftBottomCornerImageUrl { 112 get { return !ControlStyleCreated ? String.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderLeftBottomCornerImageUrl; } 113 set { ((BorderedPanelStyle) ControlStyle).OuterBorderLeftBottomCornerImageUrl = value; } 114 } 115 116 [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")] 117 [UrlProperty] 118 [DefaultValue ("")] 119 [Category ("Appearance")] 120 [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))] 121 public string OuterBorderLeftTopCornerImageUrl { 122 get { return !ControlStyleCreated ? String.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderLeftTopCornerImageUrl; } 123 set { ((BorderedPanelStyle) ControlStyle).OuterBorderLeftTopCornerImageUrl = value; } 124 } 125 126 [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")] 127 [UrlProperty] 128 [DefaultValue ("")] 129 [Category ("Appearance")] 130 [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))] 131 public string OuterBorderRightImageUrl { 132 get { return !ControlStyleCreated ? String.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderRightImageUrl; } 133 set { ((BorderedPanelStyle) ControlStyle).OuterBorderRightImageUrl = value; } 134 } 135 136 [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")] 137 [UrlProperty] 138 [DefaultValue ("")] 139 [Category ("Appearance")] 140 [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))] 141 public string OuterBorderRightBottomCornerImageUrl { 142 get { return !ControlStyleCreated ? String.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderRightBottomCornerImageUrl; } 143 set { ((BorderedPanelStyle) ControlStyle).OuterBorderRightBottomCornerImageUrl = value; } 144 } 145 146 [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")] 147 [UrlProperty] 148 [DefaultValue ("")] 149 [Category ("Appearance")] 150 [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))] 151 public string OuterBorderRightTopCornerImageUrl { 152 get { return !ControlStyleCreated ? String.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderRightTopCornerImageUrl; } 153 set { ((BorderedPanelStyle) ControlStyle).OuterBorderRightTopCornerImageUrl = value; } 154 } 155 156 [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")] 157 [UrlProperty] 158 [DefaultValue ("")] 159 [Category ("Appearance")] 160 [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))] 161 public string OuterBorderTopImageUrl { 162 get { return !ControlStyleCreated ? String.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderTopImageUrl; } 163 set { ((BorderedPanelStyle) ControlStyle).OuterBorderTopImageUrl = value; } 164 } 165 166 [DefaultValue (OuterBorderStyle.None)] 167 [Category ("Layout")] 168 public OuterBorderStyle OuterBorderStyle { 169 get { return !ControlStyleCreated ? OuterBorderStyle.None : ((BorderedPanelStyle) ControlStyle).OuterBorderStyle; } 170 set { ((BorderedPanelStyle) ControlStyle).OuterBorderStyle = value; } 171 } 172 173 [DefaultValue (typeof (Unit), "")] 174 [Category ("Layout")] 175 public Unit OuterBorderBottomWidth { 176 get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderBottomWidth; } 177 set { ((BorderedPanelStyle) ControlStyle).OuterBorderBottomWidth = value; } 178 } 179 180 [DefaultValue (typeof (Unit), "")] 181 [Category ("Layout")] 182 public Unit OuterBorderTopWidth { 183 get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderTopWidth; } 184 set { ((BorderedPanelStyle) ControlStyle).OuterBorderTopWidth = value; } 185 } 186 187 [DefaultValue (typeof (Unit), "")] 188 [Category ("Layout")] 189 public Unit OuterBorderLeftWidth { 190 get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderLeftWidth; } 191 set { ((BorderedPanelStyle) ControlStyle).OuterBorderLeftWidth = value; } 192 } 193 194 [DefaultValue (typeof (Unit), "")] 195 [Category ("Layout")] 196 public Unit OuterBorderRightWidth { 197 get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).OuterBorderRightWidth; } 198 set { ((BorderedPanelStyle) ControlStyle).OuterBorderRightWidth = value; } 199 } 200 201 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] 202 [Category ("Layout")] 203 [NotifyParentProperty (true)] 204 public Unit PaddingTop { 205 get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).PaddingTop; } 206 set { ((BorderedPanelStyle) ControlStyle).PaddingTop = value; } 207 } 208 209 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] 210 [Category ("Layout")] 211 [NotifyParentProperty (true)] 212 public Unit PaddingLeft { 213 get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).PaddingLeft; } 214 set { ((BorderedPanelStyle) ControlStyle).PaddingLeft = value; } 215 } 216 217 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] 218 [Category ("Layout")] 219 [NotifyParentProperty (true)] 220 public Unit PaddingBottom { 221 get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).PaddingBottom; } 222 set { ((BorderedPanelStyle) ControlStyle).PaddingBottom = value; } 223 } 224 225 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] 226 [Category ("Layout")] 227 [NotifyParentProperty (true)] 228 public Unit PaddingRight { 229 get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).PaddingRight; } 230 set { ((BorderedPanelStyle) ControlStyle).PaddingRight = value; } 231 } 232 233 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] 234 [Category ("Appearance")] 235 [NotifyParentProperty (true)] 236 public Unit MarginBottom { 237 get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).MarginBottom; } 238 set { ((BorderedPanelStyle) ControlStyle).MarginBottom = value; } 239 } 240 241 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] 242 [Category ("Appearance")] 243 [NotifyParentProperty (true)] 244 public Unit MarginLeft { 245 get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).MarginLeft; } 246 set { ((BorderedPanelStyle) ControlStyle).MarginLeft = value; } 247 } 248 249 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] 250 [Category ("Appearance")] 251 [NotifyParentProperty (true)] 252 public Unit MarginRight { 253 get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).MarginRight; } 254 set { ((BorderedPanelStyle) ControlStyle).MarginRight = value; } 255 } 256 257 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] 258 [Category ("Appearance")] 259 [NotifyParentProperty (true)] 260 public Unit MarginTop { 261 get { return !ControlStyleCreated ? Unit.Empty : ((BorderedPanelStyle) ControlStyle).MarginTop; } 262 set { ((BorderedPanelStyle) ControlStyle).MarginTop = value; } 263 } 264 265 string OuterBorderImagesArrayName { 266 get { return ClientID + "OuterBorder"; } 267 } 268 269 string OuterBorderHoverImagesArrayName { 270 get { return ClientID + "OuterBorderHover"; } 271 } 272 273 string OuterBorderPressedImagesArrayName { 274 get { return ClientID + "OuterBorderPressed"; } 275 } 276 277 #endregion 278 279 protected override void OnPreRender (EventArgs e) { 280 base.OnPreRender (e); 281 Page.ClientScript.RegisterClientScriptResource (typeof (BorderedPanel), "IZ.WebFileManager.resources.BorderedPanel.js"); 282 283 bool isHeader = Page.Header != null; 284 285 if (_hoverSyle != null) { 286 if (!isHeader) 287 throw new InvalidOperationException ("Using BorderedPanel.HoverStyle requires Page.Header to be non-null (e.g. <head runat=\"server\" />)."); 288 BorderedPanelStyle s = new BorderedPanelStyle (); 289 s.CopyFrom (_hoverSyle); 290 if (ControlStyleCreated) 291 s.MergeWith (ControlStyle); 292 Page.Header.StyleSheet.RegisterStyle (s, this); 293 _hoverCssClass = s.RegisteredCssClass; 294 RegisterBorderImagesArray (s, OuterBorderHoverImagesArrayName); 295 } 296 297 if (_pressedSyle != null) { 298 if (!isHeader) 299 throw new InvalidOperationException ("Using BorderedPanel.PressedSyle requires Page.Header to be non-null (e.g. <head runat=\"server\" />)."); 300 BorderedPanelStyle s = new BorderedPanelStyle (); 301 s.CopyFrom (_pressedSyle); 302 if (_hoverSyle != null) 303 s.MergeWith (_hoverSyle); 304 if (ControlStyleCreated) 305 s.MergeWith (ControlStyle); 306 Page.Header.StyleSheet.RegisterStyle (s, this); 307 _pressedCssClass = s.RegisteredCssClass; 308 RegisterBorderImagesArray (s, OuterBorderPressedImagesArrayName); 309 } 310 311 if (ControlStyleCreated) { 312 if (isHeader) 313 Page.Header.StyleSheet.RegisterStyle (ControlStyle, this); 314 } 315 } 316 317 void RegisterBorderImagesArray (BorderedPanelStyle style, String arrayName) { 318 Page.ClientScript.RegisterArrayDeclaration (arrayName, 319 "'" + String.Join ("','", new string []{ 320 ResolveUrl(style.OuterBorderTopImageUrl), 321 ResolveUrl(style.OuterBorderLeftImageUrl), 322 ResolveUrl(style.OuterBorderRightImageUrl), 323 ResolveUrl(style.OuterBorderBottomImageUrl), 324 325 ResolveUrl(style.OuterBorderLeftTopCornerImageUrl), 326 ResolveUrl(style.OuterBorderLeftBottomCornerImageUrl), 327 ResolveUrl(style.OuterBorderRightTopCornerImageUrl), 328 ResolveUrl(style.OuterBorderRightBottomCornerImageUrl) 329 330 }) + "'"); 331 } 332 333 protected override void AddAttributesToRender (HtmlTextWriter writer) { 334 base.AddAttributesToRender (writer); 335 if (OuterBorderStyle == OuterBorderStyle.None) 336 AddClientScriptAttributes (writer); 337 } 338 339 void AddClientScriptAttributes (HtmlTextWriter writer) { 340 if (_hoverSyle != null) { 341 writer.AddAttribute ("onmouseover", "BorderedPanel_SetStyle('" + ClientID + "'," + OuterBorderHoverImagesArrayName + ",'" + _hoverCssClass + "')"); 342 writer.AddAttribute ("onmouseout", "BorderedPanel_RestoreStyle('" + ClientID + "')"); 343 } 344 345 if (_pressedSyle != null) { 346 writer.AddAttribute ("onmousedown", "BorderedPanel_SetStyle('" + ClientID + "'," + OuterBorderPressedImagesArrayName + ",'" + _pressedCssClass + "')"); 347 if (_hoverSyle != null) 348 writer.AddAttribute ("onmouseup", "BorderedPanel_SetStyle('" + ClientID + "'," + OuterBorderHoverImagesArrayName + ",'" + _hoverCssClass + "')"); 349 else 350 writer.AddAttribute ("onmouseup", "BorderedPanel_RestoreStyle('" + ClientID + "')"); 351 } 352 } 353 354 protected override void TrackViewState () { 355 base.TrackViewState (); 356 if (_hoverSyle != null) 357 ((IStateManager) _hoverSyle).TrackViewState (); 358 if (_pressedSyle != null) 359 ((IStateManager) _pressedSyle).TrackViewState (); 360 } 361 362 protected override void LoadViewState (object savedState) { 363 if (savedState == null) 364 return; 365 366 object [] states = (object []) savedState; 367 368 base.LoadViewState (states [0]); 369 if (states [1] != null) 370 ((IStateManager) HoverSyle).LoadViewState (states [1]); 371 if (states [2] != null) 372 ((IStateManager) PressedSyle).LoadViewState (states [2]); 373 } 374 375 protected override object SaveControlState () { 376 object [] states = new object [3]; 377 378 states [0] = base.SaveViewState (); 379 if (_hoverSyle != null) 380 states [1] = ((IStateManager) _hoverSyle).SaveViewState (); 381 if (_pressedSyle != null) 382 states [2] = ((IStateManager) _pressedSyle).SaveViewState (); 383 384 for (int i = 0; i < states.Length; i++) { 385 if (states [i] != null) 386 return states; 387 } 388 return null; 389 } 390 391 protected override Style CreateControlStyle () { 392 return new BorderedPanelStyle (ViewState); 393 } 394 395 public override void RenderBeginTag (HtmlTextWriter writer) { 396 RenderBeginOuterBorder (writer); 397 base.RenderBeginTag (writer); 398 } 399 400 public override void RenderEndTag (HtmlTextWriter writer) { 401 base.RenderEndTag (writer); 402 RenderEndOuterBorder (writer); 403 } 404 405 void RenderBeginOuterBorder (System.Web.UI.HtmlTextWriter writer) { 406 if (OuterBorderStyle == OuterBorderStyle.None) 407 return; 408 409 AddClientScriptAttributes (writer); 410 411 if (writer == null) 412 throw new ArgumentNullException ("writer"); 413 414 if (OuterBorderBackColor != Color.Empty) 415 writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundColor, ColorTranslator.ToHtml (OuterBorderBackColor)); 416 417 writer.AddStyleAttribute (HtmlTextWriterStyle.Direction, "ltr"); 418 writer.AddAttribute (HtmlTextWriterAttribute.Cellspacing, "0"); 419 writer.AddAttribute (HtmlTextWriterAttribute.Cellpadding, "0"); 420 writer.RenderBeginTag (HtmlTextWriterTag.Table); 421 422 if ((OuterBorderStyle & OuterBorderStyle.Top) > 0) 423 RenderOuterBorderTopRow (writer); 424 425 writer.RenderBeginTag (HtmlTextWriterTag.Tr); 426 427 if ((OuterBorderStyle & OuterBorderStyle.Left) > 0) 428 RenderOuterBorderLeft (writer); 429 430 writer.RenderBeginTag (HtmlTextWriterTag.Td); 431 432 } 433 434 void RenderOuterBorderTopRow (System.Web.UI.HtmlTextWriter writer) { 435 writer.RenderBeginTag (HtmlTextWriterTag.Tr); 436 437 if ((OuterBorderStyle & OuterBorderStyle.Left) > 0) 438 RenderOuterBorderLeftTopCorner (writer); 439 RenderOuterBorderTop (writer); 440 if ((OuterBorderStyle & OuterBorderStyle.Right) > 0) 441 RenderOuterBorderRightTopCorner (writer); 442 443 writer.RenderEndTag (); 444 } 445 446 void RenderOuterBorderLeft (System.Web.UI.HtmlTextWriter writer) { 447 writer.AddStyleAttribute ("background-repeat", "repeat-y"); 448 writer.AddStyleAttribute ("background-position", "center left"); 449 if (OuterBorderLeftWidth != Unit.Empty) 450 writer.AddStyleAttribute (HtmlTextWriterStyle.Width, OuterBorderLeftWidth.ToString ()); 451 if (OuterBorderLeftImageUrl.Length > 0) 452 writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveClientUrl (OuterBorderLeftImageUrl) + ")"); 453 if (!String.IsNullOrEmpty (ClientID)) 454 writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_BorderL"); 455 writer.RenderBeginTag (HtmlTextWriterTag.Td); 456 writer.RenderEndTag (); 457 } 458 459 void RenderOuterBorderRightTopCorner (System.Web.UI.HtmlTextWriter writer) { 460 writer.AddStyleAttribute ("background-repeat", "no-repeat"); 461 writer.AddStyleAttribute ("background-position", "top right"); 462 if (OuterBorderRightTopCornerImageUrl.Length > 0) 463 writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveClientUrl (OuterBorderRightTopCornerImageUrl) + ")"); 464 if (!String.IsNullOrEmpty (ClientID)) 465 writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_BorderRT"); 466 writer.RenderBeginTag (HtmlTextWriterTag.Td); 467 //if (OuterBorderRightTopCornerImageUrl.Length > 0) 468 //{ 469 // writer.AddAttribute(HtmlTextWriterAttribute.Src, _urlResolver.ResolveClientUrl(OuterBorderRightTopCornerImageUrl)); 470 // writer.AddAttribute(HtmlTextWriterAttribute.Alt, ""); 471 // writer.RenderBeginTag(HtmlTextWriterTag.Img); 472 // writer.RenderEndTag(); 473 //} 474 writer.RenderEndTag (); 475 } 476 477 void RenderOuterBorderTop (System.Web.UI.HtmlTextWriter writer) { 478 writer.AddStyleAttribute ("background-repeat", "repeat-x"); 479 writer.AddStyleAttribute ("background-position", "top center"); 480 if (OuterBorderTopWidth != Unit.Empty) 481 writer.AddStyleAttribute (HtmlTextWriterStyle.Height, OuterBorderTopWidth.ToString ()); 482 if (OuterBorderTopImageUrl.Length > 0) 483 writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveClientUrl (OuterBorderTopImageUrl) + ")"); 484 if (!String.IsNullOrEmpty (ClientID)) 485 writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_BorderT"); 486 writer.RenderBeginTag (HtmlTextWriterTag.Td); 487 writer.RenderEndTag (); 488 } 489 490 void RenderOuterBorderLeftTopCorner (System.Web.UI.HtmlTextWriter writer) { 491 writer.AddStyleAttribute ("background-repeat", "no-repeat"); 492 writer.AddStyleAttribute ("background-position", "top left"); 493 if (OuterBorderLeftTopCornerImageUrl.Length > 0) 494 writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveClientUrl (OuterBorderLeftTopCornerImageUrl) + ")"); 495 if (!String.IsNullOrEmpty (ClientID)) 496 writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_BorderLT"); 497 writer.RenderBeginTag (HtmlTextWriterTag.Td); 498 //if (OuterBorderLeftTopCornerImageUrl.Length > 0) 499 //{ 500 // writer.AddAttribute(HtmlTextWriterAttribute.Src, _urlResolver.ResolveClientUrl(OuterBorderLeftTopCornerImageUrl)); 501 // writer.AddAttribute(HtmlTextWriterAttribute.Alt, ""); 502 // writer.RenderBeginTag(HtmlTextWriterTag.Img); 503 // writer.RenderEndTag(); 504 //} 505 writer.RenderEndTag (); 506 } 507 508 void RenderEndOuterBorder (System.Web.UI.HtmlTextWriter writer) { 509 if (OuterBorderStyle == OuterBorderStyle.None) 510 return; 511 512 if (writer == null) 513 throw new ArgumentNullException ("writer"); 514 515 writer.RenderEndTag (); 516 517 if ((OuterBorderStyle & OuterBorderStyle.Right) > 0) 518 RenderOuterBorderRight (writer); 519 520 writer.RenderEndTag (); 521 522 if ((OuterBorderStyle & OuterBorderStyle.Bottom) > 0) 523 RenderOuterBorderBottomRow (writer); 524 525 writer.RenderEndTag (); 526 } 527 528 void RenderOuterBorderBottomRow (System.Web.UI.HtmlTextWriter writer) { 529 writer.RenderBeginTag (HtmlTextWriterTag.Tr); 530 531 if ((OuterBorderStyle & OuterBorderStyle.Left) > 0) 532 RenderOuterBorderLeftBottomCorner (writer); 533 RenderOuterBorderBottom (writer); 534 if ((OuterBorderStyle & OuterBorderStyle.Right) > 0) 535 RenderOuterBorderRightBottomCorner (writer); 536 537 writer.RenderEndTag (); 538 } 539 540 void RenderOuterBorderRightBottomCorner (System.Web.UI.HtmlTextWriter writer) { 541 writer.AddStyleAttribute ("background-repeat", "no-repeat"); 542 writer.AddStyleAttribute ("background-position", "bottom right"); 543 if (OuterBorderRightBottomCornerImageUrl.Length > 0) 544 writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveClientUrl (OuterBorderRightBottomCornerImageUrl) + ")"); 545 if (!String.IsNullOrEmpty (ClientID)) 546 writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_BorderRB"); 547 writer.RenderBeginTag (HtmlTextWriterTag.Td); 548 //if (OuterBorderRightBottomCornerImageUrl.Length > 0) 549 //{ 550 // writer.AddAttribute(HtmlTextWriterAttribute.Src, _urlResolver.ResolveClientUrl(OuterBorderRightBottomCornerImageUrl)); 551 // writer.AddAttribute(HtmlTextWriterAttribute.Alt, ""); 552 // writer.RenderBeginTag(HtmlTextWriterTag.Img); 553 // writer.RenderEndTag(); 554 //} 555 writer.RenderEndTag (); 556 } 557 558 void RenderOuterBorderBottom (System.Web.UI.HtmlTextWriter writer) { 559 writer.AddStyleAttribute ("background-repeat", "repeat-x"); 560 writer.AddStyleAttribute ("background-position", "bottom center"); 561 if (OuterBorderBottomWidth != Unit.Empty) 562 writer.AddStyleAttribute (HtmlTextWriterStyle.Height, OuterBorderBottomWidth.ToString ()); 563 if (OuterBorderBottomImageUrl.Length > 0) 564 writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveClientUrl (OuterBorderBottomImageUrl) + ")"); 565 if (!String.IsNullOrEmpty (ClientID)) 566 writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_BorderB"); 567 writer.RenderBeginTag (HtmlTextWriterTag.Td); 568 writer.RenderEndTag (); 569 } 570 571 void RenderOuterBorderLeftBottomCorner (System.Web.UI.HtmlTextWriter writer) { 572 writer.AddStyleAttribute ("background-repeat", "no-repeat"); 573 writer.AddStyleAttribute ("background-position", "bottom left"); 574 if (OuterBorderLeftBottomCornerImageUrl.Length > 0) 575 writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveClientUrl (OuterBorderLeftBottomCornerImageUrl) + ")"); 576 if (!String.IsNullOrEmpty (ClientID)) 577 writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_BorderLB"); 578 writer.RenderBeginTag (HtmlTextWriterTag.Td); 579 //if (OuterBorderLeftBottomCornerImageUrl.Length > 0) 580 //{ 581 // writer.AddAttribute(HtmlTextWriterAttribute.Src, _urlResolver.ResolveClientUrl(OuterBorderLeftBottomCornerImageUrl)); 582 // writer.AddAttribute(HtmlTextWriterAttribute.Alt, ""); 583 // writer.RenderBeginTag(HtmlTextWriterTag.Img); 584 // writer.RenderEndTag(); 585 //} 586 writer.RenderEndTag (); 587 } 588 589 void RenderOuterBorderRight (System.Web.UI.HtmlTextWriter writer) { 590 writer.AddStyleAttribute ("background-repeat", "repeat-y"); 591 writer.AddStyleAttribute ("background-position", "center right"); 592 if (OuterBorderRightWidth != Unit.Empty) 593 writer.AddStyleAttribute (HtmlTextWriterStyle.Width, OuterBorderRightWidth.ToString ()); 594 if (OuterBorderRightImageUrl.Length > 0) 595 writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveClientUrl (OuterBorderRightImageUrl) + ")"); 596 if (!String.IsNullOrEmpty (ClientID)) 597 writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_BorderR"); 598 writer.RenderBeginTag (HtmlTextWriterTag.Td); 599 writer.RenderEndTag (); 600 } 601 602 } 603}