Example #1
0
        private void btLimpiar_Click(object sender, EventArgs e)
        {
            // Limpiar la superficie de dibujo
            Graphics g = PictureBox1.CreateGraphics();

            g.Clear(Color.White);
        }
Example #2
0
        private void btCurvas_Click(object sender, EventArgs e)
        {
            // Superficie de dibujo
            Graphics g = PictureBox1.CreateGraphics();

            // Crear lápices
            Pen lápizRojo  = new Pen(Color.Red, 3);
            Pen lápizVerde = new Pen(Color.Green, 3);

            // Puntos que definen la curva flexible cardinal
            Point[] puntos = { new Point(25, 25), new Point(50, 15), new Point(100, 5), new Point(120, 25), new Point(150, 50), new Point(220, 200), new Point(120, 120) };
            // Dibujar líneas entre los puntos
            g.DrawLines(lápizRojo, puntos);
            // Dibujar la curva
            g.DrawCurve(lápizVerde, puntos);

            // Crear lápiz
            Pen lápizNegro = new Pen(Color.Black, 3);
            // Puntos que definen la curva flexible de Bézier
            Point p1 = new Point(30, 120);
            Point p2 = new Point(150, 200);
            Point c1 = new Point(75, 10);
            Point c2 = new Point(50, 210);

            // Dibujar la curva
            g.DrawBezier(lápizNegro, p1, c1, c2, p2);
        }
Example #3
0
        private void Timer1_Tick(object sender, EventArgs e)
        {
            // Obtener el objeto Graphics expuesto por PictureBox1
            Graphics g = PictureBox1.CreateGraphics();

            // Dibujar la bola en la superficie de dibujo
            g.DrawImage(mapaBits, posXBola - anchoMapaBitsBola / 2, posYBola - altoMapaBitsBola / 2, anchoMapaBitsBola, altoMapaBitsBola);
            // Liberar los recursos utilizados por el objeto Graphics
            g.Dispose();

            // Siguiente posición de la bola
            posXBola += MovXBola;
            posYBola += MovYBola;

            // Invertir la posición de la bola cuando esta toque en los
            // límites de la superficie de dibujo
            if (posXBola + radioXBola >= PictureBox1.ClientSize.Width || posXBola - radioXBola <= 0)
            {
                MovXBola = -MovXBola;
                Console.Beep(3000, 20);
            }
            if (posYBola + radioYBola >= PictureBox1.ClientSize.Height || posYBola - radioYBola <= 0)
            {
                MovYBola = -MovYBola;
                Console.Beep(4000, 20);
            }
        }
Example #4
0
 // click once to add a point or select a point
 private void PictureBox1_MouseDown(object sender, MouseEventArgs e)
 {
     if (!stopDraw)
     {
         if (e.Button == MouseButtons.Left)
         {
             points.Add(e.Location);
             points = points.Distinct().ToList();
         }
         if (points.Count > 2)
         {
             DrawCurve(PictureBox1.CreateGraphics());
         }
     }
     if (stopDraw)
     {
         for (int i = 0; i < points.Count; i++)
         {
             if (Math.Abs(e.Location.X - points[i].X) < 10 && Math.Abs(e.Location.Y - points[i].Y) < 10)
             {
                 selectedIndex = i;
                 changeCurve   = true;
                 return;
             }
         }
     }
 }
Example #5
0
        private void butEllipse_Click(object sender, EventArgs e)
        {
            Rectangle rect = new Rectangle(250, 200, 150, 80);

            g = PictureBox1.CreateGraphics();
            g.DrawEllipse(penBlue, rect);
        }
Example #6
0
        private void PictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            if (Makeselection)
            {
                try
                {
                    if (PictureBox1.Image == null)
                    {
                        return;
                    }


                    if (e.Button == MouseButtons.Left)
                    {
                        PictureBox1.Refresh();
                        cropWidth  = e.X - cropX;
                        cropHeight = e.Y - cropY;
                        Graphics g = PictureBox1.CreateGraphics();

                        g.DrawRectangle(cropPen, cropX, cropY, cropWidth, cropHeight);
                    }
                }
                catch
                {
                    return;
                }
            }
        }
