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


C# RtfTreeNode.AppendChild方法代码示例

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


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

示例1: AdjacentNodes

        public void AdjacentNodes()
        {
            //Creación de un árbol sencillo

            RtfTree tree = new RtfTree();

            RtfTreeNode mainGroup = new RtfTreeNode(RtfNodeType.Group);
            RtfTreeNode rtfNode = new RtfTreeNode(RtfNodeType.Keyword, "rtf", true, 0);
            mainGroup.AppendChild(rtfNode);

            RtfTreeNode newGroup = new RtfTreeNode(RtfNodeType.Group);
            RtfTreeNode node1 = new RtfTreeNode(RtfNodeType.Keyword, "ul", false, 0);
            RtfTreeNode node2 = new RtfTreeNode(RtfNodeType.Text, "Test", false, 0);
            RtfTreeNode node3 = new RtfTreeNode(RtfNodeType.Keyword, "ulnone", false, 0);

            newGroup.AppendChild(node1);
            newGroup.AppendChild(node2);
            newGroup.AppendChild(node3);

            mainGroup.AppendChild(newGroup);

            tree.RootNode.AppendChild(mainGroup);

            RtfTreeNode node4 = new RtfTreeNode(RtfNodeType.Text, "fin", false, 0);

            mainGroup.AppendChild(node4);

            Assert.That(tree.RootNode.NextNode, Is.SameAs(mainGroup));
            Assert.That(mainGroup.NextNode, Is.SameAs(rtfNode));
            Assert.That(rtfNode.NextNode, Is.SameAs(newGroup));
            Assert.That(newGroup.NextNode, Is.SameAs(node1));
            Assert.That(node1.NextNode, Is.SameAs(node2));
            Assert.That(node2.NextNode, Is.SameAs(node3));
            Assert.That(node3.NextNode, Is.SameAs(node4));
            Assert.That(node4.NextNode, Is.Null);

            Assert.That(node4.PreviousNode, Is.SameAs(node3));
            Assert.That(node3.PreviousNode, Is.SameAs(node2));
            Assert.That(node2.PreviousNode, Is.SameAs(node1));
            Assert.That(node1.PreviousNode, Is.SameAs(newGroup));
            Assert.That(newGroup.PreviousNode, Is.SameAs(rtfNode));
            Assert.That(rtfNode.PreviousNode, Is.SameAs(mainGroup));
            Assert.That(mainGroup.PreviousNode, Is.SameAs(tree.RootNode));
            Assert.That(tree.RootNode.PreviousNode, Is.Null);
        }
开发者ID:Bartizan,项目名称:nrtftree,代码行数:45,代码来源:NavigationTest.cs

示例2: AddChildToEmptyNode

        public void AddChildToEmptyNode()
        {
            RtfTreeNode node = new RtfTreeNode();

            Assert.That(node.ChildNodes, Is.Null);

            RtfTreeNode childNode = new RtfTreeNode();
            node.InsertChild(0, childNode);

            Assert.That(node.ChildNodes, Is.Not.Null);
            Assert.That(node.ChildNodes[0], Is.SameAs(childNode));
            Assert.That(childNode.ChildNodes, Is.Null);

            RtfTreeNode anotherChildNode = new RtfTreeNode();
            childNode.AppendChild(anotherChildNode);

            Assert.That(childNode.ChildNodes, Is.Not.Null);
            Assert.That(childNode.ChildNodes[0], Is.SameAs(anotherChildNode));
        }
开发者ID:mnibecker,项目名称:nrtftree,代码行数:19,代码来源:RtfTreeNodeTest.cs

