Example #1
0
        private outline getnodes(XmlNode parent, outline parentnode) //parent 是xml节点的父节点parentnode是父节点在tree中的父节点
        {
            //
            outline aa = new outline()
            {
                secid    = ((XmlElement)parent).GetAttribute("id"),
                Name1    = ((XmlElement)parent).GetAttribute("id") + " " + ((XmlElement)parent).GetAttribute("sec-title"),
                nodename = parent.Name,
                toollip  = ((XmlElement)parent).GetAttribute("sec-title"),
                href     = ((XmlElement)parent).GetAttribute("href"),
                parent   = parentnode,
                type     = (outlinetype)((int)parentnode.type + 1)
                           // nodetype=parent.Name
            };

            if (parent.HasChildNodes == false)
            {
                return(aa);
            }
            else
            {
                // Console.WriteLine(aa.secid + " " + aa.Name);
                XmlNodeList ac = parent.ChildNodes;
                foreach (XmlNode acs in ac)
                {
                    aa.children.Add(getnodes(acs, aa));
                }
                return(aa);
            }
        }
        private void m_window5_outline_add(object sender, Window5.textEventArgs e)
        {
            //获取事件传递过来的数据
            newname = e.textbox;
            outline_Data add_section = new outline_Data();
            outline      sel         = (outline)tree6.SelectedItem;

            add_section.outline_node_add(sel, newname);
        }