Example #7
0
        private void btTarta_Click(object sender, EventArgs e)
        {
            Graphics  g     = PictureBox1.CreateGraphics();
            Pen       lápiz = new Pen(Color.Black, 3);
            Rectangle rect  = new Rectangle(10, 60, 230, 90);

            g.DrawPie(lápiz, rect, 30, 150);
        }
Example #8
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     points.Clear();
     curve.Clear();
     DrawFinalLine(PictureBox1.CreateGraphics());
     stopDraw      = false;
     changeCurve   = false;
     selectedIndex = -1;
 }
Example #9
0
 // end change curve
 private void PictureBox1_MouseUp(object sender, MouseEventArgs e)
 {
     if (stopDraw && changeCurve)
     {
         points[selectedIndex] = e.Location;
         DrawFinalLine(PictureBox1.CreateGraphics());
         changeCurve = false;
     }
 }
Example #10
0
        private void btRegiones_Click(object sender, EventArgs e)
        {
            // Superficie de dibujo
            Graphics g = PictureBox1.CreateGraphics();
            // Lápiz
            Pen lápiz = new Pen(Color.Black, 3);
            // Centro de la superficie de dibujo
            int xCentro = PictureBox1.Width / 2;
            int yCentro = PictureBox1.Height / 2;

            // Transformaciones: eje Y positivo hacia arriba y
            // origen (0,0) en el centro
            g.Transform = new Matrix(1, 0, 0, -1, xCentro, yCentro);
            // Rectángulos para tres elipses
            Rectangle rect0 = new Rectangle(-50, 0, 100, 100);
            Rectangle rect1 = new Rectangle(-7, -75, 100, 100);
            Rectangle rect2 = new Rectangle(-93, -75, 100, 100);
            // Añadimos tres elipses a un trazado
            GraphicsPath trazado = new GraphicsPath();

            trazado.AddEllipse(rect0);
            trazado.AddEllipse(rect1);
            trazado.AddEllipse(rect2);
            // Pintar el trazado
            g.FillPath(Brushes.Yellow, trazado);
            // Crear una región con el trazado
            Region región = new Region(trazado);

            //GraphicsPath trazado0 = new GraphicsPath();
            //trazado0.AddEllipse(rect0);
            //GraphicsPath trazado1 = new GraphicsPath();
            //trazado1.AddEllipse(rect1);
            //GraphicsPath trazado2 = new GraphicsPath();
            //trazado2.AddEllipse(rect2);
            //Region región = new Region(trazado0);
            //región.Xor(trazado1);
            //región.Xor(trazado2);
            //g.FillRegion(Brushes.Yellow, región);

            // Definir la región de recorte:
            // región de recorte actual intersección objeto región
            g.SetClip(región, CombineMode.Intersect);
            // Dibujar radios desde el origen, de dos en dos grados
            float PI    = 3.1415926F;
            float radio = Math.Min(xCentro, yCentro);
            float a;
            float x;
            float y;

            for (a = 0; a <= 2 * PI; a += PI / 90)
            {
                x = System.Convert.ToSingle(radio * Math.Cos(a));
                y = System.Convert.ToSingle(radio * Math.Sin(a));
                g.DrawLine(Pens.Red, 0, 0, x, y);
            }
        }
Example #11
0
        private void btLineasRect_Click(object sender, EventArgs e)
        {
            Graphics g     = PictureBox1.CreateGraphics();
            Pen      lápiz = new Pen(Color.Black, 3);

            g.DrawLine(lápiz, 10, 10, 240, 100);

            Rectangle rect = new Rectangle(10, 120, 230, 90);

            g.DrawRectangle(lápiz, rect);
        }
Example #12
0
        private void btTrazados_Click(object sender, EventArgs e)
        {
            Graphics     g       = PictureBox1.CreateGraphics();
            GraphicsPath trazado = new GraphicsPath();
            Rectangle    rect    = new Rectangle(10, 10, 200, 100);

            trazado.AddArc(rect, 45, 135);
            trazado.AddLine(80, 100, 160, 200);
            trazado.CloseFigure();
            g.DrawPath(Pens.Blue, trazado);
        }
