示例#1
0
        public void Remove(Note note)
        {
            notes.Remove(note);
            Gtk.TreeIter treeIter = note.TreeIter;
            NotesStore.Remove(ref treeIter);
            RemoveTagsFrom(note);

            //TODO buffering or something?
            SaveToFile();
        }
示例#2
0
    protected void loadNotes()
    {
        store.Clear ();
        notesStore = new FilesystemNotesStore (this.notesDirPath);

        ArrayList notes = notesStore.getAllNotes ();

        for (int i = 0; i < notes.Count; i++) {
            Note noteEntry = notes[i] as Note;

            store.AddNode (new NoteNode (noteEntry));
        }
    }
示例#3
0
    protected void loadNotes()
    {
        store.Clear();
        notesStore = new FilesystemNotesStore(this.notesDirPath);

        ArrayList notes = notesStore.getAllNotes();

        for (int i = 0; i < notes.Count; i++)
        {
            Note noteEntry = notes[i] as Note;

            store.AddNode(new NoteNode(noteEntry));
        }
    }
示例#4
0
        static void Main(string[] args)
        {
            NotesStore notes = new NotesStore();

            notes.AddNote("completed", "Hello");
            notes.AddNote("completed", "Hello2");
            notes.AddNote("completed", "Hello3");
            notes.AddNote("active", "Hello4");
            notes.AddNote("completed", "Hello5");
            notes.AddNote("others", "Hello5");
            notes.AddNote("othe3rs", "Hello5");
            var newNotes = notes.GetNotes("completed");

            foreach (var note in newNotes)
            {
                Console.WriteLine(note);
            }
        }
示例#5
0
        public void Update(Note note, INote newNote)
        {
            note.Title = newNote.Title;
            NotesStore.SetValue(note.TreeIter, (int)NoteCols.Title, note.Title);

            note.Content = newNote.Content;

            //TODO: optimize this later.
            HashSet <string> intersectTags = new HashSet <string> (
                note.Tags.Intersect(newNote.Tags)
                );

            IEnumerable <string> obsoleteTags = note.Tags.Except(intersectTags);
            IEnumerable <string> newTags      = newNote.Tags.Except(intersectTags);

            RemoveTagsFrom(note, obsoleteTags);
            AddTagsFrom(note, newTags);

            note.Tags = newNote.Tags;
            SaveToFile();
        }
示例#6
0
        static void Main(string[] args)
        {
            var notesStoreObj = new NotesStore();
            var n             = int.Parse(Console.ReadLine());

            for (var i = 0; i < n; i++)
            {
                var operationInfo = Console.ReadLine().Split(' ');
                try
                {
                    if (operationInfo[0] == "AddNote")
                    {
                        notesStoreObj.AddNote(operationInfo[1], operationInfo.Length == 2 ? "" : operationInfo[2]);
                    }
                    else if (operationInfo[0] == "GetNotes")
                    {
                        var result = notesStoreObj.GetNotes(operationInfo[1]);
                        if (result.Count == 0)
                        {
                            Console.WriteLine("No Notes");
                        }
                        else
                        {
                            Console.WriteLine(string.Join(",", result));
                        }
                    }
                    else
                    {
                        Console.WriteLine("Invalid Parameter");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error: " + e.Message);
                }
            }
        }
示例#7
0
    public MainWindow() : base(Gtk.WindowType.Toplevel)
    {
        Build();

        Configuration cfg = new Configuration();

        noteslist.NodeSelection.Mode = SelectionMode.Single;
        noteslist.NodeStore          = Store;
        noteslist.AppendColumn("Title", new Gtk.CellRendererText(), "text", 0);
        noteslist.AppendColumn("Date modified", new Gtk.CellRendererText(), "text", 1);

        editor.WrapMode = WrapMode.Word;

        this.notesDirPath = cfg.notesDirPath;

        Console.WriteLine("Using notes at " + notesDirPath);

        if (!System.IO.File.Exists(notesDirPath))
        {
            System.IO.Directory.CreateDirectory(notesDirPath);
        }

        notesStore = new FilesystemNotesStore(notesDirPath);

        loadNotes();

        this.KeyPressEvent += new global::Gtk.KeyPressEventHandler(this.OnKeyPressEvent);

        noteslist.NodeSelection.Changed += new System.EventHandler(OnSelectionChanged);
        noteslist.KeyPressEvent         += new global::Gtk.KeyPressEventHandler(onListKeyEvent);
        noteslist.ButtonPressEvent      += new ButtonPressEventHandler(onListButtonPress);
        editor.Buffer.Changed           += new System.EventHandler(onTextChange);
        searchbar.Changed       += new global::System.EventHandler(onSearchBarChanged);
        searchbar.KeyPressEvent += new global::Gtk.KeyPressEventHandler(onSearchbarKeyEvent);

        searchbar.GrabFocus();
    }
示例#8
0
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();

        Configuration cfg = new Configuration ();

        noteslist.NodeSelection.Mode = SelectionMode.Single;
        noteslist.NodeStore = Store;
        noteslist.AppendColumn ("Title", new Gtk.CellRendererText (), "text", 0);
        noteslist.AppendColumn ("Date modified", new Gtk.CellRendererText (), "text", 1);

        editor.WrapMode = WrapMode.Word;

        this.notesDirPath = cfg.notesDirPath;

        Console.WriteLine ("Using notes at " + notesDirPath);

        if (!System.IO.File.Exists (notesDirPath))
            System.IO.Directory.CreateDirectory (notesDirPath);

        notesStore = new FilesystemNotesStore (notesDirPath);

        loadNotes ();

        this.KeyPressEvent += new global::Gtk.KeyPressEventHandler (this.OnKeyPressEvent);

        noteslist.NodeSelection.Changed += new System.EventHandler (OnSelectionChanged);
        noteslist.KeyPressEvent += new global::Gtk.KeyPressEventHandler (onListKeyEvent);
        noteslist.ButtonPressEvent += new ButtonPressEventHandler (onListButtonPress);
        editor.Buffer.Changed += new System.EventHandler (onTextChange);
        searchbar.Changed += new global::System.EventHandler (onSearchBarChanged);
        searchbar.KeyPressEvent += new global::Gtk.KeyPressEventHandler (onSearchbarKeyEvent);

        searchbar.GrabFocus ();
    }
 public DataService(NotesStore store)
 {
     _store = store;
     _notes = _store.Read();
     _instance = this;
 }