private async void ListRenameButton_Click(object sender, RoutedEventArgs e) { var objList = _viewModel.ActiveQaList; if (objList == _viewModel.AllQaItemsList) { return; } var list = ((QaListStubsViewModel)objList).Underlying; var oldName = list.Name; _viewModel.FixAirspace = true; var dialog = new InputWithCheckDialog(T("dialog.header.rename"), T("dialog.rename_list", "oldName", oldName), oldName, s => { if (!_localListPersistence.CheckValidListName(s)) { return(T("dialog.invalid_list_name", "name", s)); } if (_localListPersistence.CheckDuplicateListName(s, list)) { return(T("dialog.list_name_already_exists", "name", s)); } return(null); }); await this.ShowMetroDialogAsync(dialog, CreateMetroDialogSettings()); var(result, name) = await dialog.WaitUntilButton(); await this.HideMetroDialogAsync(dialog); if (result != MessageDialogResult.Affirmative) { return; } try { list.Name = name; _localListPersistence.UpdateList(list, true); } catch (Exception ex) { await this.ShowMessageAsync(T("dialog.header.error"), T("dialog.rename_failed", "name", name, "exception", ex.ToString()), MessageDialogStyle.Affirmative, CreateMetroDialogSettings()); list.Name = oldName; } _viewModel.FixAirspace = false; }
private async void ListCreateButton_Click(object sender, RoutedEventArgs e) { _viewModel.FixAirspace = true; var dialog = new InputWithCheckDialog(T("dialog.header.new"), T("dialog.create_list"), DateTime.Now.ToLongDateString(), s => { if (!_localListPersistence.CheckValidListName(s)) { return(T("dialog.invalid_list_name", "name", s)); } if (_localListPersistence.CheckDuplicateListName(s)) { return(T("dialog.list_name_already_exists", "name", s)); } return(null); }); await this.ShowMetroDialogAsync(dialog, CreateMetroDialogSettings()); var(result, name) = await dialog.WaitUntilButton(); await this.HideMetroDialogAsync(dialog); if (result != MessageDialogResult.Affirmative) { return; } try { _localListPersistence.CreateList(name); } catch (Exception ex) { await this.ShowMessageAsync(T("dialog.header.error"), T("dialog.create_failed", "name", name, "exception", ex.ToString()), MessageDialogStyle.Affirmative, CreateMetroDialogSettings()); } _viewModel.FixAirspace = false; }