Panel.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. //
  2. // Permission is hereby granted, free of charge, to any person obtaining
  3. // a copy of this software and associated documentation files (the
  4. // "Software"), to deal in the Software without restriction, including
  5. // without limitation the rights to use, copy, modify, merge, publish,
  6. // distribute, sublicense, and/or sell copies of the Software, and to
  7. // permit persons to whom the Software is furnished to do so, subject to
  8. // the following conditions:
  9. //
  10. // The above copyright notice and this permission notice shall be
  11. // included in all copies or substantial portions of the Software.
  12. //
  13. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  15. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  17. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  18. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  19. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. //
  21. /**
  22. * Project : Mono
  23. * Namespace : System.Web.UI.MobileControls
  24. * Class : Panel
  25. * Author : Gaurav Vaish
  26. *
  27. * Copyright : 2003 with Gaurav Vaish, and with
  28. * Ximian Inc
  29. */
  30. using System.Collections;
  31. using System.Web.UI;
  32. using System.Web.Mobile;
  33. namespace System.Web.UI.MobileControls
  34. {
  35. public class Panel : MobileControl, ITemplateable
  36. {
  37. private Panel deviceSpecificContent;
  38. private bool paginationStateChanged = false;
  39. public Panel()
  40. {
  41. }
  42. public override bool BreakAfter
  43. {
  44. get
  45. {
  46. return base.BreakAfter;
  47. }
  48. set
  49. {
  50. base.BreakAfter = value;
  51. }
  52. }
  53. protected override bool PaginateChildren
  54. {
  55. get
  56. {
  57. return Paginate;
  58. }
  59. }
  60. public virtual bool Paginate
  61. {
  62. get
  63. {
  64. object o = ViewState["Paginate"];
  65. if(o != null)
  66. return (bool)o;
  67. return false;
  68. }
  69. set
  70. {
  71. bool oldPaginate = Paginate;
  72. ViewState["Paginate"] = value;
  73. if(IsTrackingViewState)
  74. {
  75. PaginationStateChanged = true;
  76. if(oldPaginate && !value)
  77. MobileControl.SetControlPageRecursive(this, 1);
  78. }
  79. }
  80. }
  81. public Panel Content
  82. {
  83. get
  84. {
  85. return deviceSpecificContent;
  86. }
  87. }
  88. internal bool PaginationStateChanged
  89. {
  90. get
  91. {
  92. return paginationStateChanged;
  93. }
  94. set
  95. {
  96. paginationStateChanged = value;
  97. }
  98. }
  99. public override void AddLinkedForms(IList linkedForms)
  100. {
  101. try
  102. {
  103. foreach(Control current in Controls)
  104. {
  105. if(current is MobileControl)
  106. ((MobileControl)current).AddLinkedForms(linkedForms);
  107. }
  108. } finally
  109. {
  110. if(linkedForms.GetEnumerator() is IDisposable)
  111. ((IDisposable)linkedForms.GetEnumerator()).Dispose();
  112. }
  113. }
  114. public override void CreateDefaultTemplatedUI(bool doDataBind)
  115. {
  116. ITemplate contentTmpl = GetTemplate(Constants.ContentTemplateTag);
  117. if(contentTmpl != null)
  118. {
  119. deviceSpecificContent = new TemplateContainer();
  120. contentTmpl.InstantiateIn(this);
  121. Controls.AddAt(0, deviceSpecificContent);
  122. }
  123. }
  124. public override void PaginateRecursive(ControlPager pager)
  125. {
  126. if(EnablePagination)
  127. {
  128. if(Paginate && Content != null)
  129. {
  130. Content.Paginate = true;
  131. Content.PaginateRecursive(pager);
  132. FirstPage = Content.FirstPage;
  133. LastPage = pager.PageCount;
  134. base.PaginateRecursive(pager);
  135. }
  136. }
  137. }
  138. protected override void OnInit(EventArgs e)
  139. {
  140. base.OnInit(e);
  141. if(IsTemplated)
  142. {
  143. ClearChildViewState();
  144. CreateTemplatedUI(false);
  145. ChildControlsCreated = true;
  146. }
  147. }
  148. }
  149. }