Contains all pure note data, like the note title and note text.
コード例 #1
0
ファイル: NoteTests.cs プロジェクト: Dynalon/tomboy-library
        public void NoteHasUri()
        {
            var note = new Note ();
            var guid = note.Guid;

            Assert.AreEqual ("note://tomboy/" + guid, note.Uri);
        }
コード例 #2
0
 public static Note GetTesterNote()
 {
     if (note == null)
         note = new Note ("tomboy://90d8eb70-989d-4b26-97bc-ba4b9442e51d");
     SetUpNote ();
     return note;
 }
コード例 #3
0
		public BacklinkMenuItem (Note note, string title_search) :
			base (note.Title)
		{
			this.note = note;
			this.title_search = title_search;
			this.Image = new Gtk.Image (NoteIcon);
		}
コード例 #4
0
		public static void WatchNote (Note note)
		{
			if (!openNotes.Contains (note)) {
				openNotes.Add (note);
				UpdateWindowMenu ();
			}
		}
コード例 #5
0
ファイル: DtoConversionTests.cs プロジェクト: BooTeK/Rainy
        public void ConvertBackAndForth()
        {
            var tn1 = new Note () {
                Title = "This is my Title with Umlauts: äöü",
                Text = "This is my note body text.",
                CreateDate = DateTime.Now - new TimeSpan (365, 0, 0, 0),
                MetadataChangeDate = DateTime.Now,
                ChangeDate = DateTime.Now - new TimeSpan (14, 0, 0, 0)

                // TODO check why OpenOnStartup is of type string in Tomboy
                //OpenOnStartup = "true"
            };

            var dto_note = tn1.ToDTONote ();
            var tn2 = dto_note.ToTomboyNote ();

            // notes should be identical
            Assert.AreEqual (tn1.Guid, tn2.Guid);
            Assert.AreEqual (tn1.Uri, tn2.Uri);
            Assert.AreEqual (tn1.Title, tn2.Title);
            Assert.AreEqual (tn1.Text, tn2.Text);

            Assert.AreEqual (tn1.ChangeDate, tn2.ChangeDate);
            Assert.AreEqual (tn1.MetadataChangeDate, tn2.MetadataChangeDate);
            Assert.AreEqual (tn1.CreateDate, tn2.CreateDate);

            Assert.AreEqual (tn1.OpenOnStartup, tn2.OpenOnStartup);

            Assert.AreEqual (tn1.Tags.Keys, tn2.Tags.Keys);
        }
コード例 #6
0
		/// <summary>
		/// Exports a single Note to HTML in a specified location.
		/// </summary>
		public override void ExportSingleNote (Note note,
		                                string output_folder)
		{
			string output_path = output_folder + SanitizeNoteTitle (note.Title)
				+ "." + export_file_suffix;

			Logger.Debug ("Exporting Note '{0}' to '{1}'...", note.Title, output_path);

			StreamWriter writer = null;

			try {
				// FIXME: Warn about file existing.  Allow overwrite.
				File.Delete (output_path);
			} catch {
			}

			writer = new StreamWriter (output_path);

			WriteHTMLForNote (writer, note);

			if (writer != null)
				writer.Close ();

			return;
		}
コード例 #7
0
ファイル: NoteTests.cs プロジェクト: Dynalon/tomboy-library
 public void NoteEqualityOperator()
 {
     var note1 = new Note ();
     var note2 = note1;
     Assert.AreEqual (note1, note2);
     Assert.That (note1 == note2);
 }
コード例 #8
0
		public MyDocument (Note note) : base ()
		{
			// some contructors might pass in null and not an actual note.
			if (note != null) {
				this.currentNoteID = note.Uri;
				this.currentNote = note;
			}
		}
コード例 #9
0
        public override void SaveNote(Note note)
        {
            var db_note = note.ToDTONote ().ToDBNote (Username);

            db_note.EncryptedKey = GetEncryptedNoteKey (db_note);
            EncryptNoteBody (db_note);
            base.SaveDBNote (db_note);
        }
コード例 #10
0
ファイル: Utils.cs プロジェクト: robpvn/tomboy-library
 /// <summary>
 /// Gets the note file name from URI.
 /// </summary>
 /// <returns>
 /// The note file name from URI.
 /// </returns>
 /// <param name='note'>
 /// Note.
 /// </param>
 public static string GetNoteFileNameFromURI(Note note)
 {
     string name = "";
     int begin = note.Uri.LastIndexOf ("/");
     begin++;
     name = note.Uri.Substring (begin,(note.Uri.Length - begin));
     return name;
 }
コード例 #11
0
 public void Init()
 {
     tagMgr = TagManager.Instance;
     tag_google = tagMgr.GetOrCreateTag (TAG_NAME_GOOGLE);
     tag_school = new Tag ("School");
     note = TesterNote.GetTesterNote ();
     note.Tags.Add ("School", tag_school);
 }
