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

编辑器/阅读器

开发平台:

C#

  1. // -- FILE ------------------------------------------------------------------
  2. // name       : UserFormXmlInfoRenderer.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.Drawing;
  11. using System.Web;
  12. using System.Web.UI;
  13. using System.Web.UI.WebControls;
  14. using Itenso.WebUserForms.Controls;
  15. using Itenso.WebUserForms.Data.Form;
  16. namespace Itenso.WebUserForms.Runtime
  17. {
  18. // ------------------------------------------------------------------------
  19. internal class UserFormXmlInfoRenderer : UserFormVisitor
  20. {
  21. // ----------------------------------------------------------------------
  22. public UserFormXmlInfoRenderer( Control startControl )
  23. : base( startControl )
  24. {
  25. } // UserFormXmlInfoRenderer
  26. // ----------------------------------------------------------------------
  27. public void Render( Control parent )
  28. {
  29. if ( parent == null )
  30. {
  31. throw new ArgumentNullException( "parent" );
  32. }
  33. this.parent = parent;
  34. base.Start();
  35. } // Render
  36. // ----------------------------------------------------------------------
  37. protected override void EnterForm( Control control )
  38. {
  39. Table layoutTable = new Table();
  40. layoutTable.Width = Unit.Percentage( 100 );
  41. string formXmlText = string.Empty;
  42. IForm form = UserFormAdapter.ExtractForm( control as UserControl );
  43. if ( form != null )
  44. {
  45. formXmlText = FormXml.Instance.ToXmlString( form );
  46. }
  47. formXmlText = HttpUtility.HtmlEncode( formXmlText );
  48. formXmlText = formXmlText.Replace( "n", "<br />" );
  49. formXmlText = formXmlText.Replace( "  ", "&nbsp;&nbsp;&nbsp;&nbsp;" );
  50. TableRow tableRow = new TableRow();
  51. TableCell tableCell = new TableCell();
  52. tableCell.BackColor = SystemColors.Info;
  53. Literal literal = new Literal();
  54. literal.Text = formXmlText;
  55. tableCell.Controls.Add( literal );
  56. tableRow.Cells.Add( tableCell );
  57. layoutTable.Rows.Add( tableRow );
  58. this.parent.Controls.Add( layoutTable );
  59. } // EnterForm
  60. // ----------------------------------------------------------------------
  61. // members
  62. private Control parent;
  63. } // class UserFormXmlInfoRenderer
  64. } // namespace Itenso.WebUserForms.Runtime
  65. // -- EOF -------------------------------------------------------------------