如何使用鼠标滚轮在绘制的矩形区域上放大缩小?(How do i make zoom in zoom out with the mouse wheel over a drawn rectangle ar

编程入门 行业动态 更新时间:2024-10-18 20:22:59
如何使用鼠标滚轮在绘制的矩形区域上放大缩小?(How do i make zoom in zoom out with the mouse wheel over a drawn rectangle area? [closed])

这个代码我用来在pictureBox1上绘制一个矩形:

private void DrawRectangle(Graphics e) { using (Pen pen = new Pen(Color.Red, 2)) { e.DrawRectangle(pen, mRect); } } private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { mRect = new Rectangle(e.X, e.Y, 0, 0); pictureBox1.Invalidate(); } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { mRect = new Rectangle(mRect.Left, mRect.Top, e.X - mRect.Left, e.Y - mRect.Top); pictureBox1.Invalidate(); } }

当我向上或向下移动鼠标滚轮时,我如何绘制矩形后,它将调整pictureBox1中iamge上绘制的矩形区域的大小? 不调整所有图像的大小,但仅对矩形绘制区域进行放大/缩小。

This the code im using to draw a rectangle over a pictureBox1:

private void DrawRectangle(Graphics e) { using (Pen pen = new Pen(Color.Red, 2)) { e.DrawRectangle(pen, mRect); } } private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { mRect = new Rectangle(e.X, e.Y, 0, 0); pictureBox1.Invalidate(); } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { mRect = new Rectangle(mRect.Left, mRect.Top, e.X - mRect.Left, e.Y - mRect.Top); pictureBox1.Invalidate(); } }

How do i make that after i drawed a rectangle when i move the mouse wheel up or down it will resize the drawn rectangle area on the iamge in the pictureBox1 ? Not resize all the image but make zoom in/out only for the rectangle drawn area.

最满意答案

熟悉MouseWheel事件。

Get familiar with the MouseWheel event.

更多推荐

本文发布于:2023-08-06 17:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1452810.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:鼠标   矩形   如何使用   滚轮   区域

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!