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


C# Application.GetHierarchy方法代码示例

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


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

示例1: GetPages

        private IEnumerable<object> GetPages()
        {
            var onenoteApp = new Application();

            string notebookXml;
            onenoteApp.GetHierarchy(null, HierarchyScope.hsPages, out notebookXml);

            var doc = XDocument.Parse(notebookXml);
            var ns = doc.Root.Name.Namespace;
            foreach (var notebookNode in
                doc.Descendants(ns + "Notebook").Select(node => node))
            {
                foreach (var sectionNode in notebookNode.Descendants(ns + "Section").Select(node => node))
                {
                    foreach (var pageNode in sectionNode.Descendants(ns + "Page").Select(node => node))
                    {
                        yield return new OneNotePage()
                            {
                                Id = pageNode.Attribute("ID").Value,
                                Name = pageNode.Attribute("name").Value,
                                SectionNodePath = sectionNode.Attribute("path").Value,
                                SectionName = sectionNode.Attribute("name").Value
                            };
                    }
                }
            }
        }
开发者ID:brunomlopes,项目名称:ILoveLucene,代码行数:27,代码来源:OneNotePageSource.cs

示例2: Main

        static void Main(string[] args)
        {
            // skipping error checking, just demonstrating using these APIs
            var app = new Application();

            // get the hierarchy
            string xmlHierarchy;
            app.GetHierarchy(null, HierarchyScope.hsPages, out xmlHierarchy);

            Console.WriteLine("Hierarchy:\n" + xmlHierarchy);

            // now find the current page, print out its ID
            var xdoc = XDocument.Parse(xmlHierarchy);
            var ns = xdoc.Root.Name.Namespace;

            var pageId = app.Windows.CurrentWindow.CurrentPageId;
            Console.WriteLine("Current Page ID: " + pageId);

            // get the page content, print it out
            string xmlPage;
            app.GetPageContent(pageId, out xmlPage);
            Console.WriteLine("Page XML:\n" + xmlPage);

            // sample - this is how to update content - normally you would modify the xml.
            app.UpdatePageContent(xmlPage);

            // bonus - if there are any images, get the binary content of the first one
            var xPage = XDocument.Parse(xmlPage);
            var xImage = xPage.Descendants(ns + "Image").FirstOrDefault();
            if (xImage != null)
            {
                var xImageCallbackID = xImage.Elements(ns + "CallbackID").First();
                var imageId = xImageCallbackID.Attribute("callbackID").Value;
                string base64Out;
                app.GetBinaryPageContent(pageId, imageId, out base64Out);

                Console.WriteLine("Image found, base64 data is:\n" + base64Out);
            }
        }
开发者ID:OneNoteDev,项目名称:VanillaAddIn,代码行数:39,代码来源:Program.cs

示例3: SendOneNote

        /// <summary>
        /// 发送至我的oneNote
        /// </summary>
        /// <param name="html"></param>
        private static void SendOneNote(string html,string url,string pageName)
        {
            var ls = new Application();
                string ls_return = "";
                var pageId = string.Empty;

                string notebookXml;
                ls.GetHierarchy(null, HierarchyScope.hsPages, out notebookXml);
                string existingPageId = string.Empty;
                var doc = XDocument.Parse(notebookXml);
                var ns = doc.Root.Name.Namespace;
                var session = doc.Descendants(ns + "Section").Where(n => n.Attribute("name").Value == pageName).FirstOrDefault();
                if (session != null)
                {
                    existingPageId = session.Attribute("ID").Value;
                    ls.CreateNewPage(existingPageId, out pageId, NewPageStyle.npsDefault);
                    var page = new XDocument(new XElement(ns + "Page",
                                              new XElement(ns + "Outline",
                                                new XElement(ns + "OEChildren",
                                                  new XElement(ns + "OE",
                                                    new XElement(ns + "T",
                                                      new XCData(html + url)))))));
                    page.Root.SetAttributeValue("ID", pageId);
                    try
                    {
                        ls.UpdatePageContent(page.ToString(), DateTime.MinValue);

                    }
                    catch (Exception ex)
                    {
                       ls.DeleteHierarchy(pageId, DateTime.MinValue);
                        Console.WriteLine(url+ex.Message);
                    }
                }
        }
开发者ID:zluckymn,项目名称:SimpleCrawler,代码行数:39,代码来源:Program.cs

示例4: GoThoughHierarchy

        public static void GoThoughHierarchy(Application application, Action<Application, string> pageFunction)
        {
            string hierarchyXml;
            application.GetHierarchy(null, HierarchyScope.hsPages, out hierarchyXml);
            XElement hierarchy = XElement.Parse(hierarchyXml);
            XNamespace oneNS = hierarchy.Name.Namespace;

            foreach (XElement notebook in hierarchy.Elements(oneNS + "Notebook"))
            {
                Debug.Indent();
                GoThoughNotebook(application, notebook, oneNS, pageFunction);
                Debug.Unindent();
            }
        }
开发者ID:evilch,项目名称:WordHighlight,代码行数:14,代码来源:HierarchyHelper.cs


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