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."); } } }