资源简介
c#美化winform中的button(通过重绘封装成新的控件)
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
namespace CSharpWin
{
/* 作者:Starts_2000
* 日期:2009-07-31
* 网站:http://www.csharpwin.com CS 程序员之窗。
* 你可以免费使用或修改以下代码,但请保留版权信息。
* 具体请查看 CS程序员之窗开源协议(http://www.csharpwin.com/csol.html)。
*/
public class ButtonEx : Button
{
private Color _baseColor = Color.FromArgb(51 161 224);
private ControlState _controlState;
private int _imageWidth = 18;
private Roundstyle _roundstyle = Roundstyle.All;
private int _radius = 8;
public ButtonEx()
: base()
{
Setstyle(
Controlstyles.UserPaint |
Controlstyles.AllPaintingInWmPaint |
Controlstyles.OptimizedDoubleBuffer |
Controlstyles.ResizeRedraw |
Controlstyles.SupportsTransparentBackColor true);
}
[DefaultValue(typeof(Color)“51 161 224“)]
public Color baseColor
{
get { return _baseColor; }
set
{
_baseColor = value;
base.Invalidate();
}
}
[DefaultValue(18)]
public int ImageWidth
{
get { return _imageWidth; }
set
{
if (value != _imageWidth)
{
_imageWidth = value < 12 ? 12 : value;
base.Invalidate();
}
}
}
[DefaultValue(typeof(Roundstyle) “1“)]
public Roundstyle Roundstyle
{
get { return _roundstyle; }
set
{
if (_roundstyle != value)
{
_roundstyle = value;
base.Invalidate();
}
}
}
[DefaultValue(8)]
public int Radius
{
get { return _radius; }
set
{
if (_radius != value)
{
_radius = value < 4 ? 4 : value;
base.Invalidate();
}
}
}
internal ControlState ControlState
{
get { return _controlState; }
set
{
if (_controlState != value)
{
_controlState = value;
base.Invalidate();
}
}
}
protected override void onmouseenter(EventArgs e)
{
base.onmouseenter(e);
ControlState = ControlState.Hover;
}
protected override void onmouseleave(EventArgs e)
{
base.onmouseleave(e);
ControlState =
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 249 2009-07-31 09:41 ButtonExDemo\ButtonExDemo\Properties\Settings.settings
文件 1208 2009-07-31 09:41 ButtonExDemo\ButtonExDemo\Properties\AssemblyInfo.cs
文件 4067 2009-07-31 10:55 ButtonExDemo\ButtonExDemo\Properties\Resources.Designer.cs
文件 1096 2009-07-31 09:41 ButtonExDemo\ButtonExDemo\Properties\Settings.Designer.cs
文件 7127 2009-07-31 10:55 ButtonExDemo\ButtonExDemo\Properties\Resources.resx
文件 22079 2009-07-31 11:34 ButtonExDemo\ButtonExDemo\Form1.Designer.cs
文件 5814 2009-07-31 11:34 ButtonExDemo\ButtonExDemo\Form1.resx
文件 3840 2009-07-31 10:56 ButtonExDemo\ButtonExDemo\ButtonExDemo.csproj
文件 5632 2005-11-11 22:25 ButtonExDemo\ButtonExDemo\bin\Debug\ButtonExDemo.vshost.exe
文件 28672 2009-07-31 11:32 ButtonExDemo\ButtonExDemo\bin\Debug\ButtonEx.dll
文件 34304 2009-07-31 11:32 ButtonExDemo\ButtonExDemo\bin\Debug\ButtonEx.pdb
文件 32768 2009-07-31 11:48 ButtonExDemo\ButtonExDemo\bin\Debug\ButtonExDemo.exe
文件 28160 2009-07-31 11:48 ButtonExDemo\ButtonExDemo\bin\Debug\ButtonExDemo.pdb
文件 5120 2009-07-31 10:55 ButtonExDemo\ButtonExDemo\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
文件 180 2009-07-31 11:48 ButtonExDemo\ButtonExDemo\obj\Debug\ButtonExDemo.Form1.resources
文件 8386 2009-07-31 11:32 ButtonExDemo\ButtonExDemo\obj\Debug\ButtonExDemo.Properties.Resources.resources
文件 28160 2009-07-31 11:48 ButtonExDemo\ButtonExDemo\obj\Debug\ButtonExDemo.pdb
文件 32768 2009-07-31 11:48 ButtonExDemo\ButtonExDemo\obj\Debug\ButtonExDemo.exe
文件 4476 2009-07-31 11:32 ButtonExDemo\ButtonExDemo\obj\Debug\ResolveAssemblyReference.cache
文件 1022 2009-07-31 11:48 ButtonExDemo\ButtonExDemo\obj\Debug\ButtonExDemo.csproj.GenerateResource.Cache
文件 351 2009-07-31 11:50 ButtonExDemo\ButtonExDemo\obj\ButtonExDemo.csproj.FileList.txt
文件 523 2009-07-31 11:34 ButtonExDemo\ButtonExDemo\Form1.cs
文件 471 2009-07-31 09:41 ButtonExDemo\ButtonExDemo\Program.cs
文件 8478 2009-07-31 10:55 ButtonExDemo\ButtonExDemo\Resources\10.ico
文件 8166 2009-07-31 10:55 ButtonExDemo\ButtonExDemo\Resources\11.ico
文件 7406 2009-07-31 10:55 ButtonExDemo\ButtonExDemo\Resources\12.ico
文件 9158 2009-07-31 10:55 ButtonExDemo\ButtonExDemo\Resources\14.ico
文件 9158 2009-07-31 10:55 ButtonExDemo\ButtonExDemo\Resources\15.ico
文件 1403 2009-07-31 09:43 ButtonExDemo\ButtonExDemo.sln
..A..H. 24576 2009-07-31 11:52 ButtonExDemo\ButtonExDemo.suo
............此处省略39个文件信息
- 上一篇:C# 编写的定时关机程序34646
- 下一篇:C# 相册管理系统
评论
共有 条评论