示例#1
0
        private void picturebox_MouseMove(object sender, MouseEventArgs e)
        {
            if (dragging)
            {
                PointF delta = e.Location.Subtract(drag_origin);
                if (dragmode == 1)
                {
                    _selection = drag_select.Add(delta);
                }
                else if (dragmode == 2)
                {
                    float w = drag_select.Width / 2f, h = drag_select.Height / 2f;
                    if (delta.X > delta.Y)
                    {
                        w = Math.Max(20f, w + delta.X);
                        h = w * (float)AspectRatio;
                    }
                    else
                    {
                        h = Math.Max(20 * (float)AspectRatio, h + delta.Y);
                        w = h / (float)AspectRatio;
                    }

                    h = (float)Math.Round(h);
                    w = (float)Math.Round(w);

                    _selection = new RectangleF(drag_cent.X - w, drag_cent.Y - h, w * 2, h * 2);
                }
                picturebox.Invalidate();
            }
            else
            {
                picturebox.Cursor = imgcurs[imageZone(e.X, e.Y)];
            }
        }