public Drawingboard(TransformationMatrix transf, Rectangle viewport, Graphics graphics)
 {
     this.transf = transf;
     this.graphics = graphics;
     this.Viewport = viewport;
     graphics.Transform = transf.Transformation;
 }
Exemple #2
0
        void Form1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;

            if (algorithmSet == null || algorithmSet.Nodes == null)
                return;

            matrix = new TransformationMatrix(sender as Control, boundingRectangle.ToGDI());
            var board = new GDI.Drawingboard(matrix, e.Graphics);

            if (checkBox1.Checked)
            {
                var counter = 0;
                foreach (var c in algorithmSet.Nodes)
                {
                    board.DrawCoordinate(c.ToGDI(), algorithmSet.Nodes.Count < 100, (++counter).ToString());
                }
            }

            if (algorithmSet.LastRoute != null && checkBox3.Checked)
            {
                using (var pen = new Pen(Color.Blue, 0))
                    e.Graphics.DrawLines(pen, algorithmSet.LastRoute.Concat(new[] { algorithmSet.LastRoute.First() }).Select(h => algorithmSet.Nodes[h].ToGDI()).ToArray());
            }
            //else if (algorithmSet.LastTSPResult != null && checkBox3.Checked)
            //{
            //    using (var pen = new Pen(Color.Blue, 0))
            //    {
            //        e.Graphics.DrawLines(pen, algorithmSet.LastTSPResult.TourOrPath.Concat(new[] { algorithmSet.LastTSPResult.TourOrPath.First() }).Select(h => h.ToGDI()).ToArray());
            //    }
            //}

            if (lastTSPResultWithClusters != null && checkBox4.Checked)
            {
                using (var pen = new Pen(Color.Red, 0))
                {
                    e.Graphics.DrawLines(pen, lastTSPResultWithClusters.Concat(new[] { lastTSPResultWithClusters.First() }).Select(h => h.ToGDI()).ToArray());
                }
            }

          
            if (algorithmSet.Clusters != null && checkBox2.Checked)
            {
                using (var pen = new Pen(Color.Green, 0))
                    foreach (var cluster in algorithmSet.Clusters)
                    {
                        if (cluster.Nodes.Count() > 1)
                        {
                            //var hul = new ConvexHull().Algorithm(cluster);
                            //e.Graphics.DrawPolygon(pen, hul.Select(h => h.ToGDI()).ToArray());
                            e.Graphics.DrawLines(pen, cluster.Nodes.Select(h => h.ToGDI()).ToArray());
                        }
                    }
            }
        }
 public Drawingboard(TransformationMatrix transf, Graphics graphics)
 {
     this.transf = transf;
     this.graphics = graphics;
     graphics.Transform = transf.Transformation;
 }
 public Drawingboard(Graphics graphics)
 {
     this.transf = null;
     this.graphics = graphics;
 }
 public Drawingboard(Graphics graphics, Rectangle viewport)
 {
     this.transf = null;
     this.graphics = graphics;
     this.Viewport = viewport;
 }