示例#1
0
        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);
            }
        }
示例#2
0
        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);
        }
示例#3
0
        // 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);
            }
        }
示例#4
0
        // 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;
        }