Panel.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**
  2. * Namespace: System.Web.UI.WebControls
  3. * Class: Panel
  4. *
  5. * Author: Gaurav Vaish
  6. * Maintainer: [email protected]
  7. * Contact: <[email protected]>, <[email protected]>
  8. * Implementation: yes
  9. * Status: 100%
  10. *
  11. * (C) Gaurav Vaish (2002)
  12. */
  13. using System;
  14. using System.ComponentModel;
  15. using System.Web;
  16. using System.Web.UI;
  17. namespace System.Web.UI.WebControls
  18. {
  19. public class Panel: WebControl
  20. {
  21. public Panel(): base(HtmlTextWriterTag.Div)
  22. {
  23. }
  24. public virtual string BackImageUrl
  25. {
  26. get
  27. {
  28. object o = ViewState["BackImageUrl"];
  29. if(o != null)
  30. return (string)o;
  31. return String.Empty;
  32. }
  33. set
  34. {
  35. ViewState["BackImageUrl"] = value;
  36. }
  37. }
  38. public virtual HorizontalAlign HorizontalAlign
  39. {
  40. get
  41. {
  42. object o = ViewState["HorizontalAlign"];
  43. if(o != null)
  44. return (HorizontalAlign)o;
  45. return HorizontalAlign.NotSet;
  46. }
  47. set
  48. {
  49. if(!Enum.IsDefined(typeof(HorizontalAlign), value))
  50. {
  51. throw new ArgumentException();
  52. }
  53. ViewState["HorizontalAlign"] = value;
  54. }
  55. }
  56. public virtual bool Wrap
  57. {
  58. get
  59. {
  60. object o = ViewState["Wrap"];
  61. if(o != null)
  62. return (bool)o;
  63. return true;
  64. }
  65. set
  66. {
  67. ViewState["Wrap"] = value;
  68. }
  69. }
  70. protected override void AddAttributesToRender(HtmlTextWriter writer)
  71. {
  72. AddAttributesToRender(writer);
  73. if(BackImageUrl.Length > 0)
  74. {
  75. writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveUrl(BackImageUrl) + ")");
  76. }
  77. if(HorizontalAlign != HorizontalAlign.NotSet)
  78. {
  79. writer.AddAttribute(HtmlTextWriterAttribute.Align, TypeDescriptor.GetConverter(typeof(HorizontalAlign)).ConvertToString(HorizontalAlign));
  80. }
  81. if(Wrap)
  82. {
  83. writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "nowrap");
  84. }
  85. }
  86. }
  87. }