Пример #1
0
        private void StartSimulation()
        {
            var tramTechs = 3;

            for (int i = 0; i < tramTechs; i++)
            {
                AddViewItem(tramTechsView);
            }

            var routeTechs = 1;

            for (int i = 0; i < routeTechs; i++)
            {
                AddViewItem(routeTechsView);
            }

            // Создаем депо
            depot = new Depot(tramTechs, routeTechs);

            List <Route> routes = new List <Route>()
            {
                depot.addRoute(6, new List <Point> {
                    new Point(5, 4), new Point(3, 5), new Point(5, 8), new Point(9, 8)
                }, Color.Blue),
                depot.addRoute(4, new List <Point> {
                    new Point(7, 4), new Point(7, 2), new Point(3, 2)
                }, Color.Green),
                depot.addRoute(8, new List <Point> {
                    new Point(3, 6), new Point(3, 9), new Point(8, 9), new Point(8, 1), new Point(1, 1), new Point(1, 4)
                }, Color.Red),
                depot.addRoute(5, new List <Point> {
                    new Point(5, 6), new Point(9, 3), new Point(3, 4), new Point(2, 7)
                }, Color.Purple)
            };

            routes.ForEach(route => {
                AddSeries(route.id, route.color, route.stops);
            });

            // Добавляем трамваи
            int numTrams = Prompt.ShowDialog("How many trams?", "Input", 24);

            for (int i = 0; i < numTrams; i++)
            {
                var tram = depot.addTram();
                AddPoint(tram.id, Color.Orange, new Point(-1, -1));
            }

            //depot.update();
            interval.Tick += new EventHandler((object sender, EventArgs e) => {
                reserveView.Items.Clear();
                depot.update();
            });
            interval.Interval = 1000;
            interval.Start();
        }
Пример #2
0
        private void buttonAddTram_Click(object sender, EventArgs e)
        {
            var tram = depot.addTram();

            AddPoint(tram.id, Color.Orange, new Point(-1, -1));
        }