当前位置: 首页>>代码示例>>C#>>正文


C# HtmlTextWriter.BeginDocument方法代码示例

本文整理汇总了C#中System.Web.UI.HtmlTextWriter.BeginDocument方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTextWriter.BeginDocument方法的具体用法?C# HtmlTextWriter.BeginDocument怎么用?C# HtmlTextWriter.BeginDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.HtmlTextWriter的用法示例。


在下文中一共展示了HtmlTextWriter.BeginDocument方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateHtmlReport

        public void GenerateHtmlReport(string filename)
        {
            var stringWriter = new StringWriter();

            // Put HtmlTextWriter in using block because it needs to call Dispose.
            using (var writer = new HtmlTextWriter(stringWriter))
            {
                #region header

                writer.BeginDocument("Component Item Report",
                   @"
body { background-color: #E6E6FA }
h1 { font-family: Arial, Helvetica, sans-serif; }
table { background-color: #FFFFFF; }
table tr td { font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: normal; color: #000000; }
table thead td { background-color: #BABDD6; font-weight: bold; Color: #000000; }
td.right { text-align: right; }");

                #endregion

                #region Cubes

                writer.RenderElement(HtmlTextWriterTag.H1, "Cubes");
                writer.BeginTable("1", "3", "0",
                    new[] { "Icon", "Name", "Type Id", "Sub Type Id", "Cube Size", "Accessible", "Size (W×H×D)", "Mass (Kg)", "Build Time (h:m:s)" });

                foreach (var asset in CubeAssets)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    if (asset.TextureFile != null && File.Exists(asset.TextureFile))
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Src, "data:image/png;base64," + ImageTextureUtil.GetTextureToBase64(asset.TextureFile, 32, 32));
                        writer.AddAttribute(HtmlTextWriterAttribute.Width, "32");
                        writer.AddAttribute(HtmlTextWriterAttribute.Height, "32");
                        writer.AddAttribute(HtmlTextWriterAttribute.Alt, Path.GetFileNameWithoutExtension(asset.TextureFile));
                        writer.RenderBeginTag(HtmlTextWriterTag.Img);
                        writer.RenderEndTag();
                    }
                    writer.RenderEndTag(); // Td

                    writer.RenderElement(HtmlTextWriterTag.Td, asset.FriendlyName);
                    writer.RenderElement(HtmlTextWriterTag.Td, asset.TypeId);
                    writer.RenderElement(HtmlTextWriterTag.Td, asset.SubtypeId);
                    writer.RenderElement(HtmlTextWriterTag.Td, asset.CubeSize);
                    writer.RenderElement(HtmlTextWriterTag.Td, new EnumToResouceConverter().Convert(asset.Accessible, typeof(string), null, CultureInfo.CurrentUICulture));
                    writer.RenderElement(HtmlTextWriterTag.Td, "{0}×{1}×{2}", asset.Size.Width, asset.Size.Height, asset.Size.Depth);
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "right");
                    writer.RenderElement(HtmlTextWriterTag.Td, "{0:#,##0.00}", asset.Mass);
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "right");
                    writer.RenderElement(HtmlTextWriterTag.Td, "{0:hh\\:mm\\:ss\\.ff}", asset.Time);

                    writer.RenderEndTag(); // Tr
                }
                writer.RenderEndTag(); // Table 

                #endregion

                #region Components

                writer.RenderElement(HtmlTextWriterTag.H1, "Components");
                writer.BeginTable("1", "3", "0",
                    new[] { "Icon", "Name", "Type Id", "Sub Type Id", "Accessible", "Mass (Kg)", "Volume (L)", "Build Time (h:m:s)" });

                foreach (var asset in ComponentAssets)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    if (asset.TextureFile != null && File.Exists(asset.TextureFile))
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Src, "data:image/png;base64," + ImageTextureUtil.GetTextureToBase64(asset.TextureFile, 32, 32));
                        writer.AddAttribute(HtmlTextWriterAttribute.Width, "32");
                        writer.AddAttribute(HtmlTextWriterAttribute.Height, "32");
                        writer.AddAttribute(HtmlTextWriterAttribute.Alt, Path.GetFileNameWithoutExtension(asset.TextureFile));
                        writer.RenderBeginTag(HtmlTextWriterTag.Img);
                        writer.RenderEndTag();
                    }
                    writer.RenderEndTag(); // Td

                    writer.RenderElement(HtmlTextWriterTag.Td, asset.FriendlyName);
                    writer.RenderElement(HtmlTextWriterTag.Td, asset.TypeId);
                    writer.RenderElement(HtmlTextWriterTag.Td, asset.SubtypeId);
                    writer.RenderElement(HtmlTextWriterTag.Td, new EnumToResouceConverter().Convert(asset.Accessible, typeof(string), null, CultureInfo.CurrentUICulture));
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "right");
                    writer.RenderElement(HtmlTextWriterTag.Td, "{0:#,##0.00}", asset.Mass);
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "right");
                    writer.RenderElement(HtmlTextWriterTag.Td, "{0:#,##0.00}", asset.Volume);
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "right");
                    writer.RenderElement(HtmlTextWriterTag.Td, "{0:hh\\:mm\\:ss\\.ff}", asset.Time);

                    writer.RenderEndTag(); // Tr
                }
                writer.RenderEndTag(); // Table 

                #endregion

                #region Items

