Panel.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /**
  2. * Project : Mono
  3. * Namespace : System.Web.UI.MobileControls
  4. * Class : Panel
  5. * Author : Gaurav Vaish
  6. *
  7. * Copyright : 2003 with Gaurav Vaish, and with
  8. * Ximian Inc
  9. */
  10. using System.Collections;
  11. using System.Web.UI;
  12. using System.Web.Mobile;
  13. namespace System.Web.UI.MobileControls
  14. {
  15. public class Panel : MobileControl, ITemplateable
  16. {
  17. private Panel deviceSpecificContent;
  18. private bool paginationStateChanged = false;
  19. public Panel()
  20. {
  21. }
  22. public override bool BreakAfter
  23. {
  24. get
  25. {
  26. return base.BreakAfter;
  27. }
  28. set
  29. {
  30. base.BreakAfter = value;
  31. }
  32. }
  33. protected override bool PaginateChildren
  34. {
  35. get
  36. {
  37. return Paginate;
  38. }
  39. }
  40. public virtual bool Paginate
  41. {
  42. get
  43. {
  44. object o = ViewState["Paginate"];
  45. if(o != null)
  46. return (bool)o;
  47. return false;
  48. }
  49. set
  50. {
  51. bool oldPaginate = Paginate;
  52. ViewState["Paginate"] = value;
  53. if(IsTrackingViewState)
  54. {
  55. PaginationStateChanged = true;
  56. if(oldPaginate && !value)
  57. MobileControl.SetControlPageRecursive(this, 1);
  58. }
  59. }
  60. }
  61. public Panel Content
  62. {
  63. get
  64. {
  65. return deviceSpecificContent;
  66. }
  67. }
  68. internal bool PaginationStateChanged
  69. {
  70. get
  71. {
  72. return paginationStateChanged;
  73. }
  74. set
  75. {
  76. paginationStateChanged = value;
  77. }
  78. }
  79. public override void AddLinkedForms(IList linkedForms)
  80. {
  81. try
  82. {
  83. foreach(Control current in Controls)
  84. {
  85. if(current is MobileControl)
  86. ((MobileControl)current).AddLinkedForms(linkedForms);
  87. }
  88. } finally
  89. {
  90. if(linkedForms.GetEnumerator() is IDisposable)
  91. ((IDisposable)linkedForms.GetEnumerator()).Dispose();
  92. }
  93. }
  94. public override void CreateDefaultTemplatedUI(bool doDataBind)
  95. {
  96. ITemplate contentTmpl = GetTemplate(Constants.ContentTemplateTag);
  97. if(contentTmpl != null)
  98. {
  99. deviceSpecificContent = new TemplateContainer();
  100. contentTmpl.InstantiateIn(this);
  101. Controls.AddAt(0, deviceSpecificContent);
  102. }
  103. }
  104. public override void PaginateRecursive(ControlPager pager)
  105. {
  106. if(EnablePagination)
  107. {
  108. if(Paginate && Content != null)
  109. {
  110. Content.Paginate = true;
  111. Content.PaginateRecursive(pager);
  112. FirstPage = Content.FirstPage;
  113. LastPage = pager.PageCount;
  114. base.PaginateRecursive(pager);
  115. }
  116. }
  117. }
  118. protected override void OnInit(EventArgs e)
  119. {
  120. base.OnInit(e);
  121. if(IsTemplated)
  122. {
  123. ClearChildViewState();
  124. CreateTemplatedUI(false);
  125. ChildControlsCreated = true;
  126. }
  127. }
  128. }
  129. }