コード例 #1
0
        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);
        }
コード例 #2
0
 /// <summary>
 /// Listar alla lediga platser i varje hamn
 /// </summary>
 public void ListFreeSpots()
 {
     foreach (Port port in Ports)
     {
         BoatData.ListAllFreeSpotsInPort(port);
     }
 }
コード例 #3
0
        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);
        }
コード例 #4
0
 /// <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);
 }
コード例 #5
0
 public void AddBoat(Boat boat)
 {
     boat.IsInPort = this.PortName;
     Boats.Add(boat);
     UpdatePortSpot(boat, true);
     BoatData.UpdatePort(this, boat);
     //BoatData.ListEmptyFromBoatPosition(this, boat);
 }
コード例 #6
0
        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}%)";
        }
コード例 #7
0
        /// <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);
                    }
                }
            }
        }
コード例 #8
0
        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();
            }
        }
コード例 #9
0
 /// <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;
 }