コード例 #12
0
		public static bool HasChanged (Note note)
		{
			string original_xml = GetContent(note.CreateDate, note.Manager);
			if (GetContentWithoutTitle (note.TextContent) ==
			                GetContentWithoutTitle (XmlDecoder.Decode (original_xml))) {
				return false;
			}
			return true;
		}
コード例 #13
0
ファイル: DbStorage.cs プロジェクト: BooTeK/Rainy
        public void SaveNote(Note note)
        {
            var dbNote = note.ToDTONote ().ToDBNote (User);

            // unforunately, we can't know if that note already exist
            // so we delete any previous incarnations of that note and
            // re-insert
            db.Delete<DBNote> (n => n.CompoundPrimaryKey == dbNote.CompoundPrimaryKey);
            db.Insert (dbNote);
        }
コード例 #14
0
ファイル: NoteAddin.cs プロジェクト: MichaelAquilina/tomboy
		public void Initialize (Note note)
		{
			this.note = note;
			this.note.Opened += OnNoteOpenedEvent;

			Initialize ();

			if (note.IsOpened)
				OnNoteOpened ();
		}
コード例 #15
0
ファイル: Reader.cs プロジェクト: robpvn/tomboy-library
        /// <summary>
        /// Read the specified xml and uri.
        /// </summary>
        /// <description>XML is the raw Note XML for each note in the system.</description>
        /// <description>uri is in the format of //tomboy:NoteHash</description>
        /// <param name='xml'>
        /// Xml.
        /// </param>
        /// <param name='uri'>
        /// URI.
        /// </param>
        public static Note Read(XmlTextReader xml, string uri)
        {
            Note note = new Note (uri);
            DateTime date;
            int num;
            string 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 "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;
                    }
                    break;
                }
            }

            return note;
        }
コード例 #16
0
        public override void Initialize()
        {
            try {
                GlobalTodo = Note.Manager.Find(GLOBALTITLE);

                if(GlobalTodo == null)
                    GlobalTodo = Note.Manager.Create(GLOBALTITLE, GLOBALCONTENT);
            } catch (Exception e) {
                Console.WriteLine("Error at initialize: " + e);
            }
        }
コード例 #17
0
ファイル: DbStorage.cs プロジェクト: jonpolak/Rainy
        public void SaveNote(Note note)
        {
            var dbNote = note.ToDTONote ().ToDBNote ();
            dbNote.Username = Username;

            // unforunately, we can't know if that note already exist
            // so we delete any previous incarnations of that note and
            // re-insert
            db.Delete<DBNote> (n => n.Username == Username && n.Guid == dbNote.Guid);
            db.Insert (dbNote);
        }
コード例 #18
0
ファイル: NoteCreator.cs プロジェクト: robpvn/tomboy-library
        public static Note NewNote(string title, string body)
        {
            Note note = new Note ("tomboy://" + Guid.NewGuid ().ToString ());

            if (title != null)
                note.Title = title;

            if (body != null)
                note.Text = body;
            return note;
        }
コード例 #19
0
		public void RemoveBrokenLinkTag (Note note)
		{
			
			NoteTag broken_link_tag = note.TagTable.BrokenLinkTag;
			Gtk.TextIter note_start, note_end;
			
			// We get the whole note as a range
			// and then just remove the "broken link" tag from it
			note.Buffer.GetBounds (out note_start, out note_end);
			
			// Sweep 'em
			note.Buffer.RemoveTag (broken_link_tag,note_start,note_end);

			Logger.Debug ("Removed broken links from a note: " + note.Title);
		}
コード例 #20
0
        public static Note NewNote(string title, string body)
        {
            Note note = new Note ("note://tomboy/" + Guid.NewGuid ().ToString ());
            note.CreateDate = DateTime.UtcNow;

            if (title != null)
                note.Title = title;

            if (body != null)
                note.Text = title + "\n\n" + body;
            else
                note.Text = title + "\n\n";

            return note;
        }
コード例 #21
0
ファイル: Tray.cs プロジェクト: MichaelAquilina/tomboy
		static string GetDisplayName (Note note)
		{
			string display_name = note.Title;
			int max_length = (int) Preferences.Get (Preferences.MENU_ITEM_MAX_LENGTH);

			if (note.IsNew) {
				string new_string = Catalog.GetString (" (new)");
				max_length -= new_string.Length;
				display_name = Ellipsify (display_name, max_length)
					+ new_string;
			} else {
				display_name = Ellipsify (display_name, max_length);
			}

			return FormatForLabel (display_name);
		}
