コード例 #1
0
        public void generateRoute()
        {
            /*int Seed = (int)DateTime.Now.Ticks;
             * Random rnd = new Random(Seed);*/
            this.name = $"Маршрут {id}";

            Random rnd = MainWindow.rnd;

            int stationsCount = rnd.Next(7, 10);

            int windowWidth  = (int)System.Windows.SystemParameters.PrimaryScreenWidth;
            int windowHeight = (int)System.Windows.SystemParameters.PrimaryScreenHeight;

            /*windowWidth = (int)canvas.ActualWidth;
             * windowHeight = (int)canvas.ActualHeight;*/

            Console.WriteLine("parms");
            Console.WriteLine(windowWidth);
            Console.WriteLine(windowHeight);

            int x = windowWidth / 2 - windowWidth / 4 + rnd.Next(-100, 500);
            int y = windowHeight / 2 + windowHeight / 4 + rnd.Next(-100, 100);

            for (int i = 0; i != stationsCount; i++)
            {
                Graph newGraph = Graph.createGraph(i);
                newGraph.setCoords(x + this.angle, y + this.angle);
                newGraph.color = this.color;
                newGraph.setRoute(this);
                newGraph.setName($"Станция {i} M{newGraph.route.id}");

                if (this.graphs.Count > 0)
                {
                    Graph oldGraph = this.getLastGraph();

                    GraphEdge edge = GraphEdge.createGraphEdge();
                    edge.addEdges(oldGraph, newGraph);
                    edge.addLength(rnd.Next(4, 8));

                    this.addEdge(edge);
                }

                this.addGraph(newGraph);

                x -= rnd.Next(-50, 100);
                y -= rnd.Next(20, 100);
            }
        }
コード例 #2
0
        public static GraphEdge createGraphEdge()
        {
            GraphEdge graphEdge = new GraphEdge();

            return(graphEdge);
        }
コード例 #3
0
 private void addEdge(GraphEdge edge)
 {
     this.edges.Add(edge);
 }