PanelDesigner.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * Namespace: System.Web.UI.Design.WebControls
  3. * Class: PanelDesigner
  4. *
  5. * Author: Gaurav Vaish
  6. * Maintainer: [email protected]
  7. *
  8. * (C) Gaurav Vaish (2002)
  9. */
  10. using System;
  11. using System.Web.UI.WebControls;
  12. using System.Web.UI.Design;
  13. namespace System.Web.UI.Design.WebControls
  14. {
  15. public class PanelDesigner : ReadWriteControlDesigner
  16. {
  17. public PanelDesigner()
  18. {
  19. }
  20. protected override void MapPropertyToStyle(string propName,
  21. object varPropValue)
  22. {
  23. if(propName != null)
  24. {
  25. try
  26. {
  27. bool hasBeenSet = false;
  28. if(propName == "BackImageUrl")
  29. {
  30. string url = varPropValue.ToString();
  31. if(url.Length > 0)
  32. url = "url(" + url + ")";
  33. // FIXME: CSS Specs read "background-image",
  34. // while MS implementation puts "backgroundImage".
  35. // Is it a MS implementation bug?
  36. Behavior.SetStyleAttribute("backgroundImage",
  37. true, url, true);
  38. hasBeenSet = true;
  39. } else if(propName == "HorizonalAlign")
  40. {
  41. HorizontalAlign alignment = (HorizontalAlign)varPropValue;
  42. if(alignment != HorizontalAlign.NotSet)
  43. {
  44. string value = Enum.Format(typeof(HorizontalAlign),
  45. varPropValue, "G");
  46. Behavior.SetStyleAttribute("textAlign",
  47. true, value, true);
  48. hasBeenSet = true;
  49. }
  50. }
  51. if(!hasBeenSet)
  52. base.MapPropertyToStyle(propName, varPropValue);
  53. } catch(Exception) { }
  54. }
  55. }
  56. protected override void OnBehaviorAttached()
  57. {
  58. base.OnBehaviorAttached();
  59. Panel toDesign = (Panel)Component;
  60. MapPropertyToStyle("BackImageUrl", toDesign.BackImageUrl);
  61. MapPropertyToStyle("HorizontalAlign", toDesign.HorizontalAlign);
  62. }
  63. }
  64. }