C# 如何在C中使用鼠标在图片框以外的图像上绘制矩形框# private void pictureBoxImage\u MouseDown(对象发送方,MouseEventArgs e) { if(e.Button==MouseButtons.Left) { 端

C# 如何在C中使用鼠标在图片框以外的图像上绘制矩形框# private void pictureBoxImage\u MouseDown(对象发送方,MouseEventArgs e) { if(e.Button==MouseButtons.Left) { 端,c#,C#,如何在C中使用鼠标在图片框以外的图像上绘制矩形框# private void pictureBoxImage\u MouseDown(对象发送方,MouseEventArgs e) { if(e.Button==MouseButtons.Left) { 端点=起始点=e.位置; 绘图=真; } } 私有void pictureBoxImage\u MouseMove(对象发送方,MouseEventArgs e) { 终点=e.位置; if(绘图)pictureBoxImage.Invalida

如何在C中使用鼠标在图片框以外的图像上绘制矩形框#
private void pictureBoxImage\u MouseDown(对象发送方,MouseEventArgs e)
{
if(e.Button==MouseButtons.Left)
{
端点=起始点=e.位置;
绘图=真;
}
}
私有void pictureBoxImage\u MouseMove(对象发送方,MouseEventArgs e)
{
终点=e.位置;
if(绘图)pictureBoxImage.Invalidate();
}
私有void pictureBoxImage\u MouseUp(对象发送器,MouseEventArgs e)
{
if(图纸)
{
图纸=假;
var rects=getRect();
var rw=矩形X+矩形宽度;
如果(rects.Width>10和&rects.Height>10和&rw,例如,-请参阅
GetImageScaledRatio()
CanvasToImageRect()
等方法。或者:请参阅
GetScaledRect()
GetDrawingImageRect()
OffsetScaledRectangleOnMousePosition()等方法。--或者
private void pictureBoxImage_MouseDown(object sender, MouseEventArgs e) 
{
    if (e.Button == MouseButtons.Left) 
    {
        endpoint = startPoint = e.Location;
        drawing = true;
    }
}

private void pictureBoxImage_MouseMove(object sender, MouseEventArgs e) 
{
   endpoint = e.Location;

   if (drawing) pictureBoxImage.Invalidate();
}

private void pictureBoxImage_MouseUp(object sender, MouseEventArgs e) 
{
   if (drawing) 
   {
     drawing = false;
     var rects = getRect();
     var rw = rects.X + rects.Width;

     if (rects.Width > 10 && rects.Height > 10 && rw <= 1920) 
        rect.Add(rects);

     pictureBoxImage.Invalidate();
   }
}