Exemple #1
0
        private void plotPoints(List <Point> points)
        {
            int city = 1; //we start at the first city

            tsp = new TSP(points);

            viewbox = new Viewbox();
            viewbox.HorizontalAlignment = HorizontalAlignment.Stretch;
            viewbox.VerticalAlignment   = VerticalAlignment.Stretch;

            canvas = new Canvas();

            foreach (Point point in points)
            {
                Debug.WriteLine("City: " + city);
                Ellipse ellipse = new Ellipse();
                ellipse.Width  = 4;
                ellipse.Height = 4;
                ellipse.Fill   = Brushes.Red;
                ellipse.Stroke = Brushes.Black;

                ellipse.ToolTip = city + ": (" + point.X + "," + point.Y + ")";

                // Position point on canvas
                Canvas.SetLeft(ellipse, point.X + tsp.canvasOffset.X);
                Canvas.SetTop(ellipse, point.Y + tsp.canvasOffset.Y);

                canvas.Children.Add(ellipse);

                city++;
            }

            canvas.Height = tsp.maxPoint.Y - tsp.minPoint.Y + 80;
            canvas.Width  = tsp.maxPoint.X - tsp.minPoint.X + 80;
            Debug.WriteLine(canvas.Height);
            Debug.WriteLine(canvas.Width);

            viewbox.Child = canvas;
            mainGrid.Children.Add(viewbox);

            Debug.WriteLine(mainGrid.Children[0]);

            //this.UpdateLayout();
            Debug.WriteLine("Finished populating points");
        }