Exemple #1
0
        public async void DeleteNotebook(Notebook notebook)
        {
            await DatabaseHelper.Delete(notebook);

            Notebooks.Remove(notebook);
            // ReadNotebooks();
        }
 public void DeleteNotebook(NoteBook noteBook)
 {
     if (noteBook != null)
     {
         DatabaseHelper.Delete(noteBook);
         Notebooks.Remove(noteBook);
         ReadNoteBooks();
     }
 }
        private void DeleteCurrentNotebook()
        {
            // TODO: i18n
            if (SelectedNotebook != null)
            {
                var notes = Hub.Instance.Storage.GetNotes(SelectedNotebook.Notebook);
                if (!notes.Any())
                {
                    var settings = DialogHelpers.GetDefaultDialogSettings();

                    if (Notebooks.Count == 1)
                    {
                        MainWindowInstance.ShowMessageAsync("Delete", "You can't delete the last notebook, rename it if the name is wrong.", MessageDialogStyle.Affirmative, settings);
                        return;
                    }

                    MainWindowInstance.ShowMessageAsync("Delete", $"Do you want to delete the notebook {SelectedNotebook.Name}?", MessageDialogStyle.AffirmativeAndNegative, settings).ContinueWith(delegate(Task <MessageDialogResult> task)
                    {
                        if (task.Result == MessageDialogResult.Affirmative)
                        {
                            InvokeOnCurrentDispatcher(() =>
                            {
                                int index = Notebooks.IndexOf(SelectedNotebook);
                                if (index >= Notebooks.Count - 1)
                                {
                                    index--;
                                }

                                SelectedNotebook.Notebook.Delete();

                                if (Notebooks.Contains(SelectedNotebook))
                                {
                                    Notebooks.Remove(SelectedNotebook);
                                }

                                SelectedNotebook = Notebooks[index];
                            });
                        }
                    });
                }
                else
                {
                    MainWindowInstance.ShowMessageAsync("Delete", "You can't delete a notebook that contains notes.");
                }
            }
        }
Exemple #4
0
        public async void  DeleteNotebook(NoteBook noteBook)
        {
            //if (noteBook != null)
            //{
            //    DatabaseHelper.Delete(noteBook);
            //    Notebooks.Remove(noteBook);
            //    ReadNoteBooks();
            //}

            if (noteBook != null)
            {
                await DatabaseHelper.Delete(noteBook);

                Notebooks.Remove(noteBook);
                ReadNoteBooks();
            }
        }