Пример #1
0
        public void updateResults(Comparison c)
        {
            int full = c.full;
            int empty = c.empty;
            int partial = c.partial;
            long time = c.time;

            toolStripTime.Text = "ms: " + time;
            toolStripFull.Text = "Full: " + full;
            toolStripEmpty.Text = "Empty: " + empty;
            toolStripPartial.Text = "Partial: " + partial;

            if (c.fullOld != 0 && c.emptyOld != 0 && c.partialOld != 0)
            {
                toolStripPreviousFull.Visible = true;
                toolStripPreviousEmpty.Visible = true;
                toolStripPreviousPartial.Visible = true;
                toolStripTimeOld.Visible = true;

                toolStripPreviousFull.Text = "|| Previous run - Full: " + c.fullOld;
                toolStripPreviousEmpty.Text = "Empty: " + c.emptyOld;
                toolStripPreviousPartial.Text = "Partial: " + c.partialOld;
                toolStripTimeOld.Text = "ms: " + c.timeOld;
            }
        }
Пример #2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            Comparison compare = new Comparison(result);
            //ThreadStart childref = new ThreadStart(compare.sleep());
            //Thread childThread = new Thread(new ThreadStart(compare.sleep));
            //  childThread.Start();

            BlobGeneration b = new BlobGeneration();
            b.RandomShape(sizes);

            List<Point> fullHull = new List<Point>();

            fullHull = b.CreateConvexHull(this.Width, this.Height, sizes.OFFSET);
            Point[] point = new Point[fullHull.Count];

            for (int j = 0; j < fullHull.Count; j++)
            {
                point[j].X = fullHull.ElementAt(j).X;
                point[j].Y = fullHull.ElementAt(j).Y;
            }

            Graphics g;
            g = this.CreateGraphics();

            ClearDrawings();
            Pen myPen = new Pen(System.Drawing.Color.Black, 1);

            Color newColor = Color.FromArgb(80, Color.Black);
            SolidBrush blueBrush = new SolidBrush(newColor);

            g.FillPolygon(blueBrush, point);
            g.DrawPolygon(myPen, point);

            Point[] p = new Point[2];
            p[0] = point[3];
            p[1] = point[4];
            // g.FillEllipse(blueBrush, p[0].X, p[0].Y, p[1].X, p[1].Y);
        }
Пример #3
0
        public void Compare(String shape, bool isRatio = false)
        {
            Bitmap image;
            Color backColour;
            Comparison c;

            String imageLocation = Directory.GetCurrentDirectory().ToString() + Path.DirectorySeparatorChar + "Diagram.bmp";
            if (File.Exists(imageLocation))
            {
                //Gets the blob image from default location
                image = new Bitmap(imageLocation);
                // Bug -- maybe error is getting wrong colour?
                backColour = image.GetPixel(BorderWidth , TitlebarHeight);
                //Comparison c = new Comparison(result);
                GetFormScreenshot("BlobAndMesh.bmp");
            }
            else
            {
                MessageBox.Show("Temporary files have been moved!\nPlease regenerate blob and mesh", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (shape.Equals("Square"))
            {
                c = new Comparison(result, isRatio);
                c.IterateThroughSquares(shapeList, backColour, image);
                updateResults(c);
                quotas = c.getBreakDown();
                image.Dispose();
            }
            else if (shape.Equals("Triangle"))
            {
                c = new Comparison(result,isRatio);

                c.IterateThroughTriangleBasedShapes(shapeList, backColour, image, true);
                image.Dispose();
                quotas = c.getBreakDown();
                //Logger.Debug(c.percentageFilled);
                updateResults(c);
            }
            else if (shape.Equals("Hexagon"))
            {
                c = new Comparison(result,isRatio);
                c.IterateThroughTriangleBasedShapes(shapeList, backColour, image, false);
                updateResults(c);
                quotas = c.getBreakDown();
                image.Dispose();
            }
        }