我可以使用图片框缩放图表吗? [英] can i use picture box zoom for chart?

查看:82
本文介绍了我可以使用图片框缩放图表吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的代码缩放图片。它是否正常工作。

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?

查看此文章:

MSChart Extension - 缩放和平移控制

您也可以在此论坛中发布您的问题以寻求有关如何使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:

.NET Framework的图表控件


这篇关于我可以使用图片框缩放图表吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