Example #3
0
        private static void createhtml(outline outline, string dir)
        {
            FileStream   fi;
            StreamWriter sw;

            if (outline.children.Count == 0)
            {
                #region outlinetype.common
                if (outline.type == outlinetype.common)
                {
                    article dd = new article(outline.nodename);
                    //FileStream fi = new FileStream(dir + "\\" + "section" + ((XmlElement)root).GetAttribute("id") + ".html", FileMode.Create);
                    fi = new FileStream(dir + "\\" + outline.nodename + ".html", FileMode.Create);
                    sw = new StreamWriter(fi, Encoding.Default);
                    sw.WriteLine("<!doctype html>");
                    sw.WriteLine("<html lang=\"en\">");
                    sw.WriteLine("<head>");
                    sw.WriteLine("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\"/>");
                    sw.WriteLine("<script type=\"text/javascript\" src=\"change.js\"></script>");
                    //sw.WriteLine("<title>" + tree5_sel.Name + "</title>");
                    sw.WriteLine("</head>");
                    sw.WriteLine("<body>");
                    sw.WriteLine("<script type=\"text/javascript\" src=\"wz_tooltip.js\"></script>");
                    if (outline.nodename == "CatalogOutline")
                    {
                        sw.WriteLine(gethtmlcode(updateEVENT_WPFTOJS(dd.getcontext_comm(), 1)));
                    }
                    else if (outline.nodename == "CatalogFig")
                    {
                        sw.WriteLine(gethtmlcode(updateEVENT_WPFTOJS(dd.getcontext_comm(), 3)));
                    }
                    else
                    {
                        sw.WriteLine(gethtmlcode(dd.getcontext_comm()));
                    }
                    sw.WriteLine("</body>");
                    sw.WriteLine("</html>");
                    sw.Flush();
                    sw.Close();
                    fi.Close();
                    create_leftnode(outline, sws);
                }
                #endregion
                #region outlinetype.section
                else
                {
                    article dd = new article(outline.secid, "Papersection/" + outline.nodename);
                    fi = new FileStream(dir + "\\" + "section" + outline.secid + ".html", FileMode.Create);
                    sw = new StreamWriter(fi, Encoding.Default);
                    sw.WriteLine("<!doctype html>");
                    sw.WriteLine("<html lang=\"en\">");
                    sw.WriteLine("<head>");
                    sw.WriteLine("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\"/>");
                    //sw.WriteLine("<script type=\"text/javascript\" src=\"change.js\"></script>");
                    sw.WriteLine("</head>");
                    sw.WriteLine("<body>");
Example #4
0
 public static string getparent(outline sel)
 {
     if (sel.parent == null)
     {
         return(sel.nodename);
     }
     else
     {
         return(getparent(sel.parent) + "/" + sel.nodename);
     }
 } //获取选中节点的父类
Example #5
0
 private outline getchapter(outline sel)
 {
     if (sel.type == outlinetype.Chapter)
     {
         return(sel);
     }
     else
     {
         return(getchapter(sel.parent));
     }
 }
Example #6
0
        public void outline_node_add(outline select, string newname) //增加小节
        {
            //  string cc = getparent(select);
            //root_outline = doc.DocumentElement;
            XmlNode     a           = getselectnode(select);
            XmlNode     b           = getlasnode(select);
            XmlNode     c           = getlasnode_tem(select);
            XmlNodeList xmllist     = a.ChildNodes;
            string      id          = select.secid + "." + (xmllist.Count + 1).ToString();
            string      newname_add = newname;
            string      href        = select.href + "/" + id;
            string      type        = ((outlinetype)((int)select.type + 1)).ToString();
            string      nodename    = type;
            outline     newone      = new outline()
            {
                Name1    = newname_add,
                toollip  = newname_add,
                parent   = select,
                secid    = id,
                nodename = nodename,
                href     = href,
                type     = (outlinetype)((int)select.type + 1)
            };

            select.children.Add(newone);
            XmlElement xe1 = doc_outline.CreateElement(nodename); //创建一个节点

            xe1.SetAttribute("id", id);                           //设置该节点id属性
            xe1.SetAttribute("sec-title", newname);               //设置该节点name属性
            xe1.SetAttribute("nodetype", type);                   //设置该节点type属性
            xe1.SetAttribute("href", href);                       //设置节点的href
            a.AppendChild(xe1);
            doc_outline.Save(outline_xml);
            XmlDocument doc = new XmlDocument();

            doc.Load(MainWindow.idd_href + "/webTemplateStyle.xml");
            XmlNode    style = doc.DocumentElement.SelectSingleNode(type);
            XmlElement xe2   = doc_contex.CreateElement(nodename);

            xe2.SetAttribute("id", id);
            xe2.InnerXml = style.InnerXml;
            //xe2.InnerXml = xe2.InnerXml.Replace(")#@paper_title@#)", newname);
            root_contex.InsertAfter(xe2, b);
            doc_contex.Save(idis_xml);
            XmlElement xe3       = doc_tem.CreateElement(nodename);
            XmlElement xe3_title = doc_tem.CreateElement("papersectiontitle");
            XmlElement xe3_text  = doc_tem.CreateElement("papersectiontext");

            xe3.SetAttribute("id", id);
            xe3.AppendChild(xe3_title);
            xe3.AppendChild(xe3_text);
            root_tem.InsertAfter(xe3, c);
            doc_tem.Save(tem_xml);
        }
Example #7
0
 public XmlNode getlasnode_tem(outline select) //获取tem中节点的最后一个子节点
 {
     if (select.children.Count == 0)
     {
         return(get_temnode(select.nodename, select.secid));
     }
     else
     {
         return(getlasnode_tem(select.children[select.children.Count - 1]));
         //return get_contexnode(select.children[select.children.Count - 1].nodename, select.children[select.children.Count - 1].secid);
     }
 }
        private int getindex(outline cc)
        {
            int i = 0;

            foreach (outline cv in this.tree6.Items)
            {
                i++;
                if (cv.Name1 == cc.Name1)
                {
                    break;
                }
            }
            return(i);
        }
Example #9
0
        public void outline_node_modify(outline select, string newname) //修改outline的接点名称
        {
            XmlNode a           = getselectnode(select);
            string  id          = select.secid;
            XmlNode contex_node = get_contexnode(select.nodename, select.secid);

            contex_node = contex_node.SelectSingleNode("papersectiontitle");
            string context = contex_node.InnerText;

            ((XmlElement)contex_node).InnerXml = contex_node.InnerXml.Replace(context, " " + newname);
            doc_contex.Save(idis_xml);
            ((XmlElement)a).SetAttribute("sec-title", newname);
            doc_outline.Save(outline_xml);
        }
        private void m_window5_outline_addchapter(object sender, Window5.textEventArgs e)
        {
            //获取事件传递过来的数据
            newname = e.textbox;
            outline_Data add_section = new outline_Data();
            outline      sel         = (outline)tree6.SelectedItem;
            int          c           = getindex(sel);
            //outline_Data.Instance.TreeViewItems1.Insert(c,);
            outline aa = add_section.outline_chapter_add(sel, newname);
            //outline_Data.Instance.TreeViewItems1.Insert(c, aa);
            ObservableCollection <outline> cc = tree6.ItemsSource as ObservableCollection <outline>;

            cc.Insert(c, aa);
        }
Example #11
0
 public void refer_number_updata(outline charp)
 {
     if (charp.children.Count == 0)
     {
         update(charp);
     }
     else
     {
         update(charp);
         foreach (outline a in charp.children)
         {
             refer_number_updata(a);
         }
     }
 }
Example #12
0
        public void outline_node_delet(outline select) //删除节点
        {
            XmlNode b      = getselectnode(select);
            XmlNode b_next = b.NextSibling;
            string  oldid  = ((XmlElement)b).GetAttribute("id");

            delet_outline(b);
            //root_outline.RemoveChild(b);
            //delete_contex(b.Name, oldid);
            if (b_next != null && ((XmlElement)b_next).GetAttribute("nodetype") != "common")
            {
                upadatexml(b_next, oldid);
            }
            doc_outline.Save(outline_xml);
        }
Example #13
0
        private XmlNode getselectnode(outline ss) //获取outline选中的节点
        {
            XmlNode     select  = null;
            XmlNodeList xmllist = root_outline.SelectNodes(getparent(ss));

            foreach (XmlNode ses in xmllist)
            {
                if (((XmlElement)ses).GetAttribute("id") == ss.secid)
                {
                    select = ses;
                    break;
                }
            }
            return(select);
        }
Example #14
0
        public outline outline_chapter_add(outline select, string newname) //增加章节
        {
            doc_outline = new XmlDocument();
            doc_outline.Load(outline_xml);
            root_outline = doc_outline.DocumentElement;
            doc_contex   = new XmlDocument();
            doc_contex.Load(idis_xml);
            root_contex = doc_contex.DocumentElement.SelectSingleNode("Papersection");
            string  id          = (int.Parse(select.secid) + 1).ToString();
            string  href        = id;
            string  newname_add = id + " " + newname;
            string  nodename    = "Chapter";
            string  type        = "Chapter";
            outline newone      = new outline()
            {
                Name1    = newname_add,
                toollip  = newname_add,
                parent   = null,
                secid    = id,
                nodename = nodename,
                href     = href,
                type     = outlinetype.Chapter
            };
            XmlElement xe1 = doc_outline.CreateElement(nodename); //创建一个节点

            xe1.SetAttribute("id", id);                           //设置该节点id属性
            xe1.SetAttribute("sec-title", newname);               //设置该节点name属性
            xe1.SetAttribute("nodetype", type);                   //设置该节点type属性
            xe1.SetAttribute("href", href);                       //设置节点的href
            XmlNode bb = getselectnode(select);

            root_outline.InsertAfter(xe1, bb);
            doc_outline.Save(outline_xml);
            XmlDocument doc = new XmlDocument();

            doc.Load(MainWindow.idd_href + "/webTemplateStyle.xml");
            XmlNode    style = doc.DocumentElement.SelectSingleNode(type);
            XmlElement xe2   = doc_contex.CreateElement(nodename);

            xe2.SetAttribute("id", id);
            xe2.InnerXml = style.InnerXml;
            //root_contex.InsertAfter(xe2);
            doc_contex.Save(idis_xml);
            return(newone);
        }
Example #15
0
        public void outline_node_modify(outline select, string newname) //修改outline的接点名称
        {
            // doc_contex = new XmlDocument();
            //doc_contex.Load(idis_xml);
            // root_contex = doc_contex.DocumentElement.SelectSingleNode("Papersection");
            //string cc = getparent(select);
            XmlNode a = getselectnode(select);
            //root_outline = doc.DocumentElement;
            //XmlNodeList xmllist = root_outline.SelectSingleNode(cc).ChildNodes;
            string id = select.secid;
            //string newname_add = id + " " + newname;
            // string href = select.href + "/" + id;
            string nodename = "Section" + id;

            // string type = ((outlinetype)((int)select.type + 1)).ToString();
            //XmlElement xe1 =(XmlElement)root_outline.SelectSingleNode(cc);
            ((XmlElement)a).SetAttribute("sec-title", newname);
            doc_outline.Save(outline_xml);
        }
 private void savexml(outline sel, string html)
 {
     //outline sel = tree6.SelectedItem as outline;
     if (sel.nodename != "Cover" || sel.nodename != "Statement")
     {
         //string html = invoker.InvokeScript("getContent").ToString();
         if (sel.type == outlinetype.common)
         {
             Savexml cxml = new Savexml(sel.nodename, html, sel.secid);
             cxml.savexml();
             //ThreadPool.QueueUserWorkItem(status => cxml.savetem());
         }
         else
         {
             Savexml sxml = new Savexml("Papersection/" + sel.nodename, html, sel.secid);
             sxml.savexml();
             // ThreadPool.QueueUserWorkItem(status => sxml.savetem());
         }
     }
 }
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            //MessageBox.Show(Environment.GetFolderPath(Environment.SpecialFolder.Personal));
            outline sel = tree6.SelectedItem as outline;

            if (sel.nodename != "Cover" || sel.nodename != "Statement")
            {
                string html = invoker.InvokeScript("getContent").ToString();
                if (sel.type == outlinetype.common)
                {
                    Savexml cxml = new Savexml(sel.nodename, html, sel.secid);
                    cxml.savexml();
                }
                else
                {
                    Savexml sxml = new Savexml("Papersection/" + sel.nodename, html, sel.secid);
                    sxml.savexml();
                }
            }
        }
Example #18
0
        public void update(outline ch)
        {
            XmlDocument doc = new XmlDocument();

            if (ch.context == null)
            {
                article dd = new article(ch.secid, "Papersection/" + ch.nodename);
                ch.context = dd.getcontext();
                doc.LoadXml(ch.context);
            }
            else
            {
                doc.LoadXml(ch.context.Replace("&", "&amp;"));
            }
            XmlNode xml = doc.DocumentElement.FirstChild;

            do
            {
                XmlNodeList sups = xml.SelectNodes("span/span/sup");
                if (sups.Count > 0)
                {
                    foreach (XmlNode cc in sups)
                    {
                        if (cc.Attributes.Count != 0)
                        {
                            referStartNumber++;
                            //refer_context=MainWindow.tree5_sel.Refer[MainWindow.tree5_sel.Refernumber[referStartNumber - 1] - 1].Context;
                            MainWindow.tree5_sel.Refernumber.Add(cd[int.Parse(((XmlElement)cc).GetAttribute("id")) - 1]);
                            ((XmlElement)cc).SetAttribute("id", referStartNumber.ToString());
                            ((XmlElement)cc).SetAttribute("onClick", "window.external.MN_showreferinfo(\"" + referStartNumber.ToString() + "\")");
                            cc.InnerText = "[" + referStartNumber + "]";
                        }
                    }
                }
                xml = xml.NextSibling;
            } while (xml != null);
            ch.context = doc.InnerXml.Replace("&amp;", "&");
        }
Example #19
0
 public pictureandchart_title(outline sel)
 {
     chapter            = getchapter(sel);
     chapter.CatalogFig = new List <Picture_ChartInfo>();
 }
        }  //增加idis项

        private void tree6_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            //ThreadPool.QueueUserWorkItem(status=>savexml(tree6_sel));
            if (issave == true)
            {
                // if(savecontext!=null)
                if (tree6_sel.type != outlinetype.empty && tree6_sel.Name1 != null)
                {
                    savecontext = invoker.InvokeScript("getContent").ToString();
                    savexml(tree6_sel, savecontext);
                }
            }
            try
            {
                tree6_sel     = this.tree6.SelectedItem as outline;
                textBox2.Text = tree6_sel.Name1;
                //tree6_sel.Name1 = "1111";
                //tree6_sel = tree6.SelectedItem as outline;
                if (tree6_sel.type != outlinetype.common)
                {
                    this.tree6.ContextMenu = c5;
                }
                else
                {
                    this.tree6.ContextMenu = null;
                }
                // iDissertation ccc = tree5.SelectedItem as iDissertation;
                if (tree6_sel.Name1.Contains("封面") == true || tree6_sel.nodename == "Statement")
                {
                    //string filepath = item_Directory;
                    // cd = "../../" + filepath + "/article_xml/";
                    //string cccc = ccc.href;
                    string cd = idd_href + "/" + tree6_sel.href;
                    //cd = cd + cc.href.Replace("..", "");
                    this.webBrowser1.Navigate(@cd);
                    web_show = true;
                }
                else
                {
                    if (web_show)
                    {
                        this.webBrowser1.Navigate("file:///F:/ueditor1_3_6-src_tofuchangli/ueditor1_3_6-src/index.html");
                        web_show = false;
                    }
                    if (tree6_sel.type != outlinetype.common)
                    {
                        article dd = new article(tree6_sel.secid, "Papersection/" + tree6_sel.nodename);

                        if (invoker.WaitWebPageLoad() == true)
                        {
                            invoker.InvokeScript("setContent", dd.getcontext().Replace("&amp;", "&"));
                        }
                    }
                    else
                    {
                        article dd = new article(tree6_sel.nodename);

                        if (invoker.WaitWebPageLoad() == true)
                        {
                            invoker.InvokeScript("setContent", dd.getcontext_comm().Replace("&amp;", "&"));
                        }
                    }
                }
                issave = true;
            }
            catch
            {
                if (invoker.WaitWebPageLoad() == true)
                {
                    invoker.InvokeScript("setContent", "");
                }
            }
        }
Example #21
0
 public void updatetitle(outline ch)
 {
     try
     {
         XmlDocument doc = new XmlDocument();
         if (ch.context == null)
         {
             article dd = new article(ch.secid, "Papersection/" + ch.nodename);
             ch.context = dd.getcontext();
             doc.LoadXml(ch.context);
         }
         else
         {
             doc.LoadXml(ch.context.Replace("&", "&amp;"));
         }
         //XmlDocument doc = new XmlDocument();
         //doc.LoadXml(ch.context);
         XmlNodeList xml = doc.DocumentElement.SelectNodes("p");
         foreach (XmlNode xm in xml)
         {
             if (((XmlElement)xm).GetAttribute("name") == "msocaption")
             {
                 cou++;
                 Picture_ChartInfo newone = null;
                 ((XmlElement)xm).SetAttribute("id", cou.ToString());
                 xm.FirstChild.InnerText = "图" + chapter.secid.ToString() + "-" + cou.ToString() + " ";
                 XmlNode xms = xm.PreviousSibling.FirstChild.FirstChild.SelectSingleNode("img");
                 if (xms == null)
                 {
                     newone = new Picture_ChartInfo()
                     {
                         ownsection = ch.secid,
                         title      = xm.InnerText,
                         path       = ""
                     }
                 }
                 ;
                 else
                 {
                     newone = new Picture_ChartInfo()
                     {
                         ownsection = ch.secid,
                         title      = xm.InnerText,
                         path       = ((XmlElement)xms).GetAttribute("src")
                     }
                 };
                 chapter.CatalogFig.Add(newone);
             }
         }
         ch.context = doc.InnerXml.Replace("&amp;", "&");
         foreach (outline ou in ch.children)
         {
             updatetitle(ou);
         }
     }
     catch
     {
         ;
     }
     //    ;
 }