示例3: SimpleTreeNavigation

        public void SimpleTreeNavigation()
        {
            //Creación de un árbol sencillo

            RtfTree tree = new RtfTree();

            RtfTreeNode mainGroup = new RtfTreeNode(RtfNodeType.Group);
            RtfTreeNode rtfNode = new RtfTreeNode(RtfNodeType.Keyword, "rtf", true, 0);
            mainGroup.AppendChild(rtfNode);

            RtfTreeNode newGroup = new RtfTreeNode(RtfNodeType.Group);
            RtfTreeNode node1 = new RtfTreeNode(RtfNodeType.Keyword, "ul", false, 0);
            RtfTreeNode node2 = new RtfTreeNode(RtfNodeType.Text, "Test", false, 0);
            RtfTreeNode node3 = new RtfTreeNode(RtfNodeType.Text, "ulnone", false, 0);

            newGroup.AppendChild(node1);
            newGroup.AppendChild(node2);
            newGroup.AppendChild(node3);

            mainGroup.AppendChild(newGroup);

            tree.RootNode.AppendChild(mainGroup);

            //Navegación básica: tree
            Assert.That(tree.RootNode, Is.Not.Null);
            Assert.That(tree.MainGroup, Is.SameAs(mainGroup));

            //Navegación básica: newGroup
            Assert.That(newGroup.Tree, Is.SameAs(tree));
            Assert.That(newGroup.ParentNode, Is.SameAs(mainGroup));
            Assert.That(newGroup.RootNode, Is.SameAs(tree.RootNode));
            Assert.That(newGroup.ChildNodes, Is.Not.Null);
            Assert.That(newGroup[1], Is.SameAs(node2));
            Assert.That(newGroup.ChildNodes[1], Is.SameAs(node2));
            Assert.That(newGroup["ul"], Is.SameAs(node1));
            Assert.That(newGroup.FirstChild, Is.SameAs(node1));
            Assert.That(newGroup.LastChild, Is.SameAs(node3));
            Assert.That(newGroup.PreviousSibling, Is.SameAs(rtfNode));
            Assert.That(newGroup.NextSibling, Is.Null);
            Assert.That(newGroup.Index, Is.EqualTo(1));

            //Navegación básica: nodo2
            Assert.That(node2.Tree, Is.SameAs(tree));
            Assert.That(node2.ParentNode, Is.SameAs(newGroup));
            Assert.That(node2.RootNode, Is.SameAs(tree.RootNode));
            Assert.That(node2.ChildNodes, Is.Null);
            Assert.That(node2[1], Is.Null);
            Assert.That(node2["ul"], Is.Null);
            Assert.That(node2.FirstChild, Is.Null);
            Assert.That(node2.LastChild, Is.Null);
            Assert.That(node2.PreviousSibling, Is.SameAs(node1));
            Assert.That(node2.NextSibling, Is.SameAs(node3));
            Assert.That(node2.Index, Is.EqualTo(1));
        }
开发者ID:mnibecker,项目名称:nrtftree,代码行数:54,代码来源:NavigationTest.cs

示例4: InsertGenerator

            /// <summary>
            /// Inserta el código RTF de la aplicación generadora del documento.
            /// </summary>
            private void InsertGenerator()
            {
                RtfTreeNode genGroup = new RtfTreeNode(RtfNodeType.Group);

                genGroup.AppendChild(new RtfTreeNode(RtfNodeType.Control, "*", false, 0));
                genGroup.AppendChild(new RtfTreeNode(RtfNodeType.Keyword, "generator", false, 0));
                genGroup.AppendChild(new RtfTreeNode(RtfNodeType.Text, "NRtfTree Library 1.3.0;", false, 0));

                mainGroup.InsertChild(7, genGroup);
            }
开发者ID:sonygod,项目名称:dotahit,代码行数:13,代码来源:RtfDocument.cs

