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


C# TagList.AddChild方法代码示例

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


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

示例1: Build

		/////////////////////////////////////////////////////////////////////////////

		#region code
		//
		// template is in Templates.cs
		//
		public Tuple<string, string> Build()
		{
			// ******
			var tagList = new TagList { };
			tagList.AddChild( new QuickTag( "h4" )
					.SetValue( About ) );

			// ******
			var instance = Templates.MoneyFlowTemplate.CreateTemplateInstance();
			foreach( var item in AccountSummaryData.Create() ) {
				instance.AddBodyRow(
					item.Col1.ToString( "dd MMM yyyy" ),
					item.Col2.ToString( "n" ),
					item.Col3.ToString( "n" ),
					item.Col4.ToString( "n" ),
					item.Col5.ToString( "n" ),
					item.Col6.ToString( "n" ),
					item.Col7.ToString( "n" )
				);
			}

			// ******
			tagList.AddChild( instance.CreateTable() );
			return new Tuple<string, string>( Render( tagList ), nameof( TableWithTemplate1 ) );
		}
开发者ID:gitsharper,项目名称:SharpHtml,代码行数:31,代码来源:TableWithTemplate1.cs

示例2: Build

		/////////////////////////////////////////////////////////////////////////////

		#region code
		public Tuple<string, string> Build()
		{
			// ******
			var tagList = new TagList { };
			tagList.AddChild( new QuickTag( "h4" )
					.SetValue( About ) );

			// ******
			var table = new Table( caption: "Money Flow", border: 0, id: "", attrAndStyles: "background : ivory" );
			tagList.AddChild( table );

			// ******
			foreach( var item in AccountSummaryData.Create() ) {
				table.AddBodyRow(
						Content( item.Col1.ToString( "dd MMM yyyy" ), "width : 100px", "text-align : right" ),
						Content( item.Col2.ToString(), "width : 100px", "text-align : right" ),
						Content( item.Col3.ToString(), "width : 100px", "text-align : right" ),
						Content( item.Col4.ToString(), "width : 100px", "text-align : right" ),
						Content( item.Col5.ToString(), "width : 100px", "text-align : right" ),
						Content( item.Col6.ToString(), "width : 100px", "text-align : right" ),
						Content( item.Col7.ToString(), "width : 100px", "text-align : right", item.Col7 < 0 ? "color : red" : "" )
				);
			}

			// ******
			return new Tuple<string, string>( Render( tagList ), nameof( TableWithFormatting2 ) );
		}
开发者ID:gitsharper,项目名称:SharpHtml,代码行数:30,代码来源:TableWithFormatting2.cs

示例3: Build

		/////////////////////////////////////////////////////////////////////////////

		#region code
		public Tuple<string, string> Build()
		{
			// ******
			var tagList = new TagList { };

			tagList.AddChild( new QuickTag( "h4" )
				.SetValue( About )
			);
			
			// ******
			var table = new Table( caption: "Checking Account", border: 0, id: "", attrAndStyles: "" );
			tagList.AddChild( table );

			// ******
			foreach( var item in AccountSummaryData.Create() ) {
				table.AddBodyRow(
						item.Col1.ToString( "dd MMM yyyy" ),
						item.Col2.ToString(),
						item.Col3.ToString(),
						item.Col4.ToString(),
						item.Col5.ToString(),
						item.Col6.ToString(),
						item.Col7.ToString()
				);
			}

			// ******
			return new Tuple<string, string>( Render( tagList ), nameof( TableWithData ) );
		}
开发者ID:gitsharper,项目名称:SharpHtml,代码行数:32,代码来源:TableWithData.cs