Example #13
0
        private void btPoligonos_Click(object sender, EventArgs e)
        {
            Graphics     g       = PictureBox1.CreateGraphics();
            GraphicsPath trazado = new GraphicsPath();
            Pen          lápiz   = new Pen(Color.Black, 3);

            PointF[] triángulo = { new Point(20, 80), new Point(110, 10), new Point(230, 90) };
            g.DrawPolygon(lápiz, triángulo);

            PointF[] pentágono = { new Point(20, 150), new Point(130, 120), new Point(230, 155), new Point(190, 200), new Point(45, 195) };
            g.DrawPolygon(lápiz, pentágono);
        }
Example #14
0
        private void timer1_Tick_1(object sender, EventArgs e)
        {
            second += 1;

            g = PictureBox1.CreateGraphics();
            if (second == 1)
            {
                Point[] points =
                {
                    new Point(40, 60),
                    new Point(50, 70),
                    new Point(30, 90)
                };

                GraphicsPath path = new GraphicsPath();

                path.StartFigure();
                path.AddArc(175, 50, 50, 50, 0, -180);
                path.AddLine(100, 0, 250, 20);
                path.CloseFigure();

                path.StartFigure();
                path.AddLine(50, 20, 5, 90);
                path.AddCurve(points, 3);
                path.AddLine(50, 150, 150, 180);
                path.CloseFigure();

                g.DrawPath(new Pen(Color.FromArgb(255, 255, 0, 0), 2), path);
            }
            if (second == 2)
            {
                g.DrawRectangle(blackPen, 450, 50, 180, 100);
            }
            if (second == 3)
            {
                GraphicsPath path = new GraphicsPath();

                path.StartFigure();
                path.AddArc(275, 150, 150, 150, 0, 180);
                path.AddLine(150, 100, 450, 120);
                path.CloseFigure();

                g.DrawPath(penGreen, path);
            }
            if (second == 4)
            {
                g.DrawRectangle(penGreen, 10, 250, 100, 100);
            }
            if (second == 5)
            {
                MessageBox.Show("Hope you enjoyed, HAPPY EASTER!!");
            }
        }
Example #15
0
 // move mouse to select point or change curve
 private void PictureBox1_MouseMove(object sender, MouseEventArgs e)
 {
     if (points.Count != 0 && !stopDraw)
     {
         DrawRubberLine(PictureBox1.CreateGraphics(), points.Last(), e.Location);
     }
     if (stopDraw && changeCurve)
     {
         points[selectedIndex] = e.Location;
         DrawFinalLine(PictureBox1.CreateGraphics());
         DrawCurve(PictureBox1.CreateGraphics());
     }
 }
Example #16
0
        private void butPie_Click(object sender, EventArgs e)
        {
            g = PictureBox1.CreateGraphics();
            int x      = 290;
            int y      = 70;
            int width  = 200;
            int height = 100;

            int startAngle = 0;
            int sweepAngle = 45;

            g.DrawPie(penGreen, x, y, width, height, startAngle, sweepAngle);
        }
Example #17
0
        private void butArc_Click(object sender, EventArgs e)
        {
            g = PictureBox1.CreateGraphics();
            float x      = 25;
            float y      = 50;
            float width  = 100;
            float height = 200;

            float startAngle = 45;
            float sweepAngle = 250;

            g.DrawArc(penBrown, x, y, width, height, startAngle, sweepAngle);
        }
Example #18
0
        //获取指纹图像并在窗口中实时显示
        private void ZKFPEngX1_OnImageReceived(object sender, AxZKFPEngXControl.IZKFPEngXEvents_OnImageReceivedEvent e)
        {
            ShowHintImage(0);
            Graphics g   = PictureBox1.CreateGraphics();
            Bitmap   bmp = new Bitmap(PictureBox1.Width, PictureBox1.Height);

            g = Graphics.FromImage(bmp);
            int dc = g.GetHdc().ToInt32();

            ZKFPEngX1.PrintImageAt(dc, 0, 0, bmp.Width, bmp.Height);
            g.Dispose();
            PictureBox1.Image = bmp;
        }
