Ejemplo n.º 1
0
        private void SrcPicBox_MouseDown(object sender, MouseEventArgs e)
        {
            // Make a note that we "have the mouse".
            bHaveMouse = true;

            if (rectCropArea != null)
            {
                if (_rectangleStatus == RectangleStatus.Moving)
                {
                    _rectangleLocation = rectCropArea.Location;
                    _mouseClick        = new Point(e.X, e.Y);
                }
                else if (_rectangleStatus == RectangleStatus.Resizing)
                {
                    _mouseClick    = new Point(e.X, e.Y);
                    _prevRectangle = new Rectangle(rectCropArea.X, rectCropArea.Y, rectCropArea.Width, rectCropArea.Height);
                }
                else
                {
                    _rectangleStatus = RectangleStatus.Creating;
                    // Store the "starting point" for this rubber-band rectangle.
                    ptOriginal.X = e.X;
                    ptOriginal.Y = e.Y;
                    // Special value lets us know that no previous
                    // rectangle needs to be erased.
                    ptLast.X     = -1;
                    ptLast.Y     = -1;
                    rectCropArea = new Rectangle(new Point(e.X, e.Y), new Size());
                }
            }
        }
Ejemplo n.º 2
0
 public ImageCorrection(Image image, string inifilename, string inikey)
 {
     iniFileName      = inifilename;
     _rectangleStatus = RectangleStatus.Creating;
     iniKey           = inikey;
     _image           = image;
     InitializeComponent();
     bHaveMouse = false;
 }
Ejemplo n.º 3
0
 private void PBX_MouseDown(object sender, MouseEventArgs e)
 {
     isMousePressed = true;
     if (rectCropArea != null)
     {
         _prevRectangle      = rectCropArea;
         _mouseClickLocation = e.Location;
         if (_rectangleStatus != RectangleStatus.Moving && _rectangleStatus != RectangleStatus.Resizing)
         {
             _rectangleStatus = RectangleStatus.Creating;
             rectCropArea     = new Rectangle(new Point(e.X, e.Y), new Size());
         }
     }
 }
