Exemplo n.º 1
0
        public void bookDeletedByUC(Notebook book)
        {
            NotebookControl _bookControl = null;

            if (bookControlMap.TryGetValue(book.name, out _bookControl))
            {
                bookControlMap.Remove(book.name);
                bookCount--;
                noteCount -= book.Notes.Count;
                notebookStackPanel.Controls.Remove(_bookControl);
                _bookControl.Dispose();
            }
            if (bookControlMap.Count == 0)
            {
                handleZeroBook();
            }
            else
            {
                setSelectedBook(this, bookControlMap[bookControlMap.Keys.ToArray()[0]].activeBook);
            }
            if (this.onBookDeleted != null)
            {
                this.onBookDeleted(this, book);
            }
        }
Exemplo n.º 2
0
        private bool addBookToPanel(Notebook book, bool update = false)
        {
            NotebookControl control  = null;
            var             valid    = true;
            var             valFound = bookControlMap.TryGetValue(book.name, out control);

            if (!valFound)
            {
                control = new NotebookControl(this, book);
                bookControlMap.Add(book.name, control);
                bookCount++;
                noteCount += book.Notes.Count;
                notebookStackPanel.Controls.Add(control);
            }
            if (valFound && !update)
            {
                MessageBox.Show("Note already exists, please try unique name", "Error");
                valid = false;
            }
            else if (update)
            {
                noteCount         -= control.activeBook.Notes.Count;
                control.activeBook = book;
                noteCount         += book.Notes.Count;
            }
            return(valid);
        }