Example #19
0
        private void btLimpiar_Click(object sender, EventArgs e)
        {
            // Limpiar la superficie de dibujo
            Graphics g = PictureBox1.CreateGraphics();

            g.Clear(Color.White);
            // Variables a False
            clicBtLineasRect   = false;
            clicbtElipsesArcos = false;
            clicbtTarta        = false;
            clicbtPoligonos    = false;
            clicbtCurvas       = false;
            clicbtTrazados     = false;
            clicBtRegiones     = false;
        }
Example #20
0
 // click twice to end
 private void PictureBox1_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (points.Count < 3)
     {
         MessageBox.Show("At least 3 points!");
         return;
     }
     if (!stopDraw)
     {
         points.Add(e.Location);
         points = points.Distinct().ToList();
         DrawFinalLine(PictureBox1.CreateGraphics());
     }
     stopDraw = true;
 }
Example #21
0
 private void butPolygon_Click(object sender, EventArgs e)
 {
     System.Drawing.Point[] p = new System.Drawing.Point[6];
     p[0].X = 0;
     p[0].Y = 0;
     p[1].X = 53;
     p[1].Y = 111;
     p[2].X = 114;
     p[2].Y = 86;
     p[3].X = 65;
     p[3].Y = 34;
     p[4].X = 165;
     p[4].Y = 0;
     g      = PictureBox1.CreateGraphics();
     g.DrawPolygon(penBlue, p);
 }
Example #22
0
        private void CrearNuevaBola()
        {
            // Superficie de dibujo
            Graphics g = PictureBox1.CreateGraphics();

            g.Clear(PictureBox1.BackColor);

            // Radio de la bola proporcional al tamaño de la superficie de dibujo
            double min       = Math.Min(PictureBox1.ClientSize.Width / g.DpiX, PictureBox1.ClientSize.Height / g.DpiY);
            double radioBola = min / CteProporBola; // pulgadas

            // Ancho y alto de la bola en píxeles
            radioXBola = Convert.ToInt32(radioBola * g.DpiX);
            radioYBola = Convert.ToInt32(radioBola * g.DpiY);

            g.Dispose(); // liberar los recursos utilizados por g

            // Píxeles que se mueve la bola en las direcciones X e Y.
            // Cantidades proporcionales a su tamaño. Mínimo 1 píxel.
            MovXBola = Math.Max(1, radioXBola / CteProporMov);
            MovYBola = Math.Max(1, radioYBola / CteProporMov);

            // Margen alrededor de la bola, del mismo color que la superficie
            // de dibujo. Haciendo el margen igual al movimiento de la bola,
            // garantizamos que la siguiente imagen dibujada borre la anterior.
            margenXMapaBits = MovXBola;
            margenYMapaBits = MovYBola;

            // Tamaño del mapa de bits incluyendo el margen.
            anchoMapaBitsBola = 2 * (radioXBola + margenXMapaBits);
            altoMapaBitsBola  = 2 * (radioYBola + margenYMapaBits);

            // Crear el mapa de bits.
            mapaBits = new Bitmap(anchoMapaBitsBola, altoMapaBitsBola);

            // Obtener el objeto Graphics expuesto por el Bitmap, limpiar
            // la superficie de dibujo, pintar la bola en el mapa de bits y
            // liberar los recursos utilizados por el objeto Graphics.
            g = Graphics.FromImage(mapaBits);
            g.Clear(PictureBox1.BackColor);
            g.FillEllipse(Brushes.Blue, new Rectangle(MovXBola, MovYBola, 2 * radioXBola, 2 * radioYBola));
            g.Dispose();

            // Posición inicial de la bola.
            posXBola = PictureBox1.ClientSize.Width / 2;
            posYBola = PictureBox1.ClientSize.Height / 2;
        }
Example #23
0
        private void butBezier_Click(object sender, EventArgs e)
        {
            g = PictureBox1.CreateGraphics();
            float startX    = 100.0F;
            float startY    = 100.0F;
            float controlX1 = 200.0F;
            float controlY1 = 10.0F;
            float controlX2 = 350.0F;
            float controlY2 = 50.0F;
            float endX      = 500.0F;
            float endY      = 100.0F;

            g.DrawBezier(penRed, startX, startY,
                         controlX1, controlY1,
                         controlX2, controlY2,
                         endX, endY);
        }
