Esempio n. 1
0
File: Form1.cs Progetto: the455/PSPM
        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();
            }
        }