示例5: InsertColorTable

            /// <summary>
            /// Inserta el código RTF de la tabla de colores en el documento.
            /// </summary>
            private void InsertColorTable()
            {
                RtfTreeNode ctGroup = new RtfTreeNode(RtfNodeType.Group);

                ctGroup.AppendChild(new RtfTreeNode(RtfNodeType.Keyword, "colortbl", false, 0));

                for (int i = 0; i < colorTable.Count; i++)
                {
                    ctGroup.AppendChild(new RtfTreeNode(RtfNodeType.Keyword, "red", true, colorTable[i].R));
                    ctGroup.AppendChild(new RtfTreeNode(RtfNodeType.Keyword, "green", true, colorTable[i].G));
                    ctGroup.AppendChild(new RtfTreeNode(RtfNodeType.Keyword, "blue", true, colorTable[i].B));
                    ctGroup.AppendChild(new RtfTreeNode(RtfNodeType.Text, ";", false, 0));
                }

                mainGroup.InsertChild(6, ctGroup);
            }
开发者ID:sonygod,项目名称:dotahit,代码行数:19,代码来源:RtfDocument.cs

示例6: InsertFontTable

            /// <summary>
            /// Inserta el código RTF de la tabla de fuentes en el documento.
            /// </summary>
            private void InsertFontTable()
            {
                RtfTreeNode ftGroup = new RtfTreeNode(RtfNodeType.Group);

                ftGroup.AppendChild(new RtfTreeNode(RtfNodeType.Keyword, "fonttbl", false, 0));

                for(int i=0; i<fontTable.Count; i++)
                {
                    RtfTreeNode ftFont = new RtfTreeNode(RtfNodeType.Group);
                    ftFont.AppendChild(new RtfTreeNode(RtfNodeType.Keyword, "f", true, i));
                    ftFont.AppendChild(new RtfTreeNode(RtfNodeType.Keyword, "fnil", false, 0));
                    ftFont.AppendChild(new RtfTreeNode(RtfNodeType.Text, fontTable[i] + ";", false, 0));

                    ftGroup.AppendChild(ftFont);
                }

                mainGroup.InsertChild(5, ftGroup);
            }
开发者ID:sonygod,项目名称:dotahit,代码行数:21,代码来源:RtfDocument.cs

示例7: AddImage

            /// <summary>
            /// Inserta una imagen en el documento.
            /// </summary>
            /// <param name="path">Ruta de la imagen a insertar.</param>
            /// <param name="width">Ancho deseado de la imagen en el documento.</param>
            /// <param name="height">Alto deseado de la imagen en el documento.</param>
            public void AddImage(string path, int width, int height)
            {
                FileStream fStream = null;
                BinaryReader br = null;

                try
                {
                    byte[] data = null;

                    FileInfo fInfo = new FileInfo(path);
                    long numBytes = fInfo.Length;

                    fStream = new FileStream(path, FileMode.Open, FileAccess.Read);
                    br = new BinaryReader(fStream);

                    data = br.ReadBytes((int)numBytes);

                    StringBuilder hexdata = new StringBuilder();

                    for (int i = 0; i < data.Length; i++)
                    {
                        hexdata.Append(GetHexa(data[i]));
                    }

                    Image img = Image.FromFile(path);

                    RtfTreeNode imgGroup = new RtfTreeNode(RtfNodeType.Group);
                    imgGroup.AppendChild(new RtfTreeNode(RtfNodeType.Keyword, "pict", false, 0));

                    string format = "";
                    if (path.ToLower().EndsWith("wmf"))
                        format = "emfblip";
                    else
                        format = "jpegblip";

                    imgGroup.AppendChild(new RtfTreeNode(RtfNodeType.Keyword, format, false, 0));

                    imgGroup.AppendChild(new RtfTreeNode(RtfNodeType.Keyword, "picw", true, img.Width * 20));
                    imgGroup.AppendChild(new RtfTreeNode(RtfNodeType.Keyword, "pich", true, img.Height * 20));
                    imgGroup.AppendChild(new RtfTreeNode(RtfNodeType.Keyword, "picwgoal", true, width * 20));
                    imgGroup.AppendChild(new RtfTreeNode(RtfNodeType.Keyword, "pichgoal", true, height * 20));
                    imgGroup.AppendChild(new RtfTreeNode(RtfNodeType.Text, hexdata.ToString(), false, 0));

                    mainGroup.AppendChild(imgGroup);
                }
                finally
                {
                    br.Close();
                    fStream.Close();
                }
            }