Example #24
0
        private void btElipsesArcos_Click(object sender, EventArgs e)
        {
            Graphics g     = PictureBox1.CreateGraphics();
            Pen      lápiz = new Pen(Color.Black);

            lápiz.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
            g.DrawRectangle(lápiz, 10, 10, 230, 90);
            lápiz = new Pen(Color.Black, 3);
            g.DrawEllipse(lápiz, 10, 10, 230, 90);

            Rectangle rect = new Rectangle(10, 120, 230, 90);

            lápiz           = new Pen(Color.Black, 3);
            lápiz.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
            g.DrawEllipse(lápiz, rect);
            lápiz = new Pen(Color.Red, 3);
            g.DrawArc(lápiz, rect, 30, 180);
        }
Example #25
0
        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            if (DrawCheckBox.Checked)
            {
                if (flag)
                {
                    list.Add(new Point(e.X, e.Y));
                    Graphics g = PictureBox1.CreateGraphics();

                    g.DrawLines(new Pen(Color.Red, 3), list.ToArray());
                }
                else
                {
                    list.Add(new Point(e.X, e.Y));
                    flag = true;
                }
            }
        }
Example #26
0
        private void PictureBox1_MouseMove_1(object sender, MouseEventArgs e)
        {
            if (txtcrp == true)
            {
                Brush brush = new SolidBrush(myColor);
                using (Graphics g = Graphics.FromHwnd(PictureBox1.Handle))
                {
                    using (myFontf)
                    {
                        g.DrawString(textBox1.Text, myFontf, brush, new PointF(e.X, e.Y));
                    }
                }
                txtcrp = true;
            }
            else if (txtcrp == false)
            {
                Cursor = Cursors.Default;
                if (Makeselection)
                {
                    try
                    {
                        if (PictureBox1.Image == null)
                        {
                            return;
                        }


                        if (e.Button == System.Windows.Forms.MouseButtons.Left)
                        {
                            PictureBox1.Refresh();
                            cropWidth  = e.X - cropX;
                            cropHeight = e.Y - cropY;
                            PictureBox1.CreateGraphics().DrawRectangle(cropPen, cropX, cropY, cropWidth, cropHeight);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error : " + ex);
                    }
                }
                txtcrp = false;
            }
        }
Example #27
0
        private void PictureBox1_MouseMove_1(object sender, MouseEventArgs e)
        {
            if (TabControl1.SelectedIndex == 4)
            {
                Point TextStartLocation = e.Location;
                if (CreateText)
                {
                    Cursor = Cursors.IBeam;
                }
            }
            else
            {
                Cursor = Cursors.Default;
                if (Makeselection)
                {
                    try
                    {
                        if (PictureBox1.Image == null)
                        {
                            return;
                        }


                        if (e.Button == System.Windows.Forms.MouseButtons.Left)
                        {
                            PictureBox1.Refresh();
                            cropWidth  = e.X - cropX;
                            cropHeight = e.Y - cropY;
                            PictureBox1.CreateGraphics().DrawRectangle(cropPen, cropX, cropY, cropWidth, cropHeight);
                        }
                    }
                    catch (Exception ex)
                    {
                        //if (ex.Number == 5)
                        //    return;
                    }
                }
            }
        }
Example #28
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            second += 1;

            g = PictureBox1.CreateGraphics();
            if (second == 1)
            {
                using (Font myFont = new Font("Arial", 30))
                {
                    g.DrawString("HAPPY EASTER", myFont, Brushes.Green, new Point(200, 10));
                }
            }
            if (second == 2)
            {
                using (Font myFont = new Font("Arial", 30))
                {
                    g.DrawString("DR. JEFF", myFont, Brushes.Green, new Point(270, 120));
                }
            }
            if (second == 3)
            {
                using (Font myFont = new Font("Arial", 30))
                {
                    g.DrawString("FROM THE CLINARD'S!", myFont, Brushes.Green, new Point(135, 220));
                }
            }

            if (second == 4)
            {
                g.DrawRectangle(blackPen, 10, 50, 100, 100);
            }

            if (second == 5)
            {
                g.DrawRectangle(blackPen, 600, 50, 100, 100);
            }
        }
