private void OnButtonOkClick(object sender, EventArgs e) { if (_engineList.SettingAvailable) { EngineSetting setting = _engineList.Settings[_listBoxSettings.SelectedIndex]; string name = _textBoxName.Text; if (string.IsNullOrWhiteSpace(name)) { return; } bool nameChanged = name != setting.Name; if (nameChanged && _listBoxSettings.Items.Contains(name)) { MessageBox.Show(this, "Setting with this name already exists.", "Zentropy", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (nameChanged) { setting.Name = name; } setting.ExecutablePath = _comboBoxExePath.Text; setting.LogoPath = _comboBoxLogoPath.Text; setting.UciOptions = _textBoxUciOptions.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); _engineList.TryAddExePath(setting.ExecutablePath); _engineList.TryAddLogoPath(setting.LogoPath); EngineSelected?.Invoke(); UpdateUI(_listBoxSettings.SelectedIndex); Close(); } }
private void OnButtonRemoveClick(object sender, EventArgs e) { if (!_engineList.SettingAvailable) { return; } int selected = _listBoxSettings.SelectedIndex; _engineList.Settings.RemoveAt(selected); if (_engineList.SelectedIndex == selected) { _engineList.SelectedIndex = 0; } if (_engineList.SelectedOpponentIndex == selected) { _engineList.SelectedOpponentIndex = 0; } EngineSelected?.Invoke(); UpdateUI(_listBoxSettings.SelectedIndex); if (selected - 1 >= 0) { _listBoxSettings.SelectedIndex = selected - 1; } }
private void OnComboBoxEngine2SelectedIndexChanged(object sender, EventArgs e) { _engineList.SelectedOpponentIndex = _comboBoxEngine2.SelectedIndex; EngineSelected?.Invoke(); }