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


C# Node.Parse方法代码示例

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


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

示例1: InsertFromXml

        // 
        private void InsertFromXml (Node currentSelectedNode, XmlNode xmlChildNode, Node newNode, ref Node newSelectedNode, ref bool selected)
        {
            newNode = new Node();
            newNode.Parse(xmlChildNode, this.types_, this.entityManager, false, null, false);
            if (newNode.type_ != null)
            {
                currentSelectedNode.PrependNode(newNode);

                newSelectedNode = newNode.Parse(xmlChildNode, this.types_, this.entityManager, true, null, false);
                
                if (newSelectedNode != null)
                {
                    this.SelectNode(newSelectedNode, newSelectedNode.IsAppend);
                    selected = true;
                }
            }
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:18,代码来源:NodesBuilder.cs

示例2: MakeTopTable

 //
 private void MakeTopTable ()
 {
     Node root = this.FindRoot ();
     if (root != null)
     {
         bool append = false;
         bool isLast = false;
         Node top = null;
         bool wasSplit = false;
         Node cur = this.GetCurrentlySelectedNode ();
         top = this.FindRootChild ();
         if (((top != null) && (top.parent_ != null)) && (top.parent_ == root))
         {
             if (top != cur)
             {
                 this.SelectNode (top, false);
                 cur = this.GetCurrentlySelectedNode ();
             }
             if (((cur.InternalMark > 0) && !cur.IsAppend) && ((cur.literalText != null) && (cur.literalText.Length > 1)))
             {
                 cur = this.CarriageReturn (cur, ref wasSplit);
             }
             append = cur.IsAppend;
             if (append)
             {
                 if (cur.nextSibling == null)
                 {
                     isLast = true;
                 }
                 else if (cur == top)
                 {
                     this.SelectNode (cur.nextSibling, false);
                     cur = this.GetCurrentlySelectedNode ();
                     top = cur;
                     append = false;
                 }
             }
             string xml =  "<math xmlns=\"http://www.w3.org/1998/Math/MathML\">";
             xml += "<mtable columnalign=\"left\" class=\"nugentoplevel\">";
             xml = xml + "<mtr>";
             xml = xml + "<mtd><mrow></mrow></mtd>";
             xml = xml + "</mtr>";
             xml = xml + "<mtr>";
             xml = xml + "<mtd nugenCursor=''><mrow></mrow></mtd>";
             xml = xml + "</mtr>";
             xml = xml + "</mtable>";
             xml = xml + "</math>";
             XmlDocument doc = new XmlDocument ();
             doc.LoadXml (xml);
             XmlNode first = doc.DocumentElement.FirstChild;
             Node r = new Node ();
             Node sel = r.Parse (first, this.types_, this.entityManager, true, null);
             Node last = r;
             Node next = sel;
             Node prev = next.parent_.prevSibling.firstChild;
             if ((((last != null) && (last.type_.type == ElementType.Mtable)) &&
                  ((prev != null) && (next != null))) &&
                 (((prev.type_.type == ElementType.Mtd) &&
                   (next.type_.type == ElementType.Mtd)) && (root.numChildren > 0)))
             {
                 root.firstChild.PrependNode (last);
                 root.UpdateChildrenIndices ();
                 root.UpdateLevel ();
                 int count = 0;
                 while (last.nextSibling != null)
                 {
                     Node ns = last.nextSibling;
                     if (!append)
                     {
                         if (ns == cur)
                         {
                             count++;
                         }
                     }
                     else if (ns == cur.nextSibling)
                     {
                         count++;
                     }
                     if (count == 0)
                     {
                         this.ReParent (ns.parent_, prev, ns);
                         continue;
                     }
                     this.ReParent (ns.parent_, next, ns);
                 }
                 Node pc = prev.firstChild;
                 Node nc = next.firstChild;
                 if (((pc != null) && (pc.type_.type == ElementType.Mrow)) &&
                     ((pc.numChildren == 0) && (pc.nextSibling != null)))
                 {
                     this.Tear (pc, false, false);
                 }
                 if (((nc != null) && (nc.type_.type == ElementType.Mrow)) &&
                     ((nc.numChildren == 0) && (nc.nextSibling != null)))
                 {
                     this.SelectNode (nc.nextSibling, false);
                     this.Tear (nc, false, false);
                 }
                 if (isLast)
//.........这里部分代码省略.........
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:101,代码来源:NodesBuilder.cs

示例3: tryAddMathXML


//.........这里部分代码省略.........
            {
                return;
            }

            bool wasSelect = false;
            Node lastRow = null;
            if (!((xmlRoot == null) || !xmlRoot.HasChildNodes))
            {
                Node selRow = selectedNode;
                int count = 0;
                count = xmlRoot.ChildNodes.Count;
                int rCount = 0;
                if (((selRow.type_ != null) && (selRow.type_.type == ElementType.Mrow)) && !selRow.HasChildren())
                {
                    emptyRow = true;
                    rCount = 1;
                }
                if ((((selRow.parent_ != null)) &&
                     ((selRow.parent_.type_.maxChilds != -1) &&
                      (((selRow.parent_.numChildren - rCount) + count) >= selRow.parent_.type_.maxChilds))) ||
                    ((selRow.parent_.type_.type == ElementType.Mmultiscripts) ||
                     (selRow.parent_.type_.type == ElementType.Maction)))
                {
                    selRow = this.WrapInRowInplace(selRow);
                }

                if (selRow.IsAppend)
                {
                    Node row = selRow;
                    Node lastCell = null;
                    if (isPaste && (xmlRoot.Name == "math"))
                    {
                        Node newNode = new Node();
                        newNode.Parse(xmlRoot, this.types_, this.entityManager, true, null);
                        if ((newNode.type_ != null) && newNode.HasChildren())
                        {
                            NodesList list = newNode.GetChildrenNodes();
                            Node n = list.Next();
                            lastRow = row;
                            for (int i = 0; (row != null) && (n != null); i++)
                            {
                                row.AppendNode(n);
                                lastCell = n;
                                n = list.Next();
                                row = row.nextSibling;
                            }
                            if (lastCell != null)
                            {
                                if (lastCell.nextSibling != null)
                                {
                                    this.SelectNode(lastCell.nextSibling, false);
                                }
                                else
                                {
                                    this.SelectNode(lastCell, true);
                                }
                                wasSelect = true;
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < count; i++)
                        {
                            XmlNode x = xmlRoot.ChildNodes[i];
                            Node n = new Node();
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:67,代码来源:NodesBuilder_edit.cs

示例4: EnterPressed_NeedSplit

 //
 private bool EnterPressed_NeedSplit (bool splitCell)
 {
     bool isTop = false;
     try
     {
         Node cur = this.GetCurrentlySelectedNode ();
         if (((cur == null)) || (cur.type_.type == ElementType.Math))
         {
             return isTop;
         }
         try
         {
             bool isLast = false;
             bool isfirst = false;
             Node td = null;
             Node c = cur;
             bool isMath = false;
             while (((c.parent_ != null) && !isMath) && (c.type_.type != ElementType.Mtd))
             {
                 if (c.type_.type == ElementType.Math)
                 {
                     isMath = true;
                     continue;
                 }
                 td = c;
                 c = c.parent_;
             }
             if ((c != null) && (c.type_.type == ElementType.Mtd))
             {
                 Node cell = c;
                 if (cell.nextSibling == null)
                 {
                     isLast = true;
                 }
                 if (((cell.nextSibling != null) && (cell.prevSibling == null)) &&
                     ((cell.firstChild == cur) && (cur.InternalMark == 0)))
                 {
                     isfirst = true;
                 }
                 if ((cell.parent_ != null) && (cell.parent_.type_.type == ElementType.Mtr))
                 {
                     Node row = cell.parent_;
                     int numCols = row.numChildren;
                     string xml = "<math xmlns=\"http://www.w3.org/1998/Math/MathML\">";
                     xml = xml + "<mtable columnalign=\"left\">";
                     xml = xml + "<mtr>";
                     for (int i = 0; i < numCols; i++)
                     {
                         if (i == 0)
                         {
                             xml = xml + "<mtd nugenCursor=''/>";
                         }
                         else
                         {
                             xml = xml + "<mtd><mrow/></mtd>";
                         }
                     }
                     xml = xml + "</mtr>";
                     xml = xml + "</mtable>";
                     xml = xml + "</math>";
                     XmlDocument doc = new XmlDocument ();
                     doc.LoadXml (xml);
                     XmlNode topnode = doc.DocumentElement.FirstChild;
                     Node newNode = new Node ();
                     Node newSelected = newNode.Parse (topnode, this.types_, this.entityManager, true, null);
                     Node toSel = null;
                     if (newNode.HasChildren ())
                     {
                         newNode = newNode.firstChild;
                     }
                     if (newNode.type_.type != ElementType.Mtr)
                     {
                         return isTop;
                     }
                     if (isfirst)
                     {
                         row.PrependNode (newNode);
                         this.PropogateAttributes (row, newNode);
                         if ((newSelected.type_.type == ElementType.Mtd) && (newSelected.numChildren == 0))
                         {
                             newSelected.AdoptChild (this.CreateRow ());
                         }
                         this.SelectNode (cur, false);
                         return isTop;
                     }
                     row.AppendNode (newNode);
                     this.PropogateAttributes (row, newNode);
                     if (newSelected == null)
                     {
                         return isTop;
                     }
                     if (splitCell && isLast)
                     {
                         if (td != null)
                         {
                             Node cel = td;
                             toSel = newSelected;
                             int num = 0;
                             if ((cel.InternalMark == 0) && (cel.prevSibling == null))
//.........这里部分代码省略.........
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:101,代码来源:NodesBuilder.cs

示例5: Parse

        public Node Parse(XmlNode XMLNode, Types mTypes, EntityManager mEntities, bool recurse, StyleAttributes styleAttributes, bool bParentShift)
        {
            bool hasSelect = false;
            bool hasSelectRight = false;
            Node result = null;
            if (!bParentShift)
            {
                xmlTagName = XMLNode.LocalName;
                namespaceURI = XMLNode.NamespaceURI;
            }
            
            int numAttrs = 0;
            
            if ((recurse && (XMLNode.Attributes != null)) && !bParentShift)
            {
                StyleAttributes attributes = ParseMStyle(XMLNode, style_);
                if (attributes != null)
                {
                    if (style_ == null)
                    {
                        style_ = new StyleAttributes();
                    }
                    attributes.CopyTo(style_);
                }
            
                numAttrs = XMLNode.Attributes.Count;
                if (numAttrs > 0)
                {
                    if (attrs == null)
                    {
                        attrs = new AttributeList();
                    }

                    for (int i = 0; i < numAttrs; i++)
                    {
                        
                        if (XMLNode.Attributes[i].Name == "nugenCursor")
                        {
                            result = this;
                            hasSelect = true;
                        }
                        else if (XMLNode.Attributes[i].Name == "nugenCursorEnd")
                        {
                            result = this;
                            result.IsAppend = true;
                            hasSelectRight = true;
                        }
                        else
                        {
                            attrs.Add(new Attribute(XMLNode.Attributes[i].Name, XMLNode.Attributes[i].Value, XMLNode.Attributes[i].NamespaceURI));
                        }
                    }

                    if (hasSelect)
                    {
                        XMLNode.Attributes.RemoveNamedItem("nugenCursor");
                    }
                    if (hasSelectRight)
                    {
                        XMLNode.Attributes.RemoveNamedItem("nugenCursorEnd");
                    }
                }
            }

            if ((XMLNode.NodeType == XmlNodeType.Element) && !bParentShift)
            {
                if (type_ == null)
                {
                    type_ = mTypes[xmlTagName];
                }
                if ((hasSelect && (type_.type == ElementType.Mi)) &&
                    (literalText != null))
                {
                    InternalMark = literalText.Length;
                }
            }

            if (recurse && XMLNode.HasChildNodes)
            {
                XmlNodeList list = XMLNode.ChildNodes;
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].NodeType == XmlNodeType.Text)
                    {
                        if ((type_.type == ElementType.Mtext) || (type_.type == ElementType.Ms))
                        {
                            literalText += list[i].Value;
                            continue;
                        }
                        
                        if (type_.type == ElementType.Mn)
                        {
                            literalText += list[i].Value.Trim();
                            continue;
                        }
                        
                        if (type_.type == ElementType.Mi)
                        {
                            literalText += list[i].Value.Trim();
                            continue;
//.........这里部分代码省略.........
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:101,代码来源:Node_parse.cs


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