Example #29
0
        private void PictureBox1_MouseClick(System.Object sender, System.Windows.Forms.MouseEventArgs e)
        {
            //Dim p(5) As System.Drawing.Point
            // Dim miCounter As Integer = 0
            int percentage = 0;

            if (e.Button == MouseButtons.Left)
            {
                NodeProperties._nodes.Label25.Text = "X." + e.X + "\r\n" + "Y." + e.Y;
                Graphics g = PictureBox1.CreateGraphics();
                g.DrawEllipse(new Pen(Color.Blue, 5), e.X, e.Y, 2, 2);
                percentage = System.Convert.ToInt32(Convert.ToInt32(DomainUpDown1.Text));
                miCounter += 1;
                NodeProperties._nodes.Label26.Text = miCounter.ToString();
            }
            if (polydrawnumber == false)
            {
                return;
            }
            if (miCounter == 1)
            {
                xone = e.X;
                yone = e.Y;
                NodeProperties._nodes.x1.Text = xone.ToString();
                NodeProperties._nodes.y1.Text = yone.ToString();
                NodeProperties._nodes.CRPwidth.AppendText(100 / percentage * xone + ", " + 100 / percentage * yone);
            }
            if (miCounter == 2)
            {
                xtwo = e.X;
                ytwo = e.Y;
                NodeProperties._nodes.x2.Text = e.Y.ToString();
                NodeProperties._nodes.y2.Text = e.X.ToString();


                NodeProperties._nodes.CRPwidth.AppendText(", " + 100 / percentage * xtwo + ", " + 100 / percentage * ytwo);
            }
            if (miCounter == 3)
            {
                xthree = e.X;
                ythree = e.Y;
                NodeProperties._nodes.x3.Text = e.Y.ToString();
                NodeProperties._nodes.y3.Text = e.X.ToString();


                NodeProperties._nodes.CRPwidth.AppendText(", " + 100 / percentage * xthree + ", " + 100 / percentage * ythree);
            }
            if (miCounter == 4)
            {
                xfour = e.X;
                yfour = e.Y;
                NodeProperties._nodes.x4.Text = e.Y.ToString();
                NodeProperties._nodes.y4.Text = e.X.ToString();

                NodeProperties._nodes.CRPwidth.AppendText(", " + 100 / percentage * xfour + ", " + 100 / percentage * yfour);
            }
            if (miCounter == 5)
            {
                xfive = e.X;
                yfive = e.Y;
                NodeProperties._nodes.x5.Text = e.Y.ToString();
                NodeProperties._nodes.y5.Text = e.X.ToString();

                NodeProperties._nodes.CRPwidth.AppendText(", " + 100 / percentage * xfive + ", " + 100 / percentage * yfive);
            }
            if (miCounter == 6)
            {
                xsix = e.X;
                ysix = e.Y;
                NodeProperties._nodes.x6.Text = e.Y.ToString();
                NodeProperties._nodes.y6.Text = e.X.ToString();

                NodeProperties._nodes.CRPwidth.AppendText(", " + 100 / percentage * xsix + ", " + 100 / percentage * ysix);
            }
            if (miCounter == 7)
            {
                xseven = e.X;
                yseven = e.Y;
                NodeProperties._nodes.x7.Text = e.Y.ToString();
                NodeProperties._nodes.y7.Text = e.X.ToString();

                NodeProperties._nodes.CRPwidth.AppendText(", " + 100 / percentage * xseven + ", " + 100 / percentage * yseven);
            }
        }
