/// <summary> /// 他のフォームに更新を通知する /// </summary> /// <param name="id">項目ID</param> private void NotifyItemChange(MiscItemId id) { switch (id) { case MiscItemId.TpMaxAttach: // 輸送艦最大付属装備数 if (Units.IsLoaded()) { Units.Items[(int)UnitType.Transport].SetDirty(UnitClassItemId.MaxAllowedBrigades); } HoI2EditorController.OnItemChanged(EditorItemId.MaxAllowedBrigades, this); break; case MiscItemId.SsMaxAttach: // 潜水艦最大付属装備数 if (Units.IsLoaded()) { Units.Items[(int)UnitType.Submarine].SetDirty(UnitClassItemId.MaxAllowedBrigades); } HoI2EditorController.OnItemChanged(EditorItemId.MaxAllowedBrigades, this); break; case MiscItemId.SsnMaxAttach: // 原子力潜水艦最大付属装備数 if (Units.IsLoaded()) { Units.Items[(int)UnitType.NuclearSubmarine].SetDirty(UnitClassItemId.MaxAllowedBrigades); } HoI2EditorController.OnItemChanged(EditorItemId.MaxAllowedBrigades, this); break; case MiscItemId.DdMaxAttach: // 駆逐艦最大付属装備数 if (Units.IsLoaded()) { Units.Items[(int)UnitType.Destroyer].SetDirty(UnitClassItemId.MaxAllowedBrigades); } HoI2EditorController.OnItemChanged(EditorItemId.MaxAllowedBrigades, this); break; case MiscItemId.ClMaxAttach: // 軽巡洋艦最大付属装備数 if (Units.IsLoaded()) { Units.Items[(int)UnitType.LightCruiser].SetDirty(UnitClassItemId.MaxAllowedBrigades); } HoI2EditorController.OnItemChanged(EditorItemId.MaxAllowedBrigades, this); break; case MiscItemId.CaMaxAttach: // 重巡洋艦最大付属装備数 if (Units.IsLoaded()) { Units.Items[(int)UnitType.HeavyCruiser].SetDirty(UnitClassItemId.MaxAllowedBrigades); } HoI2EditorController.OnItemChanged(EditorItemId.MaxAllowedBrigades, this); break; case MiscItemId.BcMaxAttach: // 巡洋戦艦最大付属装備数 if (Units.IsLoaded()) { Units.Items[(int)UnitType.BattleCruiser].SetDirty(UnitClassItemId.MaxAllowedBrigades); } HoI2EditorController.OnItemChanged(EditorItemId.MaxAllowedBrigades, this); break; case MiscItemId.BbMaxAttach: // 戦艦最大付属装備数 if (Units.IsLoaded()) { Units.Items[(int)UnitType.BattleShip].SetDirty(UnitClassItemId.MaxAllowedBrigades); } HoI2EditorController.OnItemChanged(EditorItemId.MaxAllowedBrigades, this); break; case MiscItemId.CvlMaxAttach: // 軽空母最大付属装備数 if (Units.IsLoaded()) { Units.Items[(int)UnitType.EscortCarrier].SetDirty(UnitClassItemId.MaxAllowedBrigades); } HoI2EditorController.OnItemChanged(EditorItemId.MaxAllowedBrigades, this); break; case MiscItemId.CvMaxAttach: // 空母最大付属装備数 if (Units.IsLoaded()) { Units.Items[(int)UnitType.Carrier].SetDirty(UnitClassItemId.MaxAllowedBrigades); } HoI2EditorController.OnItemChanged(EditorItemId.MaxAllowedBrigades, this); break; } }
/// <summary> /// 編集項目テキストボックスフォーカス移動後の処理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnItemTextBoxValidated(object sender, EventArgs e) { // 選択中の国家がなければ戻る if (countryListBox.SelectedIndex < 0) { return; } Country country = Countries.Tags[countryListBox.SelectedIndex]; // 選択中のユニット名種類がなければ戻る UnitClass unit = typeListBox.SelectedItem as UnitClass; if (unit == null) { return; } TextBox textBox = sender as TextBox; if (textBox == null) { return; } int index = (int)textBox.Tag; if (unit.ExistsModelName(index, country)) { // 値に変化がなければ何もしない if (textBox.Text.Equals(unit.GetCountryModelName(index, country))) { return; } if (string.IsNullOrEmpty(textBox.Text)) { // 変更後の文字列が空ならば国別のモデル名を削除する unit.RemoveModelName(index, country); } else { // 値を更新する unit.SetModelName(index, country, textBox.Text); } } else { // 値に変化がなければ何もしない if (string.IsNullOrEmpty(textBox.Text)) { return; } // 値を更新する unit.SetModelName(index, country, textBox.Text); } // 編集済みフラグを設定する UnitModel model = unit.Models[index]; model.SetDirtyName(country); Units.SetDirtyModelName(country, unit.Type); // 文字色を変更する textBox.ForeColor = Color.Red; // 編集済みフラグが更新されるため国家リストボックスの表示を更新する countryListBox.Refresh(); typeListBox.Refresh(); // ユニットモデル名の更新を通知する HoI2EditorController.OnItemChanged(EditorItemId.CountryModelName, this); }