Blame | Last modification | View Log | RSS feed
using System;using System.Collections.Generic;using System.Collections;using System.Text;using System.Text.RegularExpressions;using System.IO;using System.Xml;using com.jamiehill;using Microsoft.Win32;using System.Drawing;using System.Drawing.Imaging;using System.Drawing.Drawing2D;using System.Threading;using System.Windows.Forms;namespace ConsoleApplication1 {class node {OneNoteXMLObject onxo;node parent = null;System.Collections.ArrayList folders = null;System.Collections.ArrayList pages = null;int level = 0;bool root = false;bool leaf = false;node next = null;node previous = null;public node() {}}class Program {static void Main(string[] args) {JPHOneNoteUtilities onp = new JPHOneNoteUtilities();string on_xml = null;RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Office\12.0\OneNote\AddIns\{90f74a17-351b-4d81-85a1-740d3652de8a}");Object dtv = rk.GetValue("DefaultType", ".deftxt");Object dtt = rk.GetValue("DefaultTemplate", "deftemplate.txt");Object dtd = rk.GetValue("TemplateDirectory", "deftemplates");Object cbx = rk.GetValue("InsertAtTheTop", "1");System.Console.WriteLine(dtv.ToString());System.Console.WriteLine(dtt.ToString());System.Console.WriteLine(dtd.ToString());System.Console.WriteLine(cbx.ToString());System.Console.WriteLine(System.Guid.NewGuid());System.Console.ReadLine();Environment.Exit(0);string id = "20070118";OneNoteXMLObject nonxo = onp.GetOneNoteXMLObjectByPage(onp.GetNodeSet("Page"), ref id);string page = onp.GetPageContent(nonxo.id);System.Console.WriteLine("Page: " + page);StreamWriter os = new StreamWriter(@"C:\onenote.xml", false);os.Write(page);os.Close();XmlDocument xd = new XmlDocument();xd.LoadXml(page);XmlNamespaceManager nsmgr = new XmlNamespaceManager(xd.NameTable);nsmgr.AddNamespace("one", onp.GetOneNoteNamespace());XmlNodeList nl = xd.GetElementsByTagName("one:T");System.Console.WriteLine(nl.Count);int total = nl.Count;int seconds = 0;for (int i = 0; i < total; i++) {// if (n.Attributes.GetNamedItem("name") == null) value = "Untitled";// else value = n.Attributes.GetNamedItem("name").Value;string e = nl[i].InnerXml;// 7:35-10:00Regex re = new Regex(@"(?<h1>\d{1,2}):(?<m1>\d{2})-(?<h2>\d{1,2}):(?<m2>\d{2})");MatchCollection m = re.Matches(e);//System.Console.WriteLine("Match count: "+m.Count);foreach (Match im in m) {System.Console.WriteLine(im.Groups["h1"] + " - " + im.Groups["m1"] + " -- " + im.Groups["h2"] + " - " + im.Groups["m2"]);int sh = System.Convert.ToInt32(im.Groups["h1"].ToString(),10);int sm = System.Convert.ToInt32(im.Groups["m1"].ToString(),10);int fh = System.Convert.ToInt32(im.Groups["h2"].ToString(), 10);int fm = System.Convert.ToInt32(im.Groups["m2"].ToString(), 10);int ssecs = (sh * 3600) + (sm * 60);int fsecs = (fh * 3600) + (fm * 60);seconds += fsecs - ssecs;}}DialogResult dr = MessageBox.Show("Total: " + seconds + " - div: "+ String.Format("{0:#.##}",seconds / 3600.00),"Time");//System.Console.WriteLine("onxo: "+nonxo.ToString());System.Console.ReadLine();String text = "stratus%20nine%20two_files/this is a file\nthis is another one stratus%20nine%20two_files/morefiles.hmtl";String extdir = "stratus nine two_files";String sp_extdir = Regex.Replace(extdir, " ", "%20");String dir = "c:/mydir";System.Console.WriteLine(sp_extdir);System.Console.WriteLine(text);//text = Regex.Replace(text, "(" + extdir + "/)", "file:///" + dir + "/$1", RegexOptions.Singleline);text = Regex.Replace(text, "(" + extdir + "|" + sp_extdir + "/)", "file:///" + dir + "/$1", RegexOptions.Singleline);System.Console.WriteLine(text);System.Console.ReadLine();return;System.Collections.ArrayList al = new ArrayList();for (int i = 0; i < 10; i++) {al.Add((string)"jamie" + i);}foreach (string str in (string[])al.ToArray(typeof(string))) {System.Console.WriteLine(str);}/*onp.GetPages(out on_xml);XmlDocument xd = new XmlDocument();xd.LoadXml(on_xml);XmlNamespaceManager nsmgr = new XmlNamespaceManager(xd.NameTable);nsmgr.AddNamespace("one", onp.GetOneNoteNamespace());XmlNodeList nl = xd.GetElementsByTagName("one:Notebook");myrecurse(nl[0], 0);*///System.Console.WriteLine(on_xml);System.Console.WriteLine("\nPress <enter> to exit");System.Console.ReadLine();}static public void myrecurse(XmlNode n, int level) {if (n == null) return;string indent = null;for (int i = 0; i < level; i++) indent += " ";//OneNoteXMLObject onxo = new OneNoteXMLObject(null, null, null, null, null, null, null, false);OneNoteXMLObject onxo = JPHOneNoteUtilities.GetOneNoteXMLAttributes(n);System.Console.WriteLine(onxo);//System.Console.ReadLine();string name = null;string value = null;if (n.Name == null) name = "Untitled page";else name = n.Name;if (n.Attributes.GetNamedItem("name") == null) value = "Untitled";else value = n.Attributes.GetNamedItem("name").Value;System.Console.WriteLine(indent + (level+1) + ": " + value + " -> " + name + " -> " + n.HasChildNodes);if (n.HasChildNodes) {myrecurse(n.FirstChild, level+1);XmlNode n_next = n.NextSibling;myrecurse(n_next, level);} else {XmlNode n_next = n.NextSibling;XmlNode n_last = null;while (true) {if (n_next == null || n_last == n_next) break;n_last = n_next;System.Console.WriteLine(indent + (level+1) + ": " + n_next.Attributes.GetNamedItem("name").Value + " -> " + n_next.Name + " -> " + n_next.HasChildNodes);n_next = n_next.NextSibling;}}}}}