问题描述
winform中,拖了一个panel在form上,放了五个picturebox,然后在panel1_Paint事件里画线DrawLines连接五个pictures,有两个缩小放大按钮,点击缩小,实现整体等比例缩小,点击放大,实现等比例放大,并整体位置改变,怎么实现///<summary>///画图///</summary>///<paramname="sender"></param>///<paramname="e"></param>privatevoidpanel1_Paint(objectsender,PaintEventArgse){Point[]points={newPoint(pb5.Location.X+pb5.Width,pb5.Location.Y+pb5.Height),newPoint(pb4.Location.X,pb4.Location.Y+pb4.Height/2),newPoint(pb4.Location.X+pb4.Width,pb4.Location.Y+pb4.Height/2),newPoint(pb1.Location.X+pb1.Width,pb1.Location.Y+pb1.Height/2),};Point[]points2={newPoint(pb4.Location.X+pb4.Width,pb4.Location.Y+pb4.Height/2),newPoint(pb2.Location.X+pb2.Width,pb2.Location.Y+pb2.Height/2)};Point[]points3={newPoint(pb4.Location.X,pb4.Location.Y+pb4.Height/2),newPoint(pb3.Location.X+pb3.Width,pb3.Location.Y+pb3.Height/2)};e.Graphics.DrawLines(newPen(Color.Black,4),points);e.Graphics.DrawLines(newPen(Color.Black,4),points2);e.Graphics.DrawLines(newPen(Color.Black,4),points3);}
解决方案
解决方案二:
都用Paint了,为什么还要用PictureBox呢?很多人都是不放心自己做绘图过程,然后就出现很多无法解释的问题。放大缩小难道不是用坐标计算就能实现的吗?这个计算过程不能再伸手要了吧
解决方案三:
panel没有改变尺寸,panel中的五个picturebox也没有动那么放大缩小的是什么呢?线条也有大小吗?
解决方案四:
那你就改变panel的属性啊