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


C# IElement.AppendChild方法代码示例

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


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

示例1: SimpleTableTest

 private static void SimpleTableTest(IDocument document, IElement group, IElement table)
 {
     var foo1 = group.AppendChild(document.CreateElement("tr")) as IElement;
     foo1.Id = "foo";
     var bar1 = group.AppendChild(document.CreateElement("tr")) as IElement;
     bar1.Id = "bar";
     var foo2 = group.AppendChild(document.CreateElement("tr")) as IElement;
     foo2.Id = "foo";
     var bar2 = group.AppendChild(document.CreateElement("tr")) as IElement;
     bar2.Id = "bar";
     var rows = (table as IHtmlTableElement).Rows;
     Assert.IsNotNull(rows);
     CollectionAssert.AreEquivalent(new[] { foo1, bar1, foo2, bar2 }, rows);
     Assert.AreEqual(foo1, rows["foo"]);
     Assert.AreEqual(bar1, rows["bar"]);
 }
开发者ID:Wojdav,项目名称:AngleSharp,代码行数:16,代码来源:DOMTable.cs

示例2: ParseObject

        private static IElement ParseObject(XamlPropertyValue @object, IHtmlDocument htmlDocument, IElement outerElement)
        {
            IElement element = null;

            if (@object is XamlObject)
            {
                bool alreadyAdded = false;
                bool childsParsed = false;

                var xamlObject = (XamlObject)@object;


                switch (xamlObject.ElementType.Name)
                {
                    case "Viewbox":
                        {
                            element = htmlDocument.CreateElement("div");
                            //todo: stretch, zoom??
                            break;
                        }
                    case "Border":
                        {
                            element = htmlDocument.CreateElement("div");
                            break;
                        }
                    case "Canvas":
                        {
                            element = htmlDocument.CreateElement("div");
                            ((IHtmlElement)element).Style.Position = "absolute";
                            break;
                        }
                    case "StackPanel":
                        {
                            element = htmlDocument.CreateElement("div");
                            ((IHtmlElement)element).Style.Display = "flex";
                            ((IHtmlElement)element).Style.FlexDirection = "column";
                            break;
                        }
                    case "WrapPanel":
                        {
                            element = htmlDocument.CreateElement("div");
                            ((IHtmlElement)element).Style.Display = "flex";
                            ((IHtmlElement)element).Style.FlexWrap = "wrap";
                            ((IHtmlElement)element).Style.FlexDirection = "column";
                            break;
                        }
                    case "DockPanel":
                        {
                            element = htmlDocument.CreateElement("div");
                            ((IHtmlElement)element).Style.Display = "flex";
                            ((IHtmlElement)element).Style.FlexDirection = "column";
                            break;
                        }
                    case "Grid":
                        {
                            var tbl = htmlDocument.CreateElement("table");
                            ((IHtmlElement)tbl).Style.Width = "100%";
                            ((IHtmlElement)tbl).Style.Height = "100%";
                            outerElement.AppendChild(tbl);
                            alreadyAdded = true;
                            childsParsed = true;

                            var grid = xamlObject.Instance as Grid;
                            foreach (var xamlProperty in xamlObject.Properties.Where(x => x.PropertyName != "Children"))
                            {
                                ParseProperty(xamlProperty, htmlDocument, (IHtmlElement)tbl);
                            }

                            var children = xamlObject.Properties.FirstOrDefault(x => x.PropertyName == "Children");

                            for (int n = 0; n < (grid.RowDefinitions.Count > 0 ? grid.RowDefinitions.Count : 1); n++)
                            {
                                var row = htmlDocument.CreateElement("tr");
                                ((IHtmlElement)row).Style.VerticalAlign = "top";
                                tbl.AppendChild(row);
                                if (grid.RowDefinitions.Count > 0)
                                {
                                    var rd = grid.RowDefinitions[n];
                                    ((IHtmlElement)row).Style.Height = ParseGridLenth(rd.Height);
                                }
                                row.ClassList.Add("visuGrid");

                                for (int p = 0; p < (grid.ColumnDefinitions.Count > 0 ? grid.ColumnDefinitions.Count : 1); p++)
                                {
                                    var td = htmlDocument.CreateElement("td");
                                    td.ClassList.Add("visuGrid");
                                    row.AppendChild(td);

                                    element = htmlDocument.CreateElement("div");
                                    td.AppendChild(element);

                                    ((IHtmlElement)element).Style.Width = "100%";
                                    ((IHtmlElement)element).Style.Height = "100%";

                                    if (grid.ColumnDefinitions.Count > 0)
                                    {
                                        var rd = grid.ColumnDefinitions[p];
                                        ((IHtmlElement)td).Style.Width = ParseGridLenth(rd.Width);
                                    }

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


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