private void FillPlanes(PlaneDataType type, UserScroll userScroll) { // основные характеристики int planesStartX = 10; int planesStartY = 5; foreach (var plane in game.GetPlanes()) { PlaneData planeData = new PlaneData(type, game, cities.Values.ToList(), plane) { PlaneName = plane.Model.ToString(), CityName = game.GetPlaneLocation(plane.ID) == null ? "-" : game.GetPlaneLocation(plane.ID).Name, SpeedValue = plane.Speed, DeprecationValue = plane.DeprecationDegree, Location = new Point(planesStartX, planesStartY), PriceValue = Math.Round(game.GetBuyPrice(plane.Model) * 0.7, 1), DefaultPrice = Math.Round(game.GetBuyPrice(plane.Model) * 0.7, 1) }; planesStartY += planeData.Height + 10; if (userScroll.GetPanel.IsHandleCreated) { userScroll.GetPanel.Invoke(new Action(() => userScroll.GetPanel.Controls.Add(planeData))); } else { userScroll.GetPanel.Controls.Add(planeData); } switch (type) { case PlaneDataType.SellPlane: planesToSellUI.Add(plane.ID, planeData); break; case PlaneDataType.TransferPlane: planesUI.Add(plane.ID, planeData); break; } } }
public PlaneMarket(IGameLogicInteractable game, Plane.Models model, int days) { InitializeComponent(); BackColor = MainForm.MostlyBackColor; btnBuy.BackColor = MainForm.MostlyBackColor; cbType.BackColor = MainForm.MostlyBackColor; cbType.Items.AddRange(new object[] { "Покупка", "Аренда", "Лизинг" }); Bitmap picture = null; switch (model) { case Plane.Models.AirbusA330_200: { picture = Resources.AirbusA330_200; } break; case Plane.Models.Boeing747_8I: { picture = Resources.Boeing747_8i; } break; case Plane.Models.McDonnelDouglasMD11F: { picture = Resources.McDonnelDouglasMD11F; } break; } this.model = model; this.game = game; PlaneName = model.ToString(); PlaneCharacteristics chars = PlaneCharacteristicsStorage.Characteristics[model]; SpeedValue = chars.Speed; RangeValue = chars.Range; SetMaxValue(chars.MaxSeatings, chars.Payload); DaysValue = days; PriceValue = game.GetBuyPrice(model); cbType.SelectedIndex = 0; }