我可以使用图片框缩放图表吗?
我使用下面的代码缩放图片。它是否正常工作。
i use below code for zoom of picture. it works correctly.
我可以将它用于图表吗?
can i use it for chart?
我的意思是我将它用于图表,但它没有用。图表剂量没有" e.Graphics.ScaleTransform(缩放,缩放);"或"e.Graphics.DrawImage(img,imgx,imgy);" 。
i mean i used it for chart but it did not work . chart dose not have " e.Graphics.ScaleTransform(zoom, zoom);" or "e.Graphics.DrawImage(img, imgx, imgy);" .
imgx或imgy应该怎么做?
what should i do by imgx or imgy ?
zoom cod for图片框中的图片:
zoom cod for image in picturebox :
protected override void OnMouseWheel(MouseEventArgs e)
{
_pic_image.Image = null;
this.Cursor = Cursors.Default;
float oldzoom = zoom;
if (e.Delta > 0)
{
zoom += 0.625f;
zoomPerectNum += 50;
_txt_precentZoom.Text = zoomPerectNum.ToString() + "%";
}
else if (e.Delta < 0)
{
// zoom = Math.Max(zoom - 1F, 1F);
zoom = zoom - 0.625F;
if (zoom < 0.2503874F)
{
zoom = 0.2503874F;
}
else
{
zoomPerectNum -= 50;
_txt_precentZoom.Text = zoomPerectNum.ToString() + "%";
}
}
MouseEventArgs mouse = e as MouseEventArgs;
Point mousePosNow = mouse.Location;
int x = mousePosNow.X - _pic_image.Location.X; // Where location of the mouse in the pictureframe
int y = mousePosNow.Y - _pic_image.Location.Y;
int oldimagex = (int)(x / oldzoom); // Where in the IMAGE is it now
int oldimagey = (int)(y / oldzoom);
int newimagex = (int)(x / zoom); // Where in the IMAGE will it be when the new zoom i made
int newimagey = (int)(y / zoom);
imgx = newimagex - oldimagex + imgx; // Where to move image to keep focus on one point
imgy = newimagey - oldimagey + imgy;
_pic_image.Refresh(); // calls imageBox_Paint
}
private void imageBox_Paint(object sender, PaintEventArgs e)
{
e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
e.Graphics.ScaleTransform(zoom, zoom);
if (img != null)
{
e.Graphics.DrawImage(img, imgx, imgy);
}
}
您好Neda.IT,
Hi Neda.IT,
您是否在Windows窗体应用程序中使用MS Chart控件?
Are you using MS Chart control in Windows Forms Application?
查看此文章:
您也可以在此论坛中发布您的问题以寻求有关如何使MS Chart控件可以使用内置功能进行缩放:
Also you could post your question in this forum to ask for help about how to make the MS Chart control zoomable with built-in features: