DOTNETBAR制作圓角窗體和圓角控件代碼實例
1、如果制作圓角窗體,窗體先繼承DOTNETBAR的:public partial class Form2 : DevComponents.DotNetBar.Office2007Form
然后窗體里加上一個DONTERBAR的panel,然后設置panel為fill占滿整個窗體
然后設置panel的CornerType為Rounded,然后窗體就變?yōu)閳A角的了: panelEx1.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded;
2、如果是圓角控件就照葫蘆畫瓢,把panel放在控件上面,然后設置為fill,再設置panel的CornerType為Rounded就變?yōu)閳A角控件了
DOTNETBAR的button控件默認就可以設置為圓角按鈕的
今天弄個了一天最后弄出了圓角窗體,可是不是用DOTNETBAR,原來DOTNETBAR實現(xiàn)不了,以下是本人實現(xiàn)圓角窗體的代碼
/// <summary>
/// 重繪窗體為圓角
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DispenserForm_Paint(object sender, PaintEventArgs e)
{
Form form = ((Form)sender);
List<Point> list = new List<Point>();
int width = form.Width;
int height = form.Height;
//左上
list.Add(new Point(0, 5));
list.Add(new Point(1, 5));
list.Add(new Point(1, 3));
list.Add(new Point(2, 3));
list.Add(new Point(2, 2));
list.Add(new Point(3, 2));
list.Add(new Point(3, 1));
list.Add(new Point(5, 1));
list.Add(new Point(5, 0));
//右上
list.Add(new Point(width - 5, 0));
list.Add(new Point(width - 5, 1));
list.Add(new Point(width - 3, 1));
list.Add(new Point(width - 3, 2));
list.Add(new Point(width - 2, 2));
list.Add(new Point(width - 2, 3));
list.Add(new Point(width - 1, 3));
list.Add(new Point(width - 1, 5));
list.Add(new Point(width - 0, 5));
//右下
list.Add(new Point(width - 0, height - 5));
list.Add(new Point(width - 1, height - 5));
list.Add(new Point(width - 1, height - 3));
list.Add(new Point(width - 2, height - 3));
list.Add(new Point(width - 2, height - 2));
list.Add(new Point(width - 3, height - 2));
list.Add(new Point(width - 3, height - 1));
list.Add(new Point(width - 5, height - 1));
list.Add(new Point(width - 5, height - 0));
//左下
list.Add(new Point(5, height - 0));
list.Add(new Point(5, height - 1));
list.Add(new Point(3, height - 1));
list.Add(new Point(3, height - 2));
list.Add(new Point(2, height - 2));
list.Add(new Point(2, height - 3));
list.Add(new Point(1, height - 3));
list.Add(new Point(1, height - 5));
list.Add(new Point(0, height - 5));
Point[] points = list.ToArray();
GraphicsPath shape = new GraphicsPath();
shape.AddPolygon(points);
//將窗體的顯示區(qū)域設為GraphicsPath的實例
form.Region = new System.Drawing.Region(shape);
}
相關文章
c# 重載WndProc,實現(xiàn)重寫“最小化”的實現(xiàn)方法
在做“亦歌桌面版”的時候,發(fā)現(xiàn)當打開歌詞狀態(tài)下,用最小化隱藏窗體到托盤的話(如下code #1),在調(diào)出發(fā)現(xiàn)歌詞縮小了(雖然顯現(xiàn)的窗體大小跟剛才一樣),從這點看調(diào)用該方法其實窗體大小是改變了的(這個過程只是不可視而已)。2009-02-02