Example #1
0
File: Form1.cs Project: the455/PSPM
        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);
        }
Example #2
0
File: Form1.cs Project: the455/PSPM
        public void DrawBlob(String fileName = "(null)")
        {
            blobDrawn = true;
            //If mesh is already created then null it
            // if (mesh != null)
            // {
            //     mesh = null;
            // }
            fullHull = new List<Point>();

            if (fileName.Equals("(null)"))
            {
                BlobGeneration b = new BlobGeneration();
                b.RandomShape(sizes);
                fullHull = b.CreateConvexHull(this.Width, this.Height, sizes.OFFSET, BlobSettings.slider);
            }
            else
            {
                //Shape.csv
                fullHull = ReadShapesFile(fileName, fullHull);
            }

            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);

            // Comparison compare = new Comparison(this);
            //ThreadStart childref = new ThreadStart(compare.sleep());
            //Thread childThread = new Thread(new ThreadStart(compare.ScreenshotBlob));
            GetFormScreenshot();

            Logger.Debug(Directory.GetCurrentDirectory().ToString() + Path.DirectorySeparatorChar + "Diagram.bmp");

            //childThread.Start();

            Boolean loaded = false;

            do
            {
                // if (!compare.lockPicture)
                // {

                if (blob != null)
                {
                    //Moves the Blob out of the way
                    blob.Top = sizes.SCREEN_HEIGHT;
                    blob.Left = sizes.SCREEN_WIDTH;
                }
                //Waits until the file has been saved
                //Thread.Sleep(175);
                Thread.Sleep(250);
                //Opens the file and saves it in the variable imageBlob
                Logger.Debug(Directory.GetCurrentDirectory().ToString());
                Bitmap image = new Bitmap(Directory.GetCurrentDirectory().ToString() + Path.DirectorySeparatorChar + "Diagram.bmp");
                imageBlob = image;
                loaded = true;
                menuStrip1.Show();
                if (debugOptions)
                {
                    ShowButtons();
                }
                image.Dispose();
                //image = null;
                //  }

            } while (!loaded);
        }