我想在面板上创建的绘图上应用放大缩小。我尝试了下面的代码,但问题是缩放效果也适用于面板。 以下是我的代码段:
private void XY_dbleBufferPanel_MouseWheel(object sender, MouseEventArgs e)
{
// If the mouse wheel is moved forward (Zoom in)
if (e.Delta > 0){
if ((XY_dbleBufferPanel.Width < (15 * this.Width)) && (XY_dbleBufferPanel.Height < (15 * this.Height))){
XY_dbleBufferPanel.Width = (int)(XY_dbleBufferPanel.Width * 1.25);
XY_dbleBufferPanel.Height = (int)(XY_dbleBufferPanel.Height * 1.25);
XY_dbleBufferPanel.Top = (int)(e.Y - 1.25 * (e.Y - XY_dbleBufferPanel.Top));
XY_dbleBufferPanel.Left = (int)(e.X - 1.25 * (e.X - XY_dbleBufferPanel.Left));
}
}
else{
if ((XY_dbleBufferPanel.Width > (this.Width / 15)) && (XY_dbleBufferPanel.Height > (this.Height / 15))) {
XY_dbleBufferPanel.Width = (int)(XY_dbleBufferPanel.Width / 1.25);
XY_dbleBufferPanel.Height = (int)(XY_dbleBufferPanel.Height / 1.25);
XY_dbleBufferPanel.Top = (int)(e.Y - 0.80 * (e.Y - XY_dbleBufferPanel.Top));
XY_dbleBufferPanel.Left = (int)(e.X - 0.80 * (e.X - XY_dbleBufferPanel.Left));
}
}
}