public static Note CreateExistingNote (NoteData data, string filepath, NoteManager manager) { if (data.CreateDate == DateTime.MinValue) data.CreateDate = File.GetCreationTime (filepath); if (data.ChangeDate == DateTime.MinValue) data.ChangeDate = File.GetLastWriteTime (filepath); return new Note (data, filepath, manager); }
public override void WriteFile (string write_file, NoteData note) { WriteCalled = true; FileWritten = write_file; NoteWritten = note; }
Note (NoteData data, string filepath, NoteManager manager) { this.data = new NoteDataBufferSynchronizer (data); this.filepath = filepath; this.manager = manager; // Make sure each of the tags that NoteData found point to the // instance of this note. foreach (Tag tag in data.Tags.Values) { AddTag (tag); } save_timeout = new InterruptableTimeout (); save_timeout.Timeout += SaveTimeout; childWidgetQueue = new Queue <ChildWidgetData> (); is_deleting = false; save_errordlg_active = false; }
/// <summary> /// Creates a New Note with the given values. /// </summary> /// <param name="title"> /// A <see cref="System.String"/> /// </param> /// <param name="filepath"> /// A <see cref="System.String"/> /// </param> /// <param name="manager"> /// A <see cref="NoteManager"/> /// </param> /// <returns> /// A <see cref="Note"/> /// </returns> public static Note CreateNewNote (string title, string filepath, NoteManager manager) { NoteData data = new NoteData (UrlFromPath (filepath)); data.Title = title; data.CreateDate = DateTime.Now; data.ChangeDate = data.CreateDate; return new Note (data, filepath, manager); }
void Write (XmlWriter xml, NoteData note) { xml.WriteStartDocument (); xml.WriteStartElement (null, "note", "http://beatniksoftware.com/tomboy"); xml.WriteAttributeString(null, "version", null, CURRENT_VERSION); xml.WriteAttributeString("xmlns", "link", null, "http://beatniksoftware.com/tomboy/link"); xml.WriteAttributeString("xmlns", "size", null, "http://beatniksoftware.com/tomboy/size"); xml.WriteStartElement (null, "title", null); xml.WriteString (note.Title); xml.WriteEndElement (); xml.WriteStartElement (null, "text", null); xml.WriteAttributeString ("xml", "space", null, "preserve"); // Insert <note-content> blob... xml.WriteRaw (note.Text); xml.WriteEndElement (); xml.WriteStartElement (null, "last-change-date", null); xml.WriteString ( XmlConvert.ToString (note.ChangeDate, DATE_TIME_FORMAT)); xml.WriteEndElement (); xml.WriteStartElement (null, "last-metadata-change-date", null); xml.WriteString ( XmlConvert.ToString (note.MetadataChangeDate, DATE_TIME_FORMAT)); xml.WriteEndElement (); if (note.CreateDate != DateTime.MinValue) { xml.WriteStartElement (null, "create-date", null); xml.WriteString ( XmlConvert.ToString (note.CreateDate, DATE_TIME_FORMAT)); xml.WriteEndElement (); } xml.WriteStartElement (null, "cursor-position", null); xml.WriteString (note.CursorPosition.ToString ()); xml.WriteEndElement (); xml.WriteStartElement (null, "selection-bound-position", null); xml.WriteString (note.SelectionBoundPosition.ToString ()); xml.WriteEndElement (); xml.WriteStartElement (null, "width", null); xml.WriteString (note.Width.ToString ()); xml.WriteEndElement (); xml.WriteStartElement (null, "height", null); xml.WriteString (note.Height.ToString ()); xml.WriteEndElement (); xml.WriteStartElement (null, "x", null); xml.WriteString (note.X.ToString ()); xml.WriteEndElement (); xml.WriteStartElement (null, "y", null); xml.WriteString (note.Y.ToString ()); xml.WriteEndElement (); if (note.Tags.Count > 0) { xml.WriteStartElement (null, "tags", null); foreach (Tag tag in note.Tags.Values) { xml.WriteStartElement (null, "tag", null); xml.WriteString (tag.Name); xml.WriteEndElement (); } xml.WriteEndElement (); } xml.WriteStartElement (null, "open-on-startup", null); xml.WriteString (note.IsOpenOnStartup.ToString ()); xml.WriteEndElement (); xml.WriteEndElement (); // Note xml.WriteEndDocument (); }
public NoteDataBufferSynchronizer (NoteData data) { this.data = data; }
public static void Write (TextWriter writer, NoteData note) { Instance.WriteFile (writer, note); }
public void WriteFile (TextWriter writer, NoteData note) { using (var xml = XmlWriter.Create (writer, XmlEncoder.DocumentSettings)) Write (xml, note); }
public static void Write (string write_file, NoteData note) { Instance.WriteFile (write_file, note); }
public virtual void WriteFile (string write_file, NoteData note) { string tmp_file = write_file + ".tmp"; using (FileStream fs = new FileStream(tmp_file, FileMode.Create, FileAccess.Write)) { using (var xml = XmlWriter.Create (fs, XmlEncoder.DocumentSettings)) Write (xml, note); fs.Flush(true); } if (File.Exists (write_file)) { string backup_path = write_file + "~"; if (File.Exists (backup_path)) File.Delete (backup_path); // Backup the to a ~ file, just in case File.Move (write_file, backup_path); // Move the temp file to write_file File.Move (tmp_file, write_file); // Delete the ~ file File.Delete (backup_path); } else { // Move the temp file to write_file File.Move (tmp_file, write_file); } }
public static string WriteString(NoteData note) { StringWriter str = new StringWriter (); using (var xml = XmlWriter.Create (str, XmlEncoder.DocumentSettings)) Instance.Write (xml, note); str.Flush(); return str.ToString (); }
private NoteData Read (XmlTextReader xml, string uri, out string version) { NoteData note = new NoteData (uri); DateTime date; int num; version = String.Empty; while (xml.Read ()) { switch (xml.NodeType) { case XmlNodeType.Element: switch (xml.Name) { case "note": version = xml.GetAttribute ("version"); break; case "title": note.Title = xml.ReadString (); break; case "text": // <text> is just a wrapper around <note-content> // NOTE: Use .text here to avoid triggering a save. note.Text = xml.ReadInnerXml (); break; case "last-change-date": if (DateTime.TryParse (xml.ReadString (), out date)) note.ChangeDate = date; else note.ChangeDate = DateTime.Now; break; case "last-metadata-change-date": if (DateTime.TryParse (xml.ReadString (), out date)) note.MetadataChangeDate = date; else note.MetadataChangeDate = DateTime.Now; break; case "create-date": if (DateTime.TryParse (xml.ReadString (), out date)) note.CreateDate = date; else note.CreateDate = DateTime.Now; break; case "cursor-position": if (int.TryParse (xml.ReadString (), out num)) note.CursorPosition = num; break; case "selection-bound-position": if (int.TryParse (xml.ReadString (), out num)) note.SelectionBoundPosition = num; break; case "width": if (int.TryParse (xml.ReadString (), out num)) note.Width = num; break; case "height": if (int.TryParse (xml.ReadString (), out num)) note.Height = num; break; case "x": if (int.TryParse (xml.ReadString (), out num)) note.X = num; break; case "y": if (int.TryParse (xml.ReadString (), out num)) note.Y = num; break; case "tags": XmlDocument doc = new XmlDocument (); List<string> tag_strings = ParseTags (doc.ReadNode (xml.ReadSubtree ())); foreach (string tag_str in tag_strings) { Tag tag = TagManager.GetOrCreateTag (tag_str); note.Tags [tag.NormalizedName] = tag; } break; case "open-on-startup": bool isStartup; if (bool.TryParse (xml.ReadString (), out isStartup)) note.IsOpenOnStartup = isStartup; break; } break; } } return note; }
public void Construct () { data = new NoteData ("http://www.example.com/note"); note = new NoteDataBufferSynchronizer (data); }
public void Construct () { data = new NoteData ("http://www.example.com/note"); data.Text = "<note-content>Foo</note-content>"; note = new NoteDataBufferSynchronizer (data); buffer = new NoteBuffer (new TextTagTable ()); }
public void Construct () { note = new NoteData ("tomboy://www.example.com/note"); }