コード例 #22
0
ファイル: DbStorageTests.cs プロジェクト: rashoodkhan/Rainy
        public void DateUtcIsCorrectlyStored()
        {
            DbStorage storage = new DbStorage(connFactory, testUser.Username);

            var tomboy_note = new Note ();
            tomboy_note.ChangeDate = new DateTime (2000, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            tomboy_note.CreateDate = tomboy_note.ChangeDate;
            tomboy_note.MetadataChangeDate = tomboy_note.ChangeDate;

            storage.SaveNote (tomboy_note);
            var stored_note = storage.GetNotes ().Values.First ();

            storage.Dispose ();

            Assert.AreEqual (tomboy_note.ChangeDate, stored_note.ChangeDate.ToUniversalTime ());
        }
コード例 #23
0
        public void DeleteNote(Note note)
        {
            var dbNote = note.ToDTONote ().ToDBNote (this.Username);

            //			if (UseHistory) {
            //				var archived_note = new DBArchivedNote ().PopulateWith(dbNote);
            //				if (Manifest.NoteRevisions.ContainsKey (note.Guid)) {
            //					archived_note.LastSyncRevision = Manifest.NoteRevisions[note.Guid];
            //				}
            //				var stored_note = db.FirstOrDefault<DBArchivedNote> (n => n.CompoundPrimaryKey == archived_note.CompoundPrimaryKey);
            //				// if that revision already exists, do not store
            //				if (stored_note == null)
            //					db.Insert<DBArchivedNote> (archived_note);
            //			}

            db.Delete<DBNote> (n => n.CompoundPrimaryKey == dbNote.CompoundPrimaryKey);
        }
コード例 #24
0
        public NoteStatsDialog(Note note)
        {
            this.note = note;

            this.Build();

            SetTitle();

            Refresh();

            needs_refresh = false;

            note.Buffer.Changed += OnTextChanged;
            note.Buffer.MarkSet += OnMarkSet;
            note.Renamed += OnRenamed;

            GLib.Timeout.Add (500, OnAutoRefresh);
        }
コード例 #25
0
		public void HighlightWikiWords (Note note)
		{
			NoteTag broken_link_tag = note.TagTable.BrokenLinkTag;
			Gtk.TextIter note_start, note_end;
			
			note.Buffer.GetBounds (out note_start, out note_end);
			
			// HACK: The below is copied from Watchers.cs->ApplyWikiwordToBlock()
			// It turns WikiWords back into broken links after sweeping all broken links,
			// but only in case WikiWords are enabled.
			// Most probably there's more elegant way of doing this.
			
			const string WIKIWORD_REGEX = @"\b((\p{Lu}+[\p{Ll}0-9]+){2}([\p{Lu}\p{Ll}0-9])*)\b";

			Regex regex = new Regex (WIKIWORD_REGEX, RegexOptions.Compiled);
			
			NoteBuffer.GetBlockExtents (ref note_start,
			                            ref note_end,
			                            80 /* max wiki name */,
			                            broken_link_tag);
			
			for (Match match = regex.Match (note_start.GetText (note_end));
			     match.Success;
			     match = match.NextMatch ()) {
				System.Text.RegularExpressions.Group group = match.Groups [1];
				
				Logger.Debug ("Highlighting back wikiword: '{0}' at offset {1}",
				              group,
				              group.Index);
				
				Gtk.TextIter start_cpy = note_start;
				start_cpy.ForwardChars (group.Index);
				
				note_end = start_cpy;
				note_end.ForwardChars (group.Length);
				
				if (note.Manager.Find (group.ToString ()) == null) {
					note.Buffer.ApplyTag (broken_link_tag, start_cpy, note_end);
				}
			}
			/// End of hack
		}
コード例 #26
0
ファイル: TaskList.cs プロジェクト: rggjan/Tomboy-Todo-List
        /// <summary>
        /// Creates a new tasklists including all the given tasks.
        /// </summary>
        /// <param name="tasks">
        /// A <see cref="List<Task>"/>
        /// </param>
        public TaskList(Note note, List<Task> tasks, String name, Gtk.TextIter start)
        {
            ContainingNote = note;
            //TODO possible merge this with things below?
            Name = name;
            TaskListTag tag = (TaskListTag)ContainingNote.TagTable.CreateDynamicTag ("tasklist");

            NoteBuffer buffer = note.Buffer;

            Initialize (start, tag);

            var end = Start;
            if (tasks.Count == 0)
                name = name + "\n";

            buffer.Insert (ref end, name);
            start = Start;

            if (!end.EndsLine ())
                end.ForwardToLineEnd ();

            end.ForwardChar ();
            Buffer.ApplyTag (TaskListTag, start, end);

            Tasks = new List<Task> ();

            if (tasks.Count > 0)
                foreach (Task task in tasks) {
                    Tasks.Add (task);
                    task.RemoveTag (task.ContainingTaskList.Tag);
                    task.ContainingTaskList = this;

                    // This is required for intendation
                    this.Tag.Priority = 0;
                    task.ApplyTag (this.Tag);
                }

            else {
                end.BackwardChar ();
                AddTask (end);
            }
        }
コード例 #27
0
ファイル: NoteBuffer.cs プロジェクト: MatteoNardi/Tomboy
		public NoteBuffer (Gtk.TextTagTable tags, Note note)
: base (tags)
		{
			RegisterSerializeFormat ("text/html", (Gtk.TextBufferSerializeFunc) Delegate.CreateDelegate (typeof(Gtk.TextBufferSerializeFunc), this, "SerializeToHtml"));

			active_tags = new List<Gtk.TextTag> ();
			undo_manager = new UndoManager (this);

			InsertText += TextInsertedEvent;
			DeleteRange += RangeDeletedEvent;
			MarkSet += MarkSetEvent;

			TagApplied += OnTagApplied;

			tags.TagChanged += OnTagChanged;

			widgetQueue = new Queue <WidgetInsertData> ();
			widgetQueueTimeout = 0;

			this.note = note;
		}
コード例 #28
0
		/// <summary>
		/// Translate the note content from legacy XML format to WebKit
		/// </summary>
        	/// <param name = "note">
        	/// </param>
		public string From (Note note) {
            		if (note == null)
                		throw new ArgumentNullException("note");
            		/*
			 * I'm sure there must be a better way to do this.
			 * Basically the translator needs to be on this side of the library
			 * because when the sync service runs, it needs notes to be in their
			 * original format.
			 * 
			 * It seems very cludgy to do what I am doing here, but I don't know of another way.
			 * Aug 21, 2012 JJennings
			 */
            		StringBuilder sb = new StringBuilder();
            		StringWriter stringWriter = new StringWriter(sb);
            		XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter);
            		StringBuilder sbNoteText = new StringBuilder();
            		sbNoteText.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            		sbNoteText.AppendLine("<note version=\"0.3\" " +
					"xmlns:link=\"http://beatniksoftware.com/tomboy/link\" " +
					"xmlns:size=\"http://beatniksoftware.com/tomboy/size\" " +
					"xmlns=\"http://beatniksoftware.com/tomboy\">");
            		sbNoteText.AppendLine("<text xml:space=\"preserve\">");
            		sbNoteText.AppendLine("<note-content version=\"1\">");
            		sbNoteText.Append(note.Text);
            		sbNoteText.AppendLine("</note-content>");
            		sbNoteText.AppendLine("</text>");
            		sbNoteText.AppendLine("</note>");

            		StringReader stringReader = new StringReader(sbNoteText.ToString ());
            		XPathDocument doc;
            		try {
                		doc = new XPathDocument(stringReader);
                		xslTransformFrom.Transform(doc, null, xmlTextWriter);
            		} catch (Exception e) {
                		Logger.Error(e.Message, e, sbNoteText.ToString());
            		}
            		stringReader.Close();
            		return sb.ToString().Trim();
        	}
