C# 表單邊角圓弧處理及在C#中調用外部程式(執行批處理,開啟視窗等)

來源:互聯網
上載者:User

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();

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.