Ejemplo n.º 4
0
        private void SrcPicBox_MouseMove(object sender, MouseEventArgs e)
        {
            //Point ptCurrentNormalised = new Point((int)(e.X / ratio), (int)(e.Y / ratio));

            // If we "have the mouse", then we draw our lines.
            if (bHaveMouse)
            {
                // Update last point.
                if (_rectangleStatus == RectangleStatus.Moving)
                {
                    MoveRect(e.Location);
                }
                else if (_rectangleStatus == RectangleStatus.Resizing)
                {
                    ResizeRect(e.Location);
                }
                else
                {
                    ptLast = ptCurrent;
                    InitRectCropArea(new Point(e.X, e.Y), ptOriginal);
                }
                SrcPicBox.Refresh();
            }
            else
            {
                if (rectCropArea != null)
                {
                    if
                    (
                        (e.X >= (rectCropArea.X + _resizeArea)) &&
                        (e.X <= (rectCropArea.X + rectCropArea.Width - _resizeArea)) &&
                        (e.Y >= (rectCropArea.Y + _resizeArea)) &&
                        (e.Y <= (rectCropArea.Y + rectCropArea.Height - _resizeArea))
                    )
                    {
                        _rectangleStatus = RectangleStatus.Moving;
                        this.Cursor      = Cursors.Hand;
                        _currentLine     = 0;
                    }
                    else if
                    (
                        (e.X >= (rectCropArea.X + _resizeArea)) &&
                        (e.Y >= (rectCropArea.Y - _resizeArea)) &&
                        (e.X <= (rectCropArea.X + rectCropArea.Width - _resizeArea)) &&
                        (e.Y <= (rectCropArea.Y + _resizeArea))
                    )
                    {
                        _rectangleStatus = RectangleStatus.Resizing;
                        this.Cursor      = Cursors.SizeNS;
                        _currentLine     = 2;
                    }
                    else if
                    (
                        (e.X >= (rectCropArea.X - _resizeArea)) &&
                        (e.Y >= (rectCropArea.Y + _resizeArea)) &&
                        (e.X <= (rectCropArea.X + _resizeArea)) &&
                        (e.Y <= (rectCropArea.Y + rectCropArea.Height - _resizeArea))
                    )
                    {
                        _rectangleStatus = RectangleStatus.Resizing;
                        this.Cursor      = Cursors.SizeWE;
                        _currentLine     = 8;
                    }
                    else if
                    (
                        (e.X >= (rectCropArea.X + _resizeArea)) &&
                        (e.Y >= (rectCropArea.Y + rectCropArea.Height - _resizeArea)) &&
                        (e.X <= (rectCropArea.X + rectCropArea.Width - _resizeArea)) &&
                        (e.Y <= (rectCropArea.Y + rectCropArea.Height + _resizeArea))
                    )
                    {
                        _rectangleStatus = RectangleStatus.Resizing;
                        this.Cursor      = Cursors.SizeNS;
                        _currentLine     = 6;
                    }
                    else if
                    (
                        (e.X >= (rectCropArea.X + rectCropArea.Width - _resizeArea)) &&
                        (e.Y >= (rectCropArea.Y + _resizeArea)) &&
                        (e.X <= (rectCropArea.X + rectCropArea.Width + _resizeArea)) &&
                        (e.Y <= (rectCropArea.Y + rectCropArea.Height - _resizeArea))
                    )
                    {
                        _rectangleStatus = RectangleStatus.Resizing;
                        this.Cursor      = Cursors.SizeWE;
                        _currentLine     = 4;
                    }
                    else if
                    (
                        (e.X >= (rectCropArea.X - _resizeArea)) &&
                        (e.Y >= (rectCropArea.Y - _resizeArea)) &&
                        (e.X <= (rectCropArea.X + _resizeArea)) &&
                        (e.Y <= (rectCropArea.Y + _resizeArea))
                    )
                    {
                        _rectangleStatus = RectangleStatus.Resizing;
                        this.Cursor      = Cursors.SizeNWSE;
                        _currentLine     = 1;
                    }
                    else if
                    (
                        (e.X >= (rectCropArea.X + rectCropArea.Width - _resizeArea)) &&
                        (e.Y >= (rectCropArea.Y - _resizeArea)) &&
                        (e.X <= (rectCropArea.X + rectCropArea.Width + _resizeArea)) &&
                        (e.Y <= (rectCropArea.Y + _resizeArea))
                    )
                    {
                        _rectangleStatus = RectangleStatus.Resizing;
                        this.Cursor      = Cursors.SizeNESW;
                        _currentLine     = 3;
                    }
                    else if
                    (
                        (e.X >= (rectCropArea.X + rectCropArea.Width - _resizeArea)) &&
                        (e.Y >= (rectCropArea.Y + rectCropArea.Height - _resizeArea)) &&
                        (e.X <= (rectCropArea.X + rectCropArea.Width + _resizeArea)) &&
                        (e.Y <= (rectCropArea.Y + rectCropArea.Height + _resizeArea))
                    )
                    {
                        _rectangleStatus = RectangleStatus.Resizing;
                        this.Cursor      = Cursors.SizeNWSE;
                        _currentLine     = 5;
                    }
                    else if
                    (
                        (e.X >= (rectCropArea.X - _resizeArea)) &&
                        (e.Y >= (rectCropArea.Y + rectCropArea.Height - _resizeArea)) &&
                        (e.X <= (rectCropArea.X + _resizeArea)) &&
                        (e.Y <= (rectCropArea.Y + rectCropArea.Height + _resizeArea))
                    )
                    {
                        _rectangleStatus = RectangleStatus.Resizing;
                        this.Cursor      = Cursors.SizeNESW;
                        _currentLine     = 7;
                    }
                    else
                    {
                        _rectangleStatus = RectangleStatus.Creating;
                        this.Cursor      = Cursors.Default;
                        _currentLine     = 0;
                    }
                }
            }
        }