Example #22
0
        } //获取选中节点的父类

        private ObservableCollection <outline> GenerateTreeViewItems1()
        {
            ObservableCollection <outline> cc = new ObservableCollection <outline>();
            XmlDocument doc = new XmlDocument();

            doc.Load(MainWindow.idd_href + "\\iDisseration_outline.xml");
            //Console.WriteLine("Begin reading xml");
            // XmlElement rootElem = doc.DocumentElement;
            //XmlNodeList section = rootElem.GetElementsByTagName("section");
            //List<outline> cc = new List<outline>();
            XmlNode     root    = doc.DocumentElement;
            XmlNodeList xmllist = root.ChildNodes;

            foreach (XmlNode xm in xmllist)
            {
                if (xm.Name.Contains("Chapter") == false)
                {
                    outline newnoe = new outline()
                    {
                        secid    = ((XmlElement)xm).GetAttribute("id"),
                        Name1    = xm.InnerText,
                        nodename = xm.Name,
                        toollip  = xm.InnerText,
                        type     = (outlinetype)Enum.Parse(typeof(outlinetype), ((XmlElement)xm).GetAttribute("nodetype")),
                        href     = ((XmlElement)xm).GetAttribute("href"),
                        parent   = null
                    };
                    cc.Add(newnoe);
                    // Console.WriteLine(xm.Name);
                    // Console.WriteLine(xm.InnerText);
                }
                else
                {
                    outline chapter = new outline()
                    {
                        secid    = ((XmlElement)xm).GetAttribute("id"),
                        Name1    = ((XmlElement)xm).GetAttribute("id") + " " + ((XmlElement)xm).GetAttribute("sec-title"),
                        nodename = xm.Name,
                        href     = ((XmlElement)xm).GetAttribute("href"),
                        toollip  = ((XmlElement)xm).GetAttribute("sec-title"),
                        type     = outlinetype.Chapter,
                        parent   = null
                    };
                    cc.Add(chapter);
                    //Console.WriteLine(xm.Name);
                    XmlNodeList xml = xm.ChildNodes;

                    foreach (XmlNode xms in xml)
                    {
                        string  title = ((XmlElement)xms).GetAttribute("sec-title");
                        outline aa    = new outline()
                        {
                            secid    = ((XmlElement)xms).GetAttribute("id"),
                            Name1    = ((XmlElement)xms).GetAttribute("sec-title"),
                            nodename = xms.Name,
                            href     = ((XmlElement)xms).GetAttribute("href"),
                            toollip  = title,
                            type     = outlinetype.Section1,
                            parent   = chapter
                        };
                        chapter.children.Add(getnodes(xms, chapter));
                    }
                }
            }
            return(cc);
        }