UserFormInfoControl.cs
上传用户:husern
上传日期:2022-03-24
资源大小:534k
文件大小:4k
源码类别:

编辑器/阅读器

开发平台:

C#

  1. // -- FILE ------------------------------------------------------------------
  2. // name       : UserFormInfoControl.cs
  3. // project    : Itenso Web User Forms
  4. // created    : Jani Giannoudis - 2008.10.30
  5. // language   : c#
  6. // environment: .NET 2.0
  7. // copyright  : (c) 2008 by Itenso GmbH, Switzerland
  8. // --------------------------------------------------------------------------
  9. using System;
  10. using System.Text;
  11. using System.ComponentModel;
  12. using System.Drawing;
  13. using System.Web.UI;
  14. using System.Web.UI.WebControls;
  15. namespace Itenso.WebUserForms.Controls
  16. {
  17. // ------------------------------------------------------------------------
  18. [ToolboxBitmap( typeof( ResFinder ), "Itenso.WebUserForms.Controls.Images.UserFormInfo.png" )]
  19. [Designer( typeof( UserFormInfoDesigner ) )]
  20. public class UserFormInfoControl : System.Web.UI.WebControls.CompositeControl
  21. {
  22. // ----------------------------------------------------------------------
  23. [DefaultValue( true )]
  24. [Description( "UserFormInfoControl Show Update Button" )]
  25. [Category( "Web User Forms" )]
  26. public bool ShowUpdateButton
  27. {
  28. get { return this.showUpdateButton; }
  29. set { this.showUpdateButton = value; }
  30. } // ShowUpdateButton
  31. // ----------------------------------------------------------------------
  32. [DefaultValue( true )]
  33. [Description( "UserFormInfoControl Show Design-Time Header Info" )]
  34. [Category( "Web User Forms" )]
  35. public bool ShowDesigntimeHeaderInfo
  36. {
  37. get { return this.showDesigntimeHeaderInfo; }
  38. set { this.showDesigntimeHeaderInfo = value; }
  39. } // ShowDesigntimeHeaderInfo
  40. // ----------------------------------------------------------------------
  41. [DefaultValue( false )]
  42. [Description( "UserFormInfoControl Show Run-Time Header Info" )]
  43. [Category( "Web User Forms" )]
  44. public bool ShowRuntimeHeaderInfo
  45. {
  46. get { return this.showRuntimeHeaderInfo; }
  47. set { this.showRuntimeHeaderInfo = value; }
  48. } // ShowRuntimeHeaderInfo
  49. // ----------------------------------------------------------------------
  50. protected override void OnPreRender( EventArgs e )
  51. {
  52. base.OnPreRender( e );
  53. CreateControls();
  54. } // OnPreRender
  55. // ----------------------------------------------------------------------
  56. private void CreateControls()
  57. {
  58. Controls.Clear();
  59. if ( this.showUpdateButton )
  60. {
  61. Button updateButton = new Button();
  62. updateButton.Text = "Update Form Info";
  63. updateButton.Click += new EventHandler( UpdateButtonClick );
  64. Controls.Add( updateButton );
  65. }
  66. BuildFormInfo();
  67. } // CreateControls
  68. // ----------------------------------------------------------------------
  69. private void BuildFormInfo()
  70. {
  71. Table infoTable = new Table();
  72. infoTable.Width = Unit.Percentage( 100 );
  73. infoTable.CellPadding = 2;
  74. infoTable.CellSpacing = 1;
  75. UserFormInfoRenderer renderer = new UserFormInfoRenderer( Page.Form );
  76. renderer.ShowDesigntimeHeaderInfo = this.showDesigntimeHeaderInfo;
  77. renderer.ShowRuntimeHeaderInfo = this.showRuntimeHeaderInfo;
  78. renderer.Render( infoTable );
  79. if ( infoTable.Rows.Count > 1 )
  80. {
  81. Controls.Add( infoTable );
  82. }
  83. } // BuildFormInfo
  84. // ----------------------------------------------------------------------
  85. private void UpdateButtonClick( object sender, EventArgs e )
  86. {
  87. RecreateChildControls();
  88. } // UpdateButtonClick
  89. // ----------------------------------------------------------------------
  90. // members
  91. private bool showUpdateButton = true;
  92. private bool showDesigntimeHeaderInfo = true;
  93. private bool showRuntimeHeaderInfo = false;
  94. } // class UserFormInfoControl
  95. } // namespace Itenso.WebUserForms.Controls
  96. // -- EOF -------------------------------------------------------------------