非常感謝.
如果參數很多,太麻煩的話,可以這樣。
繪圖的時候,把圖形繪製到picture中,把picture放在窗體上,這樣圖形始終在內存中保留。無論如何切換窗口,圖形都不會消失。
具體繪圖方法:
引用如下命名空間:
using System.Drawing;
using System.Drawing.Imaging;
申明變量:
private Image theImage;//要繪圖的圖片對象
private Graphics ig; //在圖片上繪圖的Graphics對象
private System.Windows.Forms.PictureBox MyPicBox;//窗體上的picturebox控件
theImage=new Bitmap(600,800);//寬,高
ig=Graphics.FromImage(theImage);
ig.Clear(Color.White); //底色爲白色
MyPicBox.Image=theImage;//將繪製的image放在picturebox中
Pen drawPen = new Pen ( Color . Blue , 2 ) ; //畫筆工具
ig.DrawRectangle(drawPen,20,20,40,40);//繪製一個矩形區域