private void view_MouseClick(object sender, EventArgs e)
        {
            Point p = view.PointToClient(Cursor.Position);

            int i = listP.Items.Count - 1;

            if (i > 2)
            {
                myPoint A = (myPoint)listP.Items[i];

                while ((((myPoint)listP.Items[i]).det == false) && (i != 0))
                {
                    i--;
                }

                myPoint B = (myPoint)listP.Items[i];

                if (p.X != B.X || p.Y != B.Y)
                {
                    AbsDraw(p.X, p.Y);
                }
                else
                {
                    closeFigure(A.X, A.Y, B.X, B.Y);
                }
            }
            else
            {
                AbsDraw(p.X, p.Y);
            }
        }
        private void endP_Click(object sender, EventArgs e)
        {
            int i = listP.Items.Count - 1;

            myPoint A = (myPoint)listP.Items[i];

            while ((((myPoint)listP.Items[i]).det == false) && (i != 0))
            {
                i--;
            }

            myPoint B = (myPoint)listP.Items[i];

            closeFigure(A.X, A.Y, B.X, B.Y);
        }
        // Addition points by hand
        private void handAdd_Click(object sender, EventArgs e)
        {
            int x, y;

            try
            {
                x = int.Parse(edtX.Text);
                y = int.Parse(edtY.Text);
            }
            catch
            {
                if (MessageBox.Show("Invalid input! Coordinates must be only integer values.", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Cancel)
                {
                    Close();
                }
                return;
            }

            int i = listP.Items.Count - 1;

            if (i > 1)
            {
                myPoint a = (myPoint)listP.Items[i];
                while ((((myPoint)listP.Items[i]).det == false) && (i != 0))
                {
                    i--;
                }
                myPoint b = (myPoint)listP.Items[i];
                if (x != b.X || y != b.Y)
                {
                    AbsDraw(x, y);
                }
                else
                {
                    closeFigure(a.X, a.Y, b.X, b.Y);
                }
            }
            else
            {
                AbsDraw(x, y);
            }
        }
        // Draw absolute pixel
        private void AbsDraw(int x, int y)
        {
            myPoint A = new myPoint(x, y, last), B;

            view.Image = BMP;
            Color color = Color.Black;

            if (last)
            {
                listP.Items.Add(A);
                BMP.SetPixel(A.X, A.Y, color);
                last = false;
            }
            else
            {
                B = (myPoint)listP.Items[listP.Items.Count - 1];
                listP.Items.Add(A);
                LineTo(B.X, B.Y, A.X, A.Y, color);
            }

            Zag = true;
        }