コード例 #1
0
		// Shared initialization code
		void Initialize () {
			SortNotesIntoOrder (AppDelegate.Notes);
			//TODO: Tags are not working properly
			this.tags = AppDelegate.NoteEngine.GetTags ();
			Tags.Tag systemTag = new Tags.Tag ("All Notebooks");
			this.tags.Add (systemTag);

			_sharedDocumentController = (NSDocumentController)NSDocumentController.SharedDocumentController;
			AppDelegate.NoteEngine.NoteRemoved += HandleNoteRemoved;
			AppDelegate.NoteEngine.NoteAdded += HandleNoteAdded;
			AppDelegate.NoteEngine.NoteUpdated += HandleNoteUpdated;
		}
コード例 #2
0
 private void RemoveNoteFromSystemMapping(Note note, Tag tag)
 {
     if (internal_tag_to_notes_mapping.ContainsKey (tag.NormalizedName) && internal_tag_to_notes_mapping[tag.NormalizedName].Contains (note)) {
         internal_tag_to_notes_mapping[tag.NormalizedName].Remove (note);
         Console.WriteLine ("Removed Note {0} from Tag {1}", note.Title, tag.NormalizedName);
     } else {
         Console.WriteLine ("Note {0} not removed from Tag {1}", note.Title, tag.NormalizedName);
     }
 }
コード例 #3
0
        private void AddTagMap(string tag_name, Note note)
        {
            Tag t = null;
            /* whether or not a tag was created */
            bool tag_added = false;

            if (tag_name == null)
                throw new ArgumentNullException ("TagManager.GetOrCreateTag () called with a null tag name.");

            if (note == null)
                throw new ArgumentNullException ("TagManager.AddTagMap () called with null Note.");

            string normalized_tag_name = tag_name.Trim ().ToLower ();
            if (normalized_tag_name == String.Empty)
                throw new ArgumentException ("TagManager.GetOrCreateTag () called with an empty tag name.");

            if (normalized_tag_name.StartsWith (Tag.SYSTEM_TAG_PREFIX) || normalized_tag_name.Split (':').Length > 2) {
                lock (tag_locker) {
                    if (!internal_tag_list.ContainsKey (normalized_tag_name)) {
                        t = new Tag (normalized_tag_name);
                        internal_tag_list.Add (normalized_tag_name, t);
                        tag_added = true;
                        AddNoteToInternalTagMapping (normalized_tag_name, note);
                    }
                }
            }

            // otherwise the tag is normal and we need to add it to the normal tag list.
            lock (tag_locker) {
                if (!tag_list.ContainsKey (normalized_tag_name)) {
                    t = new Tag (tag_name.Trim ());
                    tag_list.Add (normalized_tag_name, t);
                    tag_added = true;
                    AddNoteToTagMapping (normalized_tag_name, note);
                }
            }
            if (tag_added && TagAdded != null)
                TagAdded (t);
        }
コード例 #4
0
        private Tag GetOrCreateTag(string tag_name, Note note)
        {
            /* whether or not a tag was created */
            bool tag_added = false;
            Tag t = null;
            if (tag_name == null)
                throw new ArgumentNullException ("TagManager.GetOrCreateTag () called with a null tag name.");

            string normalized_tag_name = tag_name.Trim ().ToLower ();
            if (normalized_tag_name == String.Empty)
                throw new ArgumentException ("TagManager.GetOrCreateTag () called with an empty tag name.");

            if (normalized_tag_name.StartsWith (Tag.SYSTEM_TAG_PREFIX) || normalized_tag_name.Split (':').Length > 2) {
                lock (tag_locker) {
                    if (internal_tag_list.ContainsKey (normalized_tag_name)) {
                        if (note != null)
                            AddNoteToInternalTagMapping (normalized_tag_name, note);
                        return internal_tag_list [normalized_tag_name];
                    }
                    else {
                        t = new Tag (normalized_tag_name);
                        internal_tag_list.Add (normalized_tag_name, t);
                        tag_added = true;
                        if (note != null)
                            AddNoteToInternalTagMapping (normalized_tag_name, note);
                        return t;
                    }
                }
            }

            lock (tag_locker) {
                t = GetTag (tag_name);
                if (t == null) {
                    t = new Tag (tag_name.Trim ());
                    tag_list.Add (normalized_tag_name, t);
                    tag_added = true;
                }

                if (note != null)
                    AddNoteToTagMapping (normalized_tag_name, note);
            }
            if (tag_added && TagAdded != null)
                TagAdded (t);
            return t;
        }
コード例 #5
0
        // <summary>
        // This will remove the tag from every note that is currently tagged
        // and from the main list of tags.
        // </summary>
        public void RemoveTag(Tag tag)
        {
            bool tag_removed = false;
            if (tag == null)
                throw new ArgumentNullException ("TagManager.RemoveTag () called with a null tag");

            if(tag.IsProperty || tag.IsSystem){
                lock (tag_locker) {
                    // TODO: Remove tags from Notese contained within the list of Tags to Notes mapping
                    //FIXME: Really should have this fixed soon
                    internal_tag_list.Remove (tag.NormalizedName);
                    internal_tag_to_notes_mapping.Remove (tag.NormalizedName);
                    Console.WriteLine ("Tag Removed: {0}", tag.NormalizedName);
                    tag_removed = true;
                }
            }

            lock (tag_locker) {
                if (tag_list.ContainsKey (tag.NormalizedName)) {
                    //TODO: Remove tags from Notese contained within the list of Tags to Notes mapping
                    tag_list.Remove (tag.NormalizedName);
                    tag_to_notes_mapping.Remove (tag.NormalizedName);
                    tag_removed = true;
                    Console.WriteLine ("Tag Removed: {0}", tag.NormalizedName);
                }
            }
            if (tag_removed && TagRemoved != null)
                TagRemoved (tag);
        }