private void FillPlanesMarket(UserScroll userScroll) { // основные характеристики int planesStartX = 10; int planesStartY = 5; List <Plane.Models> models = new List <Plane.Models>(); models.Add(Plane.Models.TY_134); models.Add(Plane.Models.SuperJet123); models.Add(Plane.Models.KukuruznikMX150); foreach (var model in models) { PlaneMarket planeMarket = new PlaneMarket(game, model, 5) { Location = new Point(planesStartX, planesStartY) }; planesStartY += planeMarket.Height + 10; if (userScroll.GetPanel.IsHandleCreated) { userScroll.GetPanel.Invoke(new Action(() => userScroll.GetPanel.Controls.Add(planeMarket))); } else { userScroll.GetPanel.Controls.Add(planeMarket); } // planesUI.Add(plane.ID, planeData); } }
private void FillPlanesMarket(UserScroll userScroll) { // основные характеристики int planesStartX = 10; int planesStartY = 5; List <Plane.Models> models = new List <Plane.Models>(); models.Add(Plane.Models.AirbusA330_200); models.Add(Plane.Models.Boeing747_8I); models.Add(Plane.Models.McDonnelDouglasMD11F); foreach (var model in models) { PlaneMarket planeMarket = new PlaneMarket(game, model, 5) { Location = new Point(planesStartX, planesStartY) }; planesStartY += planeMarket.Height + 10; if (userScroll.GetPanel.IsHandleCreated) { userScroll.GetPanel.Invoke(new Action(() => userScroll.GetPanel.Controls.Add(planeMarket))); } else { userScroll.GetPanel.Controls.Add(planeMarket); } // planesUI.Add(plane.ID, planeData); } }
private void setupTimer(int ValueChange, int FirstInterval, int SecondInterval, int ThereafterInterval) { repeatTimer = new Timer(); repeatTimer.Interval = FirstInterval; repeatTimer.Tick += (s, ee) => { switch (ValueChange) { case Int32.MaxValue: if (ScrollSkip != null) { ScrollSkip.Invoke(false); } break; case Int32.MinValue: if (ScrollSkip != null) { ScrollSkip.Invoke(true); } break; default: int v = Value; Value += ValueChange; if (v != Value) { UserScroll.Invoke(this, Value); } else { repeatTimer.Stop(); } break; } if (repeatTimer != null) { if (repeatTimer.Interval == FirstInterval) { repeatTimer.Interval = SecondInterval; } else if (repeatTimer.Interval == SecondInterval) { repeatTimer.Interval = ThereafterInterval; } } }; repeatTimer.Start(); }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (dragStart >= 0 && this.Enabled && Range > 0) { int oldVal = valFromHandlePosition(e.Y - dragOffset); if (oldVal != val) { val = oldVal; this.Invalidate(); Lib.DoEvents(); UserScroll.Invoke(this, Value); } } }
public ContractForm(IGameLogicInteractable game, Contract contract, uint flightID) { InitializeComponent(); this.game = game; this.flightID = flightID; cities = game.GetCitiesInfo().Values.ToList(); this.contract = contract; BackColor = MainForm.MostlyBackColor; btnAddFlight.BackColor = MainForm.MostlyBackColor; btnCancel.BackColor = MainForm.MostlyBackColor; planesForContract = new UserScroll(); planesForContract.SetLocation(20, 40); planesForContract.Text = "Ваши самолеты"; FillPlanes(PlaneDataType.SelectPlane, planesForContract); this.Controls.Add(planesForContract); }
private void FillPlanes(PlaneDataType type, UserScroll userScroll) { // основные характеристики int startX = 10, startY = 5; var obsplane = game.GetPlanes(); foreach (var plane in game.GetPlanes()) { PlaneData planeData = new PlaneData(type, game, cities, 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(startX, startY), }; startY += planeData.Height + 10; userScroll.GetPanel.Controls.Add(planeData); } }
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; } } }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (this.Enabled && Range > 0) { int oldVal = val; if (dragStart >= 0) { val = valFromHandlePosition(e.Y - dragOffset); dragStart = -1; } else { if (!killRepeatTimer()) { switch (getCursorPosn(e.Y, (int)handlePosition())) { case CursorPosition.OnTopButton: if (e.Button == MouseButtons.Right) { val = 0; } else { val = Math.Max(0, val - 1); } break; case CursorPosition.OnBottomButton: if (e.Button == MouseButtons.Right) { val = Range; } else { val = Math.Min(Range, val + 1); } break; case CursorPosition.AboveHandle: if (e.Button == MouseButtons.Right || LargeChange == 0) { val = valFromHandlePosition(e.Y); } else { Value -= LargeChange; } break; case CursorPosition.BelowHandle: if (e.Button == MouseButtons.Right || LargeChange == 0) { val = valFromHandlePosition(e.Y); } else { Value += LargeChange; } break; } } } if (oldVal != val) { UserScroll.Invoke(this, Value); this.Invalidate(); } } else { dragStart = -1; } }