private void AddForeignItem() { if (this.tvwForeign.SelectedNode.Tag == null) { return; } ITradable item = this.tvwForeign.SelectedNode.Tag as ITradable; if (item != null && !this.takenItems.Contains(item)) { if (item.GetType() == typeof(GoldLumpSum)) { GoldLumpSum sum = (GoldLumpSum)item; GoldAmountDialog dlg = new GoldAmountDialog(); if (dlg.ShowDialog(this) == DialogResult.OK) { sum.LumpSum = dlg.GoldAmount; } else { return; } } else if (item.GetType() == typeof(GoldPerTurn)) { GoldPerTurn turn = (GoldPerTurn)item; GoldAmountDialog dlg = new GoldAmountDialog(); if (dlg.ShowDialog(this) == DialogResult.OK) { turn.AmountPerTurn = dlg.GoldAmount; } else { return; } } this.takenItems.Add(item); Rebind(); } }
/// <summary> /// Invokes the <see cref="ApplyTradeCommand"/>. /// </summary> public override void Invoke() { OnInvoking(); Collection <ITradable> givenItems = this.DiplomacyControl.GivenItems; Collection <ITradable> takenItems = this.DiplomacyControl.TakenItems; DiplomaticTie tie = this.DiplomacyControl.DiplomaticTie; foreach (ITradable given in givenItems) { Type type = given.GetType(); if (type == typeof(DiplomaticAgreement)) { tie.DiplomaticAgreements.Add((DiplomaticAgreement)given); } else if (type == typeof(GoldLumpSum)) { GoldLumpSum gls = (GoldLumpSum)given; tie.ForeignCountry.Gold += gls.LumpSum; } else if (type == typeof(GoldPerTurn)) { } else if (type == typeof(Technology)) { tie.ForeignCountry.AcquiredTechnologies.Add((Technology)given); } else if (type == typeof(City)) { City city = (City)given; tie.ForeignCountry.Cities.Add(city); ClientApplication.Instance.Player.Cities.Remove(city); } else if (type == typeof(Resource)) { } } foreach (ITradable taken in takenItems) { Type type = taken.GetType(); if (type == typeof(DiplomaticAgreement)) { } else if (type == typeof(GoldLumpSum)) { tie.ParentCountry.Gold += ((GoldLumpSum)taken).LumpSum; } else if (type == typeof(GoldPerTurn)) { } else if (type == typeof(Technology)) { tie.ParentCountry.AcquiredTechnologies.Add((Technology)taken); } else if (type == typeof(City)) { City city = (City)taken; tie.ParentCountry.Cities.Add(city); tie.ForeignCountry.Cities.Remove(city); } else if (type == typeof(Resource)) { } } OnInvoked(); }