Example #30
0
        private void polydraw()
        {
            if (polydrawnumber == false)
            {
                return;
            }


            // Create pen.



            if (miCounter == 1)
            {
                Point   point1      = new Point(xone, yone);
                Point[] curvePoints =
                {
                    point1,
                };
                MessageBox.Show("Nothing to draw!");
            }
            if (miCounter == 2)
            {
                Point point1 = new Point(xone, yone);
                Point point2 = new Point(xtwo, ytwo);

                Point[] curvePoints =
                {
                    point1,
                    point2,
                };

                g = PictureBox1.CreateGraphics();
                g.DrawPolygon(blackPen, curvePoints);
                miCounter        = 0;
                drawpoly.Enabled = true;

                polydrawnumber = false;
            }
            if (miCounter == 3)
            {
                Point   point1      = new Point(xone, yone);
                Point   point2      = new Point(xtwo, ytwo);
                Point   point3      = new Point(xthree, ythree);
                Point[] curvePoints =
                {
                    point1,
                    point2,
                    point3,
                };
                g = PictureBox1.CreateGraphics();
                g.DrawPolygon(blackPen, curvePoints);
                miCounter        = 0;
                drawpoly.Enabled = true;

                polydrawnumber = false;
            }
            if (miCounter == 4)
            {
                Point   point1      = new Point(xone, yone);
                Point   point2      = new Point(xtwo, ytwo);
                Point   point3      = new Point(xthree, ythree);
                Point   point4      = new Point(xfour, yfour);
                Point[] curvePoints =
                {
                    point1,
                    point2,
                    point3,
                    point4,
                };

                // Draw polygon to screen.
                g = PictureBox1.CreateGraphics();
                g.DrawPolygon(blackPen, curvePoints);
                miCounter        = 0;
                drawpoly.Enabled = true;

                polydrawnumber = false;
            }

            if (miCounter == 5)
            {
                Point   point1      = new Point(xone, yone);
                Point   point2      = new Point(xtwo, ytwo);
                Point   point3      = new Point(xthree, ythree);
                Point   point4      = new Point(xfour, yfour);
                Point   point5      = new Point(xfive, yfive);
                Point[] curvePoints =
                {
                    point1,
                    point2,
                    point3,
                    point4,
                    point5,
                };
                // Draw polygon to screen.
                g = PictureBox1.CreateGraphics();
                g.DrawPolygon(blackPen, curvePoints);
                FillMode newFillMode = FillMode.Winding;

                // Fill polygon to screen.
                g.FillPolygon(myBrush, curvePoints, newFillMode);


                miCounter        = 0;
                drawpoly.Enabled = true;

                polydrawnumber = false;
            }
            if (miCounter == 6)
            {
                Point point1 = new Point(xone, yone);
                Point point2 = new Point(xtwo, ytwo);
                Point point3 = new Point(xthree, ythree);
                Point point4 = new Point(xfour, yfour);
                Point point5 = new Point(xfive, yfive);
                Point point6 = new Point(xsix, ysix);

                Point[] curvePoints =
                {
                    point1,
                    point2,
                    point3,
                    point4,
                    point5,
                    point6,
                };
                g = PictureBox1.CreateGraphics();
                g.DrawPolygon(blackPen, curvePoints);
                miCounter        = 0;
                drawpoly.Enabled = true;

                polydrawnumber = false;
            }
            if (miCounter == 7)
            {
                Point   point1      = new Point(xone, yone);
                Point   point2      = new Point(xtwo, ytwo);
                Point   point3      = new Point(xthree, ythree);
                Point   point4      = new Point(xfour, yfour);
                Point   point5      = new Point(xfive, yfive);
                Point   point6      = new Point(xsix, ysix);
                Point   point7      = new Point(xseven, yseven);
                Point[] curvePoints =
                {
                    point1,
                    point2,
                    point3,
                    point4,
                    point5,
                    point6,
                    point7,
                };

                // Draw polygon to screen.
                g = PictureBox1.CreateGraphics();
                g.DrawPolygon(blackPen, curvePoints);
                polydrawnumber   = false;
                drawpoly.Enabled = true;
                if (miCounter >= 7)
                {
                    polydrawnumber   = false;
                    drawpoly.Enabled = true;



                    // polydraw = False
                    // butPoly.Enabled = False
                    // g = PictureBox1.CreateGraphics
                    //'  g.DrawPolygon(pen1, p)
                }
            }
        }