Пример #1
0
        private void PageDelete_Click(object sender, RoutedEventArgs e)
        {
            NotebookPage selectedPage = SelectedPage;

            NoteDatabase.Delete(selectedPage);
            SelectedPage = null;

            foreach (FrameworkElement each in pageTabs.Items)
            {
                if (each.Tag == selectedPage)
                {
                    int index = pageTabs.Items.IndexOf(each);
                    pageTabs.Items.Remove(each);

                    if (pageTabs.HasItems)
                    {
                        if (index > 0)
                        {
                            ((ToggleButton)pageTabs.Items[index - 1]).IsChecked = true;
                        }
                        else
                        {
                            ((ToggleButton)pageTabs.Items[0]).IsChecked = true;
                        }
                    }
                    else
                    {
                        SelectedPage = null;
                        ShowEmptySectionMessage();
                    }

                    break;
                }
            }
        }
Пример #2
0
        private void SectionDelete_Click(object sender, RoutedEventArgs e)
        {
            NotebookSection selectedSection = SelectedSection;

            NoteDatabase.Delete(selectedSection);
            SelectedSection = null;
            SelectedPage    = null;

            foreach (object each in sectionTabs.Items)
            {
                RadioButton rb = each as RadioButton;

                if (rb != null && rb.Tag == selectedSection)
                {
                    int index = sectionTabs.Items.IndexOf(each);
                    sectionTabs.Items.Remove(each);

                    if (sectionTabs.Items.Count > 2)
                    {
                        if (index > 0)
                        {
                            ((ToggleButton)sectionTabs.Items[index - 1]).IsChecked = true;
                        }
                        else
                        {
                            ((ToggleButton)sectionTabs.Items[0]).IsChecked = true;
                        }
                    }
                    else
                    {
                        SelectedSection = null;
                        SelectedPage    = null;
                        ShowEmptyNotebookMessage();
                    }

                    break;
                }
            }

            if (NotesAppBar.LastUsedNotesAppBar != null && NotesAppBar.LastUsedNotesAppBar.SelectedSection.ID == selectedSection.ID)
            {
                NotesAppBar.LastUsedNotesAppBar.SelectedNotebook = null;
                NotesAppBar.LastUsedNotesAppBar.SelectedSection  = null;
                NotesAppBar.LastUsedNotesAppBar.SelectedPage     = null;
                NotesAppBar.LastUsedNotesAppBar.Close();
            }
        }
Пример #3
0
        private void NotebookDelete_Click(object sender, RoutedEventArgs e)
        {
            Notebook selectedNotebook = SelectedNotebook;

            NoteDatabase.Delete(selectedNotebook);
            SelectedNotebook = null;
            SelectedSection  = null;
            SelectedPage     = null;

            foreach (FrameworkElement each in notebookTabs.Items)
            {
                if (each.Tag == selectedNotebook)
                {
                    int index = notebookTabs.Items.IndexOf(each);
                    notebookTabs.Items.Remove(each);

                    if (notebookTabs.HasItems)
                    {
                        if (index > 0)
                        {
                            ((ToggleButton)notebookTabs.Items[index - 1]).IsChecked = true;
                        }
                        else
                        {
                            ((ToggleButton)notebookTabs.Items[0]).IsChecked = true;
                        }
                    }
                    else
                    {
                        SelectedNotebook = null;
                        SelectedSection  = null;
                        SelectedPage     = null;
                        ShowEmptyWorkspaceMessage();
                    }

                    break;
                }
            }

            if (NotesAppBar.LastUsedNotesAppBar != null && NotesAppBar.LastUsedNotesAppBar.SelectedNotebook.ID == selectedNotebook.ID)
            {
                NotesAppBar.LastUsedNotesAppBar.SelectedNotebook = null;
                NotesAppBar.LastUsedNotesAppBar.SelectedSection  = null;
                NotesAppBar.LastUsedNotesAppBar.SelectedPage     = null;
                NotesAppBar.LastUsedNotesAppBar.Close();
            }
        }