private async void cmdEditCharacterSetting_Click(object sender, EventArgs e) { using (new CursorWait(this)) { using (EditCharacterSettings frmOptions = new EditCharacterSettings(cboCharacterSetting.SelectedValue as CharacterSettings)) await frmOptions.ShowDialogSafeAsync(this); // Do not repopulate the character settings list because that will happen from frmCharacterSettings where appropriate } }
private async void cmdEditCharacterOption_Click(object sender, EventArgs e) { using (CursorWait.New(this)) { using (EditCharacterSettings frmOptions = new EditCharacterSettings(cboCharacterSetting.SelectedValue as CharacterSettings)) await frmOptions.ShowDialogSafeAsync(this); SuspendLayout(); try { // Populate the Gameplay Settings list. object objOldSelected = cboCharacterSetting.SelectedValue; using (new FetchSafelyFromPool <List <ListItem> >( Utils.ListItemListPool, out List <ListItem> lstGameplayOptions)) { lstGameplayOptions.AddRange(SettingsManager.LoadedCharacterSettings.Values .Select(objLoopOptions => new ListItem( objLoopOptions, objLoopOptions.DisplayName))); lstGameplayOptions.Sort(CompareListItems.CompareNames); await cboCharacterSetting.PopulateWithListItemsAsync(lstGameplayOptions); cboCharacterSetting.SelectedValue = objOldSelected; if (cboCharacterSetting.SelectedIndex == -1 && lstGameplayOptions.Count > 0) { (bool blnSuccess, CharacterSettings objSetting) = await SettingsManager.LoadedCharacterSettings.TryGetValueAsync( GlobalSettings.DefaultCharacterSetting); if (blnSuccess) { cboCharacterSetting.SelectedValue = objSetting; } } if (cboCharacterSetting.SelectedIndex == -1 && lstGameplayOptions.Count > 0) { cboCharacterSetting.SelectedIndex = 0; } } } finally { ResumeLayout(); } } }