2024年3月7日发(作者:)

(C#)用户自定义控件-圆角Panel代码(WinForm)

上一篇 / 下一篇 2010-06-24 14:48:28 / 个人分类:WinForm

查看( 397 ) / 评论( 0 ) / 评分( 0 / 0 )

(C#)用户自定义控件-圆角Panel代码(WinForm) 圆角Panel代码

using System;

using c;

using entModel;

using stics;

using ;

using ;

namespace myControlLibrary

{

public partial class RoundPanel :

{

public RoundPanel()

{

InitializeComponent();

g = new g(0, 0, 0, 0);

= new g(0, 0, 0, 0);

oundImageLayout =

h;

}

// 圆角

//

===============================================================================================

private int _Radius; // 圆角弧度

///

圆角弧度(0为不要圆角)

[Browsable(true)]

[Description("圆角弧度(0为不要圆角)")]

public int _setRoundRadius

{

get

{

return _Radius;

}

set

{

if (value < 0) { _Radius = 0; }

else { _Radius = value; }

h();

}

}

// 圆角代码

public void Round( region)

{

//

-----------------------------------------------------------------------------------------------

// 已经是.net提供给我们的最容易的改窗体的属性了(以前要自己调API)

csPath oPath = new

csPath();

int x = 0;

int y = 0;

int thisWidth = ;

int thisHeight = ;

int angle = _Radius;

if (angle > 0)

{

cs g = CreateGraphics();

(x, y, angle, angle, 180, 90);

// 左上角

(thisWidth - angle, y, angle, angle, 270,

90); // 右上角

(thisWidth - angle, thisHeight - angle,

angle, angle, 0, 90); // 右下角

(x, thisHeight - angle, angle, angle, 90,

90); // 左下角

llFigures();

Region = new (oPath);

}

//

-----------------------------------------------------------------------------------------------

else

{

e(x + angle, y, thisWidth - angle, y);

// 顶端

e(thisWidth, y + angle, thisWidth,

thisHeight - angle); // 右边

e(thisWidth - angle, thisHeight, x + angle,

thisHeight); // 底边

e(x, y + angle, x, thisHeight - angle);

// 左边

llFigures();

Region = new (oPath);

}

}

//

===============================================================================================

public RoundPanel(IContainer container)

{

(this);

InitializeComponent();

}

protected override void

OnPaint(ventArgs pe)

{

t(pe);

Round(); // 圆角

}

protected override void OnResize(EventArgs eventargs)

{

ze(eventargs);

h();

}

}

}

/html/25/