Ejemplo n.º 5
0
 private void SetPosition(Point e)
 {
     if (rectCropArea != null)
     {
         if
         (
             (e.X >= (rectCropArea.X + _resizeArea)) &&
             (e.X <= (rectCropArea.X + rectCropArea.Width - _resizeArea)) &&
             (e.Y >= (rectCropArea.Y + _resizeArea)) &&
             (e.Y <= (rectCropArea.Y + rectCropArea.Height - _resizeArea))
         )
         {
             _rectangleStatus = RectangleStatus.Moving;
             this.Cursor      = Cursors.Hand;
             _currentLine     = 0;
         }
         else if
         (
             (e.X >= (rectCropArea.X + _resizeArea)) &&
             (e.Y >= (rectCropArea.Y - _resizeArea)) &&
             (e.X <= (rectCropArea.X + rectCropArea.Width - _resizeArea)) &&
             (e.Y <= (rectCropArea.Y + _resizeArea))
         )
         {
             _rectangleStatus = RectangleStatus.Resizing;
             this.Cursor      = Cursors.SizeNS;
             _currentLine     = 2;
         }
         else if
         (
             (e.X >= (rectCropArea.X - _resizeArea)) &&
             (e.Y >= (rectCropArea.Y + _resizeArea)) &&
             (e.X <= (rectCropArea.X + _resizeArea)) &&
             (e.Y <= (rectCropArea.Y + rectCropArea.Height - _resizeArea))
         )
         {
             _rectangleStatus = RectangleStatus.Resizing;
             this.Cursor      = Cursors.SizeWE;
             _currentLine     = 8;
         }
         else if
         (
             (e.X >= (rectCropArea.X + _resizeArea)) &&
             (e.Y >= (rectCropArea.Y + rectCropArea.Height - _resizeArea)) &&
             (e.X <= (rectCropArea.X + rectCropArea.Width - _resizeArea)) &&
             (e.Y <= (rectCropArea.Y + rectCropArea.Height + _resizeArea))
         )
         {
             _rectangleStatus = RectangleStatus.Resizing;
             this.Cursor      = Cursors.SizeNS;
             _currentLine     = 6;
         }
         else if
         (
             (e.X >= (rectCropArea.X + rectCropArea.Width - _resizeArea)) &&
             (e.Y >= (rectCropArea.Y + _resizeArea)) &&
             (e.X <= (rectCropArea.X + rectCropArea.Width + _resizeArea)) &&
             (e.Y <= (rectCropArea.Y + rectCropArea.Height - _resizeArea))
         )
         {
             _rectangleStatus = RectangleStatus.Resizing;
             this.Cursor      = Cursors.SizeWE;
             _currentLine     = 4;
         }
         else if
         (
             (e.X >= (rectCropArea.X - _resizeArea)) &&
             (e.Y >= (rectCropArea.Y - _resizeArea)) &&
             (e.X <= (rectCropArea.X + _resizeArea)) &&
             (e.Y <= (rectCropArea.Y + _resizeArea))
         )
         {
             _rectangleStatus = RectangleStatus.Resizing;
             this.Cursor      = Cursors.SizeNWSE;
             _currentLine     = 1;
         }
         else if
         (
             (e.X >= (rectCropArea.X + rectCropArea.Width - _resizeArea)) &&
             (e.Y >= (rectCropArea.Y - _resizeArea)) &&
             (e.X <= (rectCropArea.X + rectCropArea.Width + _resizeArea)) &&
             (e.Y <= (rectCropArea.Y + _resizeArea))
         )
         {
             _rectangleStatus = RectangleStatus.Resizing;
             this.Cursor      = Cursors.SizeNESW;
             _currentLine     = 3;
         }
         else if
         (
             (e.X >= (rectCropArea.X + rectCropArea.Width - _resizeArea)) &&
             (e.Y >= (rectCropArea.Y + rectCropArea.Height - _resizeArea)) &&
             (e.X <= (rectCropArea.X + rectCropArea.Width + _resizeArea)) &&
             (e.Y <= (rectCropArea.Y + rectCropArea.Height + _resizeArea))
         )
         {
             _rectangleStatus = RectangleStatus.Resizing;
             this.Cursor      = Cursors.SizeNWSE;
             _currentLine     = 5;
         }
         else if
         (
             (e.X >= (rectCropArea.X - _resizeArea)) &&
             (e.Y >= (rectCropArea.Y + rectCropArea.Height - _resizeArea)) &&
             (e.X <= (rectCropArea.X + _resizeArea)) &&
             (e.Y <= (rectCropArea.Y + rectCropArea.Height + _resizeArea))
         )
         {
             _rectangleStatus = RectangleStatus.Resizing;
             this.Cursor      = Cursors.SizeNESW;
             _currentLine     = 7;
         }
         else
         {
             _rectangleStatus = RectangleStatus.Creating;
             this.Cursor      = Cursors.Default;
             _currentLine     = 0;
         }
     }
 }