Exemplo n.º 1
0
        public static List <Row> SortContainersIntoRows(int shipWidth, int shipLength, List <Container> containers)
        {
            List <Row> rows = GetRowsFromShipDimensions(shipWidth, shipLength);

            rows = SortCoolableContainers(ListSorter.GetCoolableContainers(containers), rows);
            rows = SortNormalContainers(ListSorter.GetNormalContainers(containers), rows);
            rows = SortValuableAndCoolableContainers(ListSorter.GetCoolableAndValuableContainers(containers), rows);
            rows = SortValuableContainers(ListSorter.GetValuableContainers(containers), rows);
            rows = ContainerBalancer.BalanceRows(rows);
            return(rows);
        }
Exemplo n.º 2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            if (containers.Count == 0)
            {
                MessageBox.Show("Voeg eerst containers toe");
                return;
            }

            if (ship != null)
            {
                ship = new Ship(ship.Width, ship.Length);
                bool success = ship.CheckWeightOfRowsAndAddToShip(ContainerSorter.SortContainersIntoRows(ship.Width, ship.Length, containers));
                var  output  = ShipToURL.ShipToUrl(ship);
                TBURL.Text = output;
                double balance = ContainerBalancer.GetBalanceDifference(ship.Rows.ToList());
                LBLBalance.Text = "Ship Balance difference: " + balance;
                if (webSocketServer.Sockets.Any())
                {
                    foreach (var socket in webSocketServer.Sockets)
                    {
                        socket.Send(TBURL.Text);
                    }
                    return;
                }
                var confirmResult = MessageBox.Show("Open ship visualizer in new browser tab?",
                                                    "Open visualizer!",
                                                    MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start(output);
                }
                foreach (var socket in webSocketServer.Sockets)
                {
                    socket.Send(TBURL.Text);
                }
                if (success == false)
                {
                    throw new ArgumentException("Weight is too high or too low");
                }
            }
            else
            {
                MessageBox.Show("Creëer eerst een ship");
            }
        }