Beispiel #1
0
        public void mouseUpFill()
        {
            // clean the area.
            cleanStart();

            // calculate the UVs.
            calUVS();

            // clean up the uv's incase it is great then the picture box.
            CleanUpUVS();


            txtStartText.Text = rec.Location.X.ToString() + " " + rec.Location.Y.ToString();
            txtEndText.Text   = endPoint.X.ToString() + " " + endPoint.Y.ToString();
            txtStartUV.Text   = StartUVX.ToString("n2") + " " + StartUVY.ToString("n2");
            txtEndUV.Text     = EndUVX.ToString("n2") + " " + EndUVY.ToString("n2");
            txtWidth.Text     = rec.Width.ToString();
            txtHeight.Text    = rec.Height.ToString();


            tempItem.startPoint     = rec.Location;
            tempItem.endPoints      = endPoint;
            tempItem.startUVpoint.x = StartUVX;
            tempItem.startUVpoint.y = StartUVY;
            tempItem.endUVpoint.x   = EndUVX;
            tempItem.endUVpoint.y   = EndUVY;
            tempItem.width          = rec.Width;
            tempItem.height         = rec.Height;

            //ConvertCoordinates(pictureBox1, rPic1.X, rPic1.Y, e.X, e.Y);

            setImage(rec);
            //pictureBox2.Image = CropImage(pictureBox1.Image, rec.Location.X, rec.Location.Y, rec.Width, rec.Height);

            pictureBox2.Invalidate();
        }
Beispiel #2
0
        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                //Point finalRecPos = new Point();

                if (e.Location.X < rPic1.X)
                {
                    finalRecPos.X = e.Location.X;
                }
                else
                {
                    finalRecPos.X = rPic1.X;
                }

                if (e.Location.Y < rPic1.Y)
                {
                    finalRecPos.Y = e.Location.Y;
                }
                else
                {
                    finalRecPos.Y = rPic1.Y;
                }

                rec.Location = finalRecPos;

                if (scaleWidith == true)
                {
                    rec.Width = Math.Abs(e.X - rPic1.X);
                }
                if (scaleHeight == true)
                {
                    rec.Height = Math.Abs(e.Y - rPic1.Y);
                }

                CheckBounds(e.Location);

                //lblStartPText.Text = rPic1.X.ToString() + " " + rPic1.Y.ToString();
                //lblEndPText.Text = (rec.Location.X + rec.Width).ToString() + " " + (rec.Location.Y + rec.Height).ToString();

                txtStartText.Text = rPic1.X.ToString() + " " + rPic1.Y.ToString();
                txtEndText.Text   = (rec.Location.X + rec.Width).ToString() + " " + (rec.Location.Y + rec.Height).ToString();
                calUVS();
                txtStartUV.Text = StartUVX.ToString("n2") + " " + StartUVY.ToString("n2");
                txtEndUV.Text   = EndUVX.ToString("n2") + " " + EndUVY.ToString("n2");


                this.Invalidate();
            }

            if (e.Button == MouseButtons.Right)
            {
                if (rec != null)
                {
                    if (checkCollide(e.Location.X, e.Location.Y, 1, 1, rec.X, rec.Y, rec.Width, rec.Height))
                    {
                        rec.Location = Point.Add(rec.Location, (Size)Point.Subtract(e.Location, (Size)MouseDownLocation));

                        MouseDownLocation = e.Location;
                        CheckDraggingRec();
                        pictureBox1.Refresh();
                    }
                }
            }
        }