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 ListRenameButton_Click(object sender, RoutedEventArgs e) { var objList = _viewModel.ActiveQaList; if (objList == _viewModel.AllQaItemsList) { return; } var list = ((QaListStubsViewModel)objList).Underlying; string oldName = list.Name; string name; _viewModel.FixAirspace = true; do { name = await this.ShowInputAsync(T("dialog.header.rename"), T("dialog.rename_list", "oldName", oldName), CreateMetroDialogSettings()); if (name == null) { break; } try { list.Name = name; _localListPersistence.UpdateList(list, true); } catch (IllegalListNameException) { await this.ShowMessageAsync(T("dialog.header.error"), T("dialog.invalid_list_name", "name", name), MessageDialogStyle.Affirmative, CreateMetroDialogSettings()); name = null; list.Name = oldName; } catch (DuplicateListNameException) { await this.ShowMessageAsync(T("dialog.header.error"), T("dialog.list_name_already_exists", "name", name), MessageDialogStyle.Affirmative, CreateMetroDialogSettings()); name = null; list.Name = oldName; } catch (Exception ex) { await this.ShowMessageAsync(T("dialog.header.error"), T("dialog.rename_failed", "name", name, "exception", ex.ToString()), MessageDialogStyle.Affirmative, CreateMetroDialogSettings()); } } while (name == null); _viewModel.FixAirspace = false; }