private void SetupGridsAndTables() { double rowHeight = 17.8; BoatData.SetupPortDataTable(leftPort.PortName); BoatData.SetupPortDataTable(rightPort.PortName); BoatData.SetupWaitingBoatsDataTable(); leftPortGrid.ItemsSource = BoatData.BoatDataViewer(leftPort.PortName); leftPortGrid.RowHeight = rowHeight; leftPortGrid.IsReadOnly = true; rightPortGrid.ItemsSource = BoatData.BoatDataViewer(rightPort.PortName); rightPortGrid.RowHeight = rowHeight; rightPortGrid.IsReadOnly = true; waitingBoatsGrid.ItemsSource = BoatData.BoatDataViewer("WaitingBoats"); waitingBoatsGrid.IsReadOnly = true; BoatData.Update(leftPort); BoatData.Update(rightPort); BoatData.UpdateVisitors(waitingBoats); }
/// <summary> /// Listar alla lediga platser i varje hamn /// </summary> public void ListFreeSpots() { foreach (Port port in Ports) { BoatData.ListAllFreeSpotsInPort(port); } }
private void UpdateRightPortLabels() { rightPortBoatsLabel.Content = "Antal båtar vid kajen: " + rightPort.Boats.Count(); rightPortSpotsRemainingLabel.Content = "Lediga platser: " + rightPort.SpotsLeft; rightPortBoatsLabel.ToolTip = BoatData.PortStats(rightPort.Boats); rightPortSpotsRemainingLabel.ToolTip = BoatData.FreeSpotsInPort(rightPort); }
/// <summary> /// Sätter platsen som ledig och tar bort båten ur listan /// samt tar bort raden från datatabellen /// </summary> /// <param name="boat"></param> public void Remove(Boat boat) { boat.IsInPort = $"{this.PortName}-removed"; Boats.Remove(boat); UpdatePortSpot(boat, false); BoatData.RemoveBoat(boat, this.PortName); //BoatData.ListEmptyFromBoatPosition(this, boat); }
public void AddBoat(Boat boat) { boat.IsInPort = this.PortName; Boats.Add(boat); UpdatePortSpot(boat, true); BoatData.UpdatePort(this, boat); //BoatData.ListEmptyFromBoatPosition(this, boat); }
private void UpdateStatsLabels() { var percentRejected = BoatData.CalculatePercentage(Simulate.BoatsAccepted, Simulate.BoatsRejected); var percentAccepted = BoatData.CalculatePercentage(Simulate.BoatsRejected, Simulate.BoatsAccepted); numberOfDaysLabel.Content = "Passerade dagar: " + Simulate.DaysPassed; rejectedBoatsLabel.Content = "Avvisade båtar: " + Simulate.BoatsRejected + $" ({percentRejected}%)"; acceptedBoatsLabel.Content = "Antagna båtar: " + Simulate.BoatsAccepted + $" ({percentAccepted}%)"; }
/// <summary> /// Lägger till en dag på varje båt i hamnen /// </summary> public void AddOneDay() { foreach (Port port in Ports) { port.CheckTimeOnBoats(); if (port.Boats.Any()) { foreach (Boat boat in port.Boats) { boat.DaysSpentAtHarbour++; BoatData.AddTimeToBoat(boat, port.PortName); } } } }
private void ClearSave_Clicked(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("Är du säker?", "WARNING!", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { SaveFileManager.DeleteSaves(); leftPort = new Port("LeftPort"); rightPort = new Port("RightPort"); harbour.ReplacePort(leftPort); harbour.ReplacePort(rightPort); waitingBoats.Clear(); Simulate.AddToWaiting(5); UpdateWaitingBoats(); BoatData.ClearTable(leftPort.PortName); BoatData.ClearTable(rightPort.PortName); BoatData.ClearTable("WaitingBoats"); BoatData.UpdateVisitors(waitingBoats); BoatData.Update(leftPort); BoatData.Update(rightPort); Simulate.DaysPassed = 0; Simulate.BoatsRejected = 0; Simulate.BoatsAccepted = 0; UpdateLabels(); } }
/// <summary> /// Uppdaterar de labels som är associerade med väntande båtar. /// </summary> void UpdateWaitingBoats() { waitingBoatsLabel.ToolTip = BoatData.PortStats(waitingBoats); waitingBoatsLabel.Content = "Väntande båtar: " + waitingBoats.Count(); newBoatsLabel.Content = "Nya båtar per dag: " + Simulate.BoatsPerDay; }