国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

WinForm繪制圓角的方法

2020-01-24 01:31:12
字體:
來源:轉載
供稿:網友

本文實例講述了WinForm繪制圓角的方法。分享給大家供大家參考。具體實現方法如下:

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Runtime.InteropServices;using System.Drawing.Drawing2D;namespace AppStartSample{ public partial class Form3 : Form {  public Form3()  {   InitializeComponent();  }  private void button1_Click(object sender, EventArgs e)  {  }  private void button2_Click(object sender, EventArgs e)  {  }  public void SetWindowRegion()  {   System.Drawing.Drawing2D.GraphicsPath FormPath;   FormPath = new System.Drawing.Drawing2D.GraphicsPath();   Rectangle rect = new Rectangle(0, 22, this.Width, this.Height - 22);//   FormPath = GetRoundedRectPath(rect, 30);   this.Region = new Region(FormPath);  }  private GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)  {   int diameter = radius;   Rectangle arcRect = new Rectangle(rect.Location, new Size(diameter, diameter));   GraphicsPath path = new GraphicsPath();   // 左上角     path.AddArc(arcRect, 180, 90);   // 右上角     arcRect.X = rect.Right - diameter;   path.AddArc(arcRect, 270, 90);   // 右下角     arcRect.Y = rect.Bottom - 0;   path.AddArc(arcRect, 0, 90);   // 左下角     arcRect.X = rect.Left;   path.AddArc(arcRect, 90, 90);   path.CloseFigure();   return path;  }  protected override void OnResize(System.EventArgs e)  {   this.Region = null;   SetWindowRegion();  } }}

希望本文所述對大家的C#程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 黎川县| 农安县| 长岭县| 安化县| 连州市| 赫章县| 柘荣县| 霍州市| 铅山县| 上犹县| 互助| 望谟县| 乌拉特前旗| 贵州省| 宁城县| 商城县| 信宜市| 当阳市| 黄冈市| 修武县| 澜沧| 绥棱县| 霍邱县| 当涂县| 宣威市| 合肥市| 敦煌市| 珠海市| 罗城| 景德镇市| 无锡市| 奎屯市| 和龙市| 垣曲县| 桦南县| 马关县| 烟台市| 三穗县| 玉龙| 合肥市| 陆河县|