示例4: Build

		/////////////////////////////////////////////////////////////////////////////

		#region code
		public Tuple<string, string> Build()
		{
			// ******
			var tagList = new TagList { };
			tagList.AddChild( new QuickTag( "h4" )
					.SetValue( About ) );

			// ******
			var table = new Table();
			tagList.AddChild( table );

			table.AddAttributesAndStyles(
				"table-layout: fixed",
				"border-collapse: collapse",
				"border: 1px solid black",
				"margin: 0px",
				"padding : 0",
				"background : ivory"
				);

			table.AddHeaderRow( Content( "", "colspan = 4" ), Content( $"4 month moving average", "colspan = 3" ) )
				.AddHeaderRow( "Ending Date", "In", "Out", "Diff", "Moving Avg In", "Moving Avg Out", "Moving Avg Diff" );

			table.AddStyleBlock( StyleBlockAddAs.Class, "td, th", "border : 1px solid black" );

			table.AddBodyStyles();

			//
			// yet another way to set body styles; a StylesFunc allows the interception of columns as they are
			// added, parameters are the column number being added and the StylesDictionary that represents that
			// column, return an IEnumerable<string> of styles to merge, or manipulate the styles dictionary
			// itself
			//
			// breaking out the StyleFunction on it's own makes this look a lot less messy and more readable than
			// inserting the lambda directly into SetDefaultBodyStyles() - at least for the sake of an example
			//
			StylesFunc sf = ( col, sd ) => col > 3 ? Styles( "font-style : italic " ) : null;
			table.SetDefaultBodyStyles( sf, 7, "width : 100px", "text-align : right" );

			// ******
			foreach( var item in AccountSummaryData.Create() ) {
				table.AddBodyRow(
						item.Col1.ToString( "dd MMM yyyy" ),
						item.Col2.ToString(),
						item.Col3.ToString(),
						item.Col4.ToString(),
						item.Col5.ToString(),
						item.Col6.ToString(),
						Content( item.Col7.ToString(), item.Col7 < 0 ? "color : red" : null )
				);
			}

			// ******
			return new Tuple<string, string>( Render( tagList ), nameof( TableWithFormatting3 ) );
		}
开发者ID:gitsharper,项目名称:SharpHtml,代码行数:58,代码来源:TableWithFormatting3.cs

示例5: Build

		/////////////////////////////////////////////////////////////////////////////

		public Tuple<string, string> Build()
		{
			// ******
			var tagList = new TagList { };

			tagList.AddChild( new QuickTag( "h4" )
				.SetValue( About )
			);

			// ******
			var instance = Templates.MoneyFlowTemplate.CreateTemplateInstance();
			foreach( var item in AccountSummaryData.Create() ) {
				instance.AddBodyRow(
					//
					// we can modify cells as they are added
					//
					( row, column, tag ) => ModifyTags( item, row, column, tag ),

					item.Col1.ToString( "dd MMM yyyy" ),
					item.Col2.ToString( "n" ),
					item.Col3.ToString( "n" ),

					//
					// we don't have to monitor each tag as it's created, we can 
					// modify the tag "inline" by passing a CellFunc as a callback,
					// note: we do have to add the data ourself
					//
					(CellFunc) (( row, col, tag ) => {
						tag.SetValue( item.Col4.ToString( "n" ) );
						if( item.Col4 < 0 ) {
							tag.AddStyles( "color : red" );
						}
						return null;
					}),

					item.Col5.ToString( "n" ),
					item.Col6.ToString( "n" ),

					//
					// yet another way to customize the adding of data, if we pass an IEnumerable<string>
					// the first string will be used for the content of the tag and the remaining
					// items are parsed as attributes and styles ("style : value", "attribute = value")
					//
					Content( item.Col7.ToString( "n" ), item.Col7 < 0 ? "color : red" : "" )
				);
			}

			// ******
			tagList.AddChild( instance.CreateTable() );
			return new Tuple<string, string>( Render( tagList ), nameof( TableWithTemplate2 ) );
		}
开发者ID:gitsharper,项目名称:SharpHtml,代码行数:53,代码来源:TableWithTemplate2.cs

示例6: RunTableExamples1

		/////////////////////////////////////////////////////////////////////////////

		static void RunTableExamples1( IEnumerable<string> items )
		{
			// ******
			int index = 0;
			string directory = string.Empty;
			var tagList = new TagList { };

			// ******
			foreach( var example in TableExamples() ) {
				var htmlPath = example.Item1;
				var about = example.Item2;

				if( 0 == index ) {
					directory = Path.GetDirectoryName( htmlPath );
				}

				tagList.AddChild( new A( "file:///" + htmlPath ).SetValue( about ) );
			}

			//var div = new Div().AppendChildren( tagList );

			var list = new Ul().AddListItems( tagList );

			// ******
			//var page = new SimplePage<SimpleHtml> { };
			//page.AddBodyContent( tagList );
			//var html = page.Html.Render();

			var html = new BasicHtml( "Index" );
			html.BodyContainer.AddChild( list );
			var text = html.Render();

			File.WriteAllText( Path.Combine( directory,"index.html" ), text );
		}
开发者ID:gitsharper,项目名称:SharpHtml,代码行数:36,代码来源:Program.cs


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