Esempio n. 1
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