/// <summary> /// Old Paper Todos Code. /// </summary> /// <param name="category"></param> /// <param name="data"></param> void saveRequestFile(string category, object data, StreamWriter log) { // make the pen request from the PGC data PenRequest req = new PenRequest(); req.Initialize(data); // put request information in an xml file (one per request) requestXMLFilePath = penRequestDir + @"XML\" + nowString + "_" + req.PenId + ".xml"; // xml writer XmlTextWriter xml = new XmlTextWriter(requestXMLFilePath, null); // start the xml document xml.WriteStartDocument(); xml.WriteStartElement("penRequest"); xml.WriteStartElement("requestInformation"); xml.WriteStartElement("universalTime"); xml.WriteStartAttribute("time"); xml.WriteValue(universalTimeString); xml.WriteEndElement(); xml.WriteStartElement("localTime"); xml.WriteStartAttribute("time"); xml.WriteValue(DateTime.Now.ToString()); xml.WriteEndElement(); log.WriteLine(); log.WriteLine("////////// Request at " + nowString); log.WriteLine("UniversalTime: " + universalTimeString); // more user feedback form.appendLine("Pen Synched on: " + DateTime.Now.ToString()); // Save the data to a pgc file by using Anoto.Util // writePGCFile(data, todosPath, nowString); log.WriteLine("PenID: " + req.PenId); log.WriteLine("NumPages: " + req.Pages.Count); // more user feedback form.appendLine("Number of Pages in this Session: " + req.Pages.Count); xml.WriteStartElement("penID"); xml.WriteStartAttribute("id"); xml.WriteValue(req.PenId); xml.WriteEndElement(); // end penID xml.WriteStartElement("numPages"); xml.WriteStartAttribute("num"); xml.WriteValue(req.Pages.Count); xml.WriteEndElement(); // end penID xml.WriteEndElement(); // end requestInformation // get the pages RequestPages pages = req.Pages; // process page addresses Anoto.Util.PageAddress pageAddressUtil = new Anoto.Util.PageAddress(); // go through all the pages IEnumerator pagesEnum = pages.GetEnumerator(); int pageCount = 0; while (pagesEnum.MoveNext()) { xml.WriteStartElement("page"); log.WriteLine("Page Object " + pageCount + ": "); Page page = (Page)pagesEnum.Current; log.WriteLine("\t" + page.PageAddress); // more user feedback form.appendLine("Processing Page with Address: " + page.PageAddress); // break down the page address int segment = pageAddressUtil.GetSegment(page.PageAddress); int shelf = pageAddressUtil.GetShelf(page.PageAddress); int book = pageAddressUtil.GetBook(page.PageAddress); int pageNum = pageAddressUtil.GetPage(page.PageAddress); int instance = pageAddressUtil.GetInstance(page.PageAddress); log.WriteLine("\t Segment: " + segment); log.WriteLine("\t Shelf: " + shelf); log.WriteLine("\t Book: " + book); log.WriteLine("\t Page: " + pageNum); xml.WriteStartAttribute("address"); xml.WriteValue(segment + "." + shelf + "." + book + "." + pageNum); xml.WriteEndAttribute(); xml.WriteStartAttribute("addressWithInstance"); xml.WriteValue(page.PageAddress); xml.WriteEndAttribute(); xml.WriteStartAttribute("segment"); xml.WriteValue(segment + ""); xml.WriteEndAttribute(); xml.WriteStartAttribute("shelf"); xml.WriteValue(shelf + ""); xml.WriteEndAttribute(); xml.WriteStartAttribute("book"); xml.WriteValue(book + ""); xml.WriteEndAttribute(); xml.WriteStartAttribute("page"); xml.WriteValue(pageNum); xml.WriteEndAttribute(); // the instance N of the page in the request formatted as X.X.X.X#N if (instance < 0) { log.WriteLine("\t Instance: NONE"); } else { log.WriteLine("\t Instance: " + instance); } PenStrokes strokes = page.PenStrokes; log.WriteLine("\tPen Strokes Count: " + strokes.Count); Bounds b = strokes.Bounds; log.WriteLine("\t Bounds Size: " + b.Width + " x " + b.Height); log.WriteLine("\t Bounds[ltrb]: " + b.Left + " " + b.Top + " " + b.Right + " " + b.Bottom); xml.WriteStartAttribute("minX"); xml.WriteValue(b.Left); xml.WriteStartAttribute("minY"); xml.WriteValue(b.Top); xml.WriteStartAttribute("maxX"); xml.WriteValue(b.Right); xml.WriteStartAttribute("maxY"); xml.WriteValue(b.Bottom); // deal with all of the strokes processStrokes(strokes, log, xml); // next page pageCount++; xml.WriteEndElement(); } // finish the xml document, Flush & Close xml.WriteEndDocument(); xml.Flush(); xml.Close(); }