开发者ID:sonygod,项目名称:dotahit,代码行数:57,代码来源:RtfDocument.cs

示例8: execMergeDoc

            /// <summary>
            /// Inserta el nuevo árbol en el árbol base (como un nuevo grupo) eliminando toda la cabecera del documento insertado.
            /// </summary>
            /// <param name="parentNode">Grupo base en el que se insertará el nuevo arbol.</param>
            /// <param name="treeToCopyParent">Nuevo árbol a insertar.</param>
            /// <param name="intCurrIndex">Índice en el que se insertará el nuevo árbol dentro del grupo base.</param>
            private void execMergeDoc(RtfTreeNode parentNode, RtfTree treeToCopyParent, int intCurrIndex)
            {
                //Se busca el primer "\pard" del documento (comienzo del texto)
                RtfTreeNode nodePard = treeToCopyParent.RootNode.FirstChild.SelectSingleChildNode("pard");

                //Se obtiene el índice del nodo dentro del principal
                int indPard = treeToCopyParent.RootNode.FirstChild.ChildNodes.IndexOf(nodePard);

                //Se crea el nuevo grupo
                RtfTreeNode newGroup = new RtfTreeNode(RtfNodeType.Group);

                //Se resetean las opciones de párrafo y fuente
                newGroup.AppendChild(new RtfTreeNode(RtfNodeType.Keyword, "pard", false, 0));
                newGroup.AppendChild(new RtfTreeNode(RtfNodeType.Keyword, "plain", false, 0));

                //Se inserta cada nodo hijo del documento nuevo en el documento base
                for (int i = indPard + 1; i < treeToCopyParent.RootNode.FirstChild.ChildNodes.Count; i++)
                {
                    RtfTreeNode newNode =
                        treeToCopyParent.RootNode.FirstChild.ChildNodes[i].CloneNode(true);

                    newGroup.AppendChild(newNode);
                }

                //Se inserta el nuevo grupo con el nuevo documento
                parentNode.InsertChild(intCurrIndex, newGroup);
            }
开发者ID:mnibecker,项目名称:nrtftree,代码行数:33,代码来源:RtfMerger.cs

示例9: getFontID

            /// <summary>
            /// Obtiene el código de la fuente pasada como parámetro, insertándola en la tabla de fuentes si es necesario.
            /// </summary>
            /// <param name="fontDestTbl">Tabla de fuentes resultante.</param>
            /// <param name="sFontName">Fuente buscada.</param>
            /// <returns></returns>
            private int getFontID(ref RtfFontTable fontDestTbl, string sFontName)
            {
                int iExistingFontID = -1;

                if ((iExistingFontID = fontDestTbl.IndexOf(sFontName)) == -1)
                {
                    fontDestTbl.AddFont(sFontName);
                    iExistingFontID = fontDestTbl.IndexOf(sFontName);

                    RtfNodeCollection nodeListToInsert = baseRtfDoc.RootNode.SelectNodes("fonttbl");

                    RtfTreeNode ftFont = new RtfTreeNode(RtfNodeType.Group);
                    ftFont.AppendChild(new RtfTreeNode(RtfNodeType.Keyword, "f", true, iExistingFontID));
                    ftFont.AppendChild(new RtfTreeNode(RtfNodeType.Keyword, "fnil", false, 0));
                    ftFont.AppendChild(new RtfTreeNode(RtfNodeType.Text, sFontName + ";", false, 0));

                    nodeListToInsert[0].ParentNode.AppendChild(ftFont);
                }

                return iExistingFontID;
            }
开发者ID:mnibecker,项目名称:nrtftree,代码行数:27,代码来源:RtfMerger.cs


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