【效果圖】
 
【思路】:
 在form的onload中 先使form不可見,然后從內向外,一層一層繪制rectangle ,最后讓form可見
【難點】
 首先輸出效果的rectangle要有個地方顯示,main form可不行,因為當繪制rectangle的時候 ,form是不可見的,這里使用了desktop桌面
【代碼如下】
1. 加入命名空間
 using system.drawing.imaging;
using system.runtime.interopservices;
2. 聲明win32 api getdc()
 [ dllimport("user32") ]
 public static extern system.intptr getdc(system.intptr dc);
3. 聲明變量
 system.drawing.graphics g; //畫圖板
 pen p=new pen(color.black,1); //畫筆
 int startx,starty,wx,wy,step; //startx,starty,wx,wy確定一個矩形
 int cx,cy; //cx,cy為form的client的width 和height
4.在form的onload上加上如下代碼
 this.visible=false;
 step=1;
 g=graphics.fromhdc(getdc(system.intptr.zero));
 cx=this.clientsize.width;
 cy=this.clientsize.height;
 this.visible=false;
 step=1;
 while(step<=cx/2)
 {
 startx=cx/2-step;
 starty=cy*startx/cx;
 wx=2*step;
 wy=wx*cy/cx;
 startx+=this.left;
 starty+=this.top+this.height-this.clientsize.height;
 g.drawrectangle(p,startx,starty,wx,wy);
 system.threading.thread.sleep(100);
 step+=10;
 }
 this.visible=true;
 
ps:這是第一次發表原創, 大家多多指教