Exemple #1
0
        public string GetObjectId(string parentId,
                                  Microsoft.Office.Interop.OneNote.HierarchyScope scope, string objectName)
        {
            var doc      = GetXDocument(parentId, scope);
            var nodeName = "";

            switch (scope)
            {
            case (Microsoft.Office.Interop.OneNote.HierarchyScope.hsNotebooks):
                nodeName = "Notebook";
                break;

            case (Microsoft.Office.Interop.OneNote.HierarchyScope.hsPages):
                nodeName = "Page";
                break;

            case (Microsoft.Office.Interop.OneNote.HierarchyScope.hsSections):
                nodeName = "Section";
                break;

            default:
                return(null);
            }

            var node = doc.Descendants(ns + nodeName).Where(n => n.Attribute("name").Value == objectName).FirstOrDefault();

            if (node == null)
            {
                return(null);
            }
            else
            {
                return(node.Attribute("ID").Value);
            }
        }
Exemple #2
0
        public string GetNodeNameBasedOnScope(Microsoft.Office.Interop.OneNote.HierarchyScope scope)
        {
            string nodeName;

            switch (scope)
            {
            case (Microsoft.Office.Interop.OneNote.HierarchyScope.hsNotebooks):
                nodeName = "Notebook";
                break;

            case (Microsoft.Office.Interop.OneNote.HierarchyScope.hsPages):
                nodeName = "Page";
                break;

            case (Microsoft.Office.Interop.OneNote.HierarchyScope.hsSections):
                nodeName = "Section";
                break;

            case (Microsoft.Office.Interop.OneNote.HierarchyScope.hsChildren):
                nodeName = "OEChildren";
                break;


            default:
                return(nodeName = "");
            }

            return(nodeName);
        }
Exemple #3
0
        public XDocument GetXDocument(string parentId, Microsoft.Office.Interop.OneNote.HierarchyScope scope)
        {
            string xml;

            onenoteApp.GetHierarchy(parentId, scope, out xml);

            var doc = XDocument.Parse(xml);

            return(doc);
        }
Exemple #4
0
        public List <string> GetChildObjectNames(string parentId,
                                                 Microsoft.Office.Interop.OneNote.HierarchyScope scope)
        {
            var doc      = GetXDocument(parentId, scope);
            var nodeName = GetNodeNameBasedOnScope(scope);

            var names = doc.Descendants(ns + nodeName)
                        .Select(n => n.Attribute("name").Value)
                        .ToList();

            return(names);
        }
Exemple #5
0
        public List <string> GetChildObjectIds(string parentId,
                                               Microsoft.Office.Interop.OneNote.HierarchyScope scope,
                                               ObjectType objectType)
        {
            var doc      = GetXDocument(parentId, scope);
            var nodeName = GetNodeNameBasedOnObjectType(objectType);

            var names = doc.Descendants(ns + nodeName)
                        .Where(q => q.Attribute("ID") != null)
                        .Select(q => q.Attribute("ID").Value)
                        .ToList();

            return(names);
        }
Exemple #6
0
        public IDictionary <string, string> GetChildObjectMap(
            string parentId,
            Microsoft.Office.Interop.OneNote.HierarchyScope scope,
            ObjectType requestedObject)
        {
            var doc      = GetXDocument(parentId, scope);
            var nodeName = GetNodeNameBasedOnObjectType(requestedObject);

            var result = new Dictionary <string, string>();
            var pool   = doc.Descendants(ns + nodeName).ToList();

            foreach (var item in pool)
            {
                var id = item.Attribute("ID").Value;
                if (id != null && id != parentId)
                {
                    result.Add(id, item.Attribute("name").Value);
                }
            }

            return(result);
        }
Exemple #7
0
 public string GetObjectId(Microsoft.Office.Interop.OneNote.HierarchyScope scope, string objectName)
 {
     return(GetObjectId(null, scope, objectName));
 }