这个问题之前曾被问过,但由于它不起作用并且我缺乏声誉点(我试图对问题发表评论,但我不能),我不得不再次问这个问题。
这是之前问的问题的链接; 如何缩放图片框中的某个点
我使用了链接中显示的代码,但是当我运行它时,点或形状消失了。
这是我的代码;
public partial class Form1 : Form
{
private Matrix transform = new Matrix();
private double m_dZoomscale = 1.0;
public static double s_dScrollValue = .1;
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.Transform = transform;
Pen mypen = new Pen(Color.Red,5);
Rectangle rect = new Rectangle(10, 10, 30, 30);
e.Graphics.DrawRectangle(mypen, rect);
}
protected override void OnMouseWheel(MouseEventArgs mea)
{
pictureBox1.Focus();
if (pictureBox1.Focused == true && mea.Delta != 0)
{
ZoomScroll(mea.Location, mea.Delta > 0); …Run Code Online (Sandbox Code Playgroud)