//.........这里部分代码省略.........
开发者ID:midspace,项目名称:SEToolbox,代码行数:101,代码来源:ComponentListModel.cs

示例2: CreateHtmlReport

        internal string CreateHtmlReport()
        {
            var stringWriter = new StringWriter();

            // Put HtmlTextWriter in using block because it needs to call Dispose.
            using (var writer = new HtmlTextWriter(stringWriter))
            {
                #region header

                writer.BeginDocument(string.Format("Resource Report - {0}", _saveName),
                    @"
body { background-color: #F6F6FA }
b { font-family: Arial, Helvetica, sans-serif; }
p { font-family: Arial, Helvetica, sans-serif; }
h1,h2,h3 { font-family: Arial, Helvetica, sans-serif; }
table { background-color: #FFFFFF; }
table tr td { font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: normal; color: #000000; }
table thead td { background-color: #BABDD6; font-weight: bold; Color: #000000; }
td.right { text-align: right; }");

                #endregion

                writer.RenderElement(HtmlTextWriterTag.H1, "Resource Report");

                writer.RenderElement(HtmlTextWriterTag.P, "Save World: {0}", _saveName);
                writer.RenderElement(HtmlTextWriterTag.P, "Date: {0}", _generatedDate);

                #region In game resources

                writer.RenderElement(HtmlTextWriterTag.H2, "In game resources");
                writer.RenderElement(HtmlTextWriterTag.P, "Everything is measured in its regressed state. Ie., how much ore was used/needed to build this item.");

                writer.RenderElement(HtmlTextWriterTag.H3, "Untouched Ore (Asteroids)");
                writer.BeginTable("1", "3", "0", new[] { "Name", "Volume m³" });
                foreach (var item in _untouchedOre)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                    writer.RenderElement(HtmlTextWriterTag.Td, item.MaterialName);
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "right");
                    writer.RenderElement(HtmlTextWriterTag.Td, "{0:#,##0.000}", item.Volume);
                    writer.RenderEndTag(); // Tr
                }
                writer.EndTable();

                writer.RenderElement(HtmlTextWriterTag.H3, "Unused Ore (Ore and Ingots, either floating or in containers)");
                writer.BeginTable("1", "3", "0", new[] { "Name", "Mass Kg", "Volume L" });
                foreach (var item in _unusedOre)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                    writer.RenderElement(HtmlTextWriterTag.Td, item.FriendlyName);
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "right");
                    writer.RenderElement(HtmlTextWriterTag.Td, "{0:#,##0.000}", item.Mass);
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "right");
                    writer.RenderElement(HtmlTextWriterTag.Td, "{0:#,##0.000}", item.Volume);
                    writer.RenderEndTag(); // Tr
                }
                writer.EndTable();

                writer.RenderElement(HtmlTextWriterTag.H3, "Used Ore (in tools, items, components, cubes)");
                writer.BeginTable("1", "3", "0", new[] { "Name", "Mass Kg", "Volume L" });
                foreach (var item in _usedOre)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                    writer.RenderElement(HtmlTextWriterTag.Td, item.FriendlyName);
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "right");
                    writer.RenderElement(HtmlTextWriterTag.Td, "{0:#,##0.000}", item.Mass);
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "right");
                    writer.RenderElement(HtmlTextWriterTag.Td, "{0:#,##0.000}", item.Volume);
                    writer.RenderEndTag(); // Tr
                }
                writer.EndTable();

                writer.RenderElement(HtmlTextWriterTag.H3, "Player Ore (Player inventories)");
                writer.BeginTable("1", "3", "0", new[] { "Name", "Mass Kg", "Volume L" });
                foreach (var item in _playerOre)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                    writer.RenderElement(HtmlTextWriterTag.Td, item.FriendlyName);
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "right");
                    writer.RenderElement(HtmlTextWriterTag.Td, "{0:#,##0.000}", item.Mass);
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "right");
                    writer.RenderElement(HtmlTextWriterTag.Td, "{0:#,##0.000}", item.Volume);
                    writer.RenderEndTag(); // Tr
                }
                writer.EndTable();

                writer.RenderElement(HtmlTextWriterTag.H3, "NPC Ore (Controlled by NPC)");
                writer.BeginTable("1", "3", "0", new[] { "Name", "Mass Kg", "Volume L" });
                foreach (var item in _npcOre)
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                    writer.RenderElement(HtmlTextWriterTag.Td, item.FriendlyName);
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "right");
                    writer.RenderElement(HtmlTextWriterTag.Td, "{0:#,##0.000}", item.Mass);
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "right");
                    writer.RenderElement(HtmlTextWriterTag.Td, "{0:#,##0.000}", item.Volume);
                    writer.RenderEndTag(); // Tr
                }
                writer.EndTable();

//.........这里部分代码省略.........
开发者ID:Tygra,项目名称:SEToolbox,代码行数:101,代码来源:ResourceReportModel.cs


注:本文中的System.Web.UI.HtmlTextWriter.BeginDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。