Ejemplo n.º 1
0
        private void AddSection(bool rename = true)
        {
            if (SelectedNotebook == null)
            {
                AddNotebook();
                return;
            }

            NotebookSection section = new NotebookSection();

            section.NotebookID   = SelectedNotebook.ID;
            section.Title        = "New Section";
            section.LastModified = DateTime.UtcNow;
            section.Color        = NotesFunctions.GenerateSectionColor();

            NoteDatabase.Add(section);
            AddSection(section, true);
            AddPage();

            sectionTabs.UpdateLayout();

            if (rename)
            {
                RenameActiveSection();
            }
        }
Ejemplo n.º 2
0
        private void NewNote(Notebook nb = null, NotebookSection ns = null, NotebookPage page = null)
        {
            if (page == null)
            {
                page         = new NotebookPage();
                page.Created = page.LastModified = DateTime.UtcNow;
            }

            if (nb == null)
            {
                string nbID = Settings.LastOpenedNotebook;

                if (nbID != null)
                {
                    nb = NoteDatabase.GetNotebook(nbID);
                }

                if (nb == null)
                {
                    nb = NoteDatabase.FirstNotebook();
                }
            }

            if (nb == null)
            {
                nb       = new Notebook();
                nb.Title = "My Notebook";
                nb.Color = NotesFunctions.GenerateNotebookColor();
                NoteDatabase.Add(nb);
            }

            if (ns == null)
            {
                ns = NoteDatabase.GetSection(nb.LastSelectedSectionID);
            }

            if (ns == null)
            {
                ns            = new NotebookSection();
                ns.Title      = "Quick Notes";
                ns.NotebookID = nb.ID;
                ns.Color      = NotesFunctions.GenerateSectionColor();
                NoteDatabase.Add(ns);
            }

            page.SectionID = ns.ID;

            SelectedPage     = page;
            SelectedSection  = ns;
            SelectedNotebook = nb;
        }
Ejemplo n.º 3
0
        private void createButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(titleTextBox.Text) && contentTextBox.Document.Blocks.Count == 0)
            {
                TaskDialog td = new TaskDialog(
                    Application.Current.MainWindow,
                    "Empty Note",
                    "You are about to create a note with no title and no body.",
                    MessageType.Information,
                    true
                    );

                if (td.ShowDialog() != true)
                {
                    return;
                }
            }

            NotebookPage page = new NotebookPage();

            page.Title           = titleTextBox.Text;
            page.DetailsDocument = contentTextBox.Document;
            page.Created         = page.LastModified = DateTime.UtcNow;

            if (NotesView.LastUsedNotesView == null)
            {
                string nbID = Settings.LastOpenedNotebook;

                Notebook nb = null;

                if (nbID != null)
                {
                    nb = NoteDatabase.GetNotebook(nbID);
                }

                if (nb == null)
                {
                    nb = NoteDatabase.FirstNotebook();
                }

                if (nb == null)
                {
                    nb       = new Notebook();
                    nb.Title = "My Notebook";
                    nb.Color = NotesFunctions.GenerateNotebookColor();
                    NoteDatabase.Add(nb);
                }

                NotebookSection ns = NoteDatabase.GetSection(nb.LastSelectedSectionID);

                if (ns == null)
                {
                    ns            = new NotebookSection();
                    ns.Title      = "Quick Notes";
                    ns.NotebookID = nb.ID;
                    ns.Color      = NotesFunctions.GenerateSectionColor();
                    NoteDatabase.Add(ns);
                }

                page.SectionID = ns.ID;
            }
            else
            {
                Notebook nb = NotesView.LastUsedNotesView.SelectedNotebook;

                if (nb == null)
                {
                    nb       = new Notebook();
                    nb.Title = "My Notebook";
                    nb.Color = NotesFunctions.GenerateNotebookColor();
                    NoteDatabase.Add(nb);
                }

                NotebookSection ns = NotesView.LastUsedNotesView.SelectedSection;

                if (ns == null)
                {
                    ns            = new NotebookSection();
                    ns.Title      = "Quick Notes";
                    ns.NotebookID = nb.ID;
                    ns.Color      = NotesFunctions.GenerateSectionColor();
                    NoteDatabase.Add(ns);
                }

                page.SectionID = ns.ID;
            }

            NoteDatabase.Add(page);

            titleTextBox.Clear();
            contentTextBox.Document.Blocks.Clear();

            if (NotesView.LastUsedNotesView != null)
            {
                NewNoteCommand.Execute(page, NotesView.LastUsedNotesView);
            }
        }