/// <summary> /// OKボタン押下 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { //選択済み設定変更 this.ActiveSettings.ForEach(setting => setting.IsSelected = false); ValueListSettings findSetting = this.ActiveSettings.Find(match => match.Name.Equals(this.cmbProfile.SelectedItem)); findSetting.IsSelected = true; //新規登録の名前設定 if (this.NEW_SETTING_NAME.Equals(findSetting.Name)) { SimpleInput si = new SimpleInput(); if (DialogResult.OK.Equals(si.ShowInputDialog("新しい設定名"))) { findSetting.Name = si.InputName; } else { return; } } //設定をファイルへ書き込み findSetting.Values.Clear(); foreach (string value in this.lbSettings.Items) { findSetting.Values.Add(value); } this.WriteSettingsToFile(this.ActiveSettings.FindAll(match => !this.NEW_SETTING_NAME.Equals(match.Name))); this.DialogResult = DialogResult.OK; }
/// <summary> /// プロファイル選択 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmbProfile_SelectedIndexChanged(object sender, EventArgs e) { this.lbSettings.Items.Clear(); ValueListSettings findSetting = this.ActiveSettings.Find(match => match.Name.Equals(this.cmbProfile.SelectedItem)); if (null == findSetting) { findSetting = new ValueListSettings(this.NEW_SETTING_NAME, false); this.ActiveSettings.Add(findSetting); } findSetting.Values.ForEach(value => this.lbSettings.Items.Add(value)); }
/// <summary> /// 設定削除ボタン押下 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDeleteSetting_Click(object sender, EventArgs e) { if (this.NEW_SETTING_NAME.Equals(this.cmbProfile.SelectedItem)) { return; } ValueListSettings findSettings = this.ActiveSettings.Find(match => match.Name.Equals(this.cmbProfile.SelectedItem)); this.ActiveSettings.Remove(findSettings); this.cmbProfile.Items.Remove(findSettings.Name); this.cmbProfile.SelectedItem = this.NEW_SETTING_NAME; this.IsModified = true; }
/// <summary> /// 設定値編集を開始します /// </summary> /// <returns></returns> protected DialogResult StartSetting() { //初期化 this.txtValueName.Clear(); this.cmbProfile.Items.Clear(); this.cmbProfile.Items.Add(this.NEW_SETTING_NAME); //設定読込 this.ActiveSettings.ForEach(setting => this.cmbProfile.Items.Add(setting.Name)); ValueListSettings findSettings = this.ActiveSettings.Find(match => match.IsSelected); this.cmbProfile.SelectedItem = findSettings != null ? findSettings.Name : this.NEW_SETTING_NAME; //モーダル表示 return(this.ShowDialog()); }