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


C# ApplicationClass.OpenHierarchy方法代码示例

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


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

示例1: ProcessRecord

        protected override void ProcessRecord( )
        {
            PublishFormat pf = PublishFormat.pfMHTML;
            bool publishWeb = false;

            //
            //  Figure out the publish format.
            //

            List<string> candidates = new List<string>( );
            Utilities.GetCandidatesForString(OutputFormats, _outputFormat, candidates);
            if ((candidates.Count > 1) || (candidates.Count == 0))
            {
                WriteError(new ErrorRecord(new ArgumentException("Format is ambiguous"),
                    "InvalidArgument",
                    ErrorCategory.InvalidArgument,
                    _outputFormat));
                return;
            }
            switch (candidates[0])
            {
                case "MHT":
                    pf = PublishFormat.pfMHTML;
                    break;

                case "PDF":
                    pf = PublishFormat.pfPDF;
                    break;

                case "DOC":
                    pf = PublishFormat.pfWord;
                    break;

                case "ONEPKG":
                    pf = PublishFormat.pfOneNotePackage;
                    break;

                case "XPS":
                    pf = PublishFormat.pfXPS;
                    break;
                    
                case "WEB":
                    publishWeb = true;
                    break;

                default:
                    throw new NotSupportedException( );
            }

            //
            //  Figure out what we're exporting.
            //

            Microsoft.Office.Interop.OneNote.ApplicationClass app = new ApplicationClass( );
            List<string> ids = new List<string>( );
            switch (ParameterSetName)
            {
                case "PSPath":
                    Utilities.GetOneNoteIdsForPsPath(this, _psPath, ids);
                    if ((ids.Count > 1) &&
                        !ShouldContinue("You specified multiple items to process, but only one will be converted. Continue?", "Convert"))
                    {
                        return;
                    }
                    if (ids.Count == 0)
                    {
                        Utilities.WriteInvalidPathError(this, _psPath);
                        return;
                    }
                    break;
                    
                case "OneNoteId":
                    ids.Add(_id);
                    break;

                case "NotebookPath":
                    string hierarchyId;
                    app.OpenHierarchy(_notebookPath, null, out hierarchyId, CreateFileType.cftNone);
                    WriteDebug("Will convert notebook: " + hierarchyId);
                    ids.Add(hierarchyId);
                    break;
            }

            //
            //  If we're doing change highlighting, then we need to know where the Unfiled Notes section
            //  is. We copy the page to that section, update the page XML to do the highlighting, etc.
            //

            if (_highlightChangesSince != DateTime.MaxValue)
            {
                throw new NotImplementedException( );
            }
            
            int progressSalt = 0;
            foreach (string id in ids)
            {
                if (!ShouldProcess(id))
                {
                    continue;
                }
//.........这里部分代码省略.........
开发者ID:c0ns0le,项目名称:OneNotePowerShellProvider,代码行数:101,代码来源:ExportOneNote.cs

示例2: ProcessRecord

 protected override void ProcessRecord( )
 {
     if (ShouldProcess( _fullName ))
     {
         ApplicationClass _app = new ApplicationClass( );
         string objectId;
         _app.OpenHierarchy(_fullName, null, out objectId, CreateFileType.cftNone);
         string hierarchyXml;
         _app.GetHierarchy(objectId, HierarchyScope.hsSelf, out hierarchyXml);
         XmlDocument hierarchyDoc = new XmlDocument( );
         hierarchyDoc.LoadXml(hierarchyXml);
         string notebookName = hierarchyDoc.DocumentElement.Attributes["name"].Value;
         WriteObject("OneNote:\\" + notebookName);
     }
 }
开发者ID:c0ns0le,项目名称:OneNotePowerShellProvider,代码行数:15,代码来源:OpenCloseOneNote.cs

示例3: NewItem

        /// <summary>
        /// Creates a new OneNote "thing" -- notebook, section, section group, or page.
        /// </summary>
        /// <param name="path">The path of the new thing to create.</param>
        /// <param name="itemTypeName">The type of thing to create.</param>
        /// <param name="newItemValue">In the notebook creation case, this parameter is the directory in which
        /// the notebook directory will get created.</param>
        protected override void NewItem(string path, string itemTypeName, object newItemValue)
        {
            WriteDebug("In NewItem. Path = " + path);
            string parentPath = SessionState.Path.ParseParent(path, null);
            string childName = SessionState.Path.ParseChildName(path);
            WriteDebug("Parsed path as: Parent = " + parentPath + ", child = " + childName);
            XmlNode parent = getOneNoteNode(parentPath);
            if (parent == null)
            {
                WriteInvalidPathError(parentPath);
                return;
            }

            //
            //  Find out what we're creating. Per guidelines, itemTypeName is case-insensitive,
            //  and it's sufficient for it to be enough characters to disambiguate between the options
            //  in OneNoteTypes.
            //

            List<string> candidates = new List<string>( );
            Microsoft.Office.OneNote.PowerShell.Utilities.GetCandidatesForString(OneNoteTypes, itemTypeName, candidates);
            if (candidates.Count > 1)
            {
                WriteError(new ErrorRecord(
                    new ArgumentException("itemTypeName is ambiguous"),
                    "InvalidArgument",
                    ErrorCategory.InvalidArgument,
                    itemTypeName)
                );
                return;
            }
            if (candidates.Count == 0)
            {
                WriteError(new ErrorRecord(
                    new ArgumentException("itemTypeName not a recognized OneNote type"),
                    "InvalidArgument",
                    ErrorCategory.InvalidArgument,
                    itemTypeName)
                );
                return;
            }
            string selectedType = candidates[0];
            Microsoft.Office.Interop.OneNote.ApplicationClass app = new ApplicationClass( );
            string id;
            switch (selectedType)
            {
                case "Notebook":
                    string notebookPath = SessionState.Path.Combine((string)newItemValue, childName);
                    WriteVerbose("Creating notebook in " + notebookPath);
                    app.OpenHierarchy(notebookPath, "", out id, CreateFileType.cftNotebook);
                    break;

                case "Directory":
                case "Section":
                    if (parent.LocalName != "Notebook")
                    {
                        WriteError(new ErrorRecord(new ArgumentException(path + " is not a valid section path: It is not contained in a notebook."),
                            "InvalidArgument",
                            ErrorCategory.InvalidArgument,
                            path));
                        return;
                    }
                    WriteVerbose("Creating section " + childName +
                        " in notebook ID " + parent.Attributes["ID"].Value);
                    app.OpenHierarchy(childName + ".one",
                        parent.Attributes["ID"].Value,
                        out id, 
                        CreateFileType.cftSection);
                    break;

                case "Page":

                    //
                    //  Creating pages is a bit more work than creating notebooks or sections. I need to build
                    //  up a bit of XML describing the page creation operation.
                    //

                    WriteVerbose("Creating page " + childName);
                    string parentId = parent.Attributes["ID"].Value;
                    OneNoteXml command = new OneNoteXml( );
                    XmlElement section = command.CreateSection(null, parentId);
                    command.Document.AppendChild(section);
                    XmlElement page = command.CreatePage(childName, null);
                    section.AppendChild(page);
                    string xml = command.Document.OuterXml;
                    WriteVerbose(xml);
                    app.UpdateHierarchy(xml);
                    break;
            }
        }
开发者ID:c0ns0le,项目名称:OneNotePowerShellProvider,代码行数:97,代码来源:OneNoteProvider.cs


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