コード例 #29
0
ファイル: Tray.cs プロジェクト: MichaelAquilina/tomboy
		public NoteMenuItem (Note note, bool show_pin)
			: base (GetDisplayName(note))
		{
			this.note = note;
			Image = new Gtk.Image (note_icon);
#if HAS_GTK_2_16
			this.SetAlwaysShowImage (true);
#endif
			if (show_pin) {
				Gtk.HBox box = new Gtk.HBox (false, 0);
				Gtk.Widget child = Child;
				Remove (child);
				box.PackStart (child, true, true, 0);
				Add (box);
				box.Show();

				pinned = note.IsPinned;
				pin_img = new Gtk.Image(pinned ? pindown : pinup);
				pin_img.Show();
				box.PackStart (pin_img, false, false, 0);
			}
		}
コード例 #30
0
ファイル: Engine.cs プロジェクト: j-4/tomboy-library
        /// <summary>
        /// Saves the note.
        /// </summary>
        /// <param name='note'>
        /// Note.
        /// </param>
        /// <param name='update_dates'>
        /// By default true and can be omited. If set to false, do not update the ChangeDate
        /// and MetadataChangeDate fields. Usefull for pure data storage, and when syncing.
        /// </param>
        public void SaveNote(Note note, bool update_dates = true)
        {
            if (update_dates) {
                DateTime saveUtcNow = DateTime.UtcNow;
                note.ChangeDate = saveUtcNow;
            }

            /* Update the dictionary of notes */
            if (notes.ContainsKey (note.Uri))
                notes.Remove (note.Uri);
            notes.Add (note.Uri, note);
            tagMgr.AddTagMap (note);
            /* Save Note to Storage */
            this.storage.SaveNote (note);
            if (NoteUpdated != null)
                NoteUpdated (note);
        }