Beispiel #1
0
 public void DrawTour(TSPStats stats)
 {
     lock (Lock) {
         Graphics g = this.GetGraphics();
         this.Clear(g);
         TSPTour   Tour = (TSPTour)stats.solution;
         TSPCity[] cities = Tour.GetCities();
         TSPCity   from, to;
         int[]     tour = Tour.GetTour();
         // 1. draw tour
         for (int i = 0; i < tour.Length; i++)
         {
             from = cities[tour[i]];
             to   = cities[tour[(i + 1) % tour.Length]];
             this.DrawPath(g, from, to);
         }
         // 2. draw cities
         foreach (TSPCity city in cities)
         {
             this.DrawCity(g, city);
         }
         // 3. draw stats
         this.DrawStats(g, stats);
         g.Flush();
         g.Dispose();
     }
     // refresh display
     this.form.Invoke(new Action(() => {
         lock (Lock) {
             this.pb.Image = this.bitmap;
         }
     }));
 }