Esempio n. 1
0
        } // DrawPoints

        public void DrawLines(int[] trail, Grid graph)
        {
            GeometryGroup linesGroup = new GeometryGroup();
            LineGeometry  line       = new LineGeometry();
            int           city       = 1;

            for (; city < trail.Length; city++)
            {
                line            = new LineGeometry();
                line.StartPoint = new Point(cities.GetLocation(trail[city - 1]).X, cities.GetLocation(trail[city - 1]).Y);
                line.EndPoint   = new Point(cities.GetLocation(trail[city]).X, cities.GetLocation(trail[city]).Y);
                linesGroup.Children.Add(line);
            }
            line            = new LineGeometry();
            line.StartPoint = new Point(cities.GetLocation(trail[city - 1]).X, cities.GetLocation(trail[city - 1]).Y);
            line.EndPoint   = new Point(cities.GetLocation(trail[0]).X, cities.GetLocation(trail[0]).Y);
            linesGroup.Children.Add(line);

            Path myPath = new Path();

            myPath.Stroke = Brushes.Black;
            myPath.Data   = linesGroup;
            if (graph.Children.Count > 1)
            {
                graph.Children.Remove(graph.Children[1]);
            }
            graph.Children.Add(myPath);
        }
Esempio n. 2
0
        public void DrawPoints(object sender, RoutedEventArgs e)
        {
            CancelCalculation();
            ClearTextBox();
            int nCities;

            if (!Int32.TryParse(textB_countCities.Text, out nCities))
            {
                textB_countCities.Background = Brushes.Coral;
                errorTB.Push(textB_countCities);
                return;
            }
            cities = new Cities(nCities);
            cities.Generate((int)graph5.Width);
            GeometryGroup cityGroup = new GeometryGroup();

            for (int i = 0; i < cities.NumCities; i++)
            {
                Location l = cities.GetLocation(i);
                // формирование точек на карте
                EllipseGeometry city = new EllipseGeometry();
                city.Center  = new Point(l.X, l.Y);
                city.RadiusX = 4;
                city.RadiusY = 4;
                cityGroup.Children.Add(city);
            }
            Path myPath = new Path();

            myPath.Fill   = Brushes.Plum;
            myPath.Stroke = Brushes.Black;
            myPath.Data   = cityGroup;
            graphs.Children.Clear();
            graphs.Children.Add(myPath);

            button_CalcBB.IsEnabled = true;
        } // DrawPoints