1、表單邊角圓弧處理
在表單的Paint事件中或者Resize事件中處理這個過程,具體代碼如下:
private void SetFormCircle()
{
int radian = 4; //圓弧角的比率,可以自己改變這個值看具體的效果
int w = this.Width; //表單寬
int h = this.Height; //表單高
//對於矩形的表單,要在一個角上畫個弧度至少需要2個點,所以4個角需要至少8個點
Point p1 = new Point(radian, 0);
Point p2 = new Point(w - radian, 0);
Point p3 = new Point(w, radian);
Point p4 = new Point(w, h - radian);
Point p5 = new Point(w - radian, h);
Point p6 = new Point(radian, h);
Point p7 = new Point(0, h - radian);
Point p8 = new Point(0, radian);
System.Drawing.Drawing2D.GraphicsPath shape = new System.Drawing.Drawing2D.GraphicsPath();
Point[] p = new Point[] { p1, p2, p3, p4, p5, p6, p7, p8 };
shape.AddPolygon(p);
//將表單的顯示地區設為GraphicsPath的執行個體
this.Region = new System.Drawing.Region(shape);
}
2、c#中調用外部程式
比如要開啟一“c:\windows”這個目錄,可以這些做
Process.Start("explorer.exe",@"c:\windows");
要執行一個DOS批處理,可以這樣做
//sPath是批次檔的路徑
myProcess.StartInfo.FileName = sPath;
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
myProcess.StartInfo.Verb = "open";
myProcess.StartInfo.CreateNoWindow = false;
myProcess.StartInfo.UseShellExecute = false;
myProcess.Start();