• 大小: 3.68MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-21
  • 语言: C#
  • 标签: C#  按钮  美化  

资源简介

C#用的漂亮按钮控件,直接拖出来就可以用,效果挺不错的

资源截图

代码片段和文件信息

using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace GlassButton
{
    #region//控件状态
    /// 
    /// 控件状态
    /// 

    public enum State
    {
        /// 
        /// 无
        /// 

        Normal = 0
        /// 
        /// 获得焦点
        /// 

        Focused = 1
        /// 
        /// 失去焦点
        /// 

        LostFocused = 2
        /// 
        /// 鼠标指针进入控件
        /// 

        MouseEnter = 3
    }
    #endregion

    public class GlassButton : Control
    {
        #region//私有变量
        private int bmp_Left;
        private const int bmp_Top = 5;
        private const int bmp_Size = 45;
        private bool _focused = false;
        private State state = State.Normal;

        private Bitmap _icon = Properties.Resources.icon;
        private string _text = null;
        #endregion

        #region//构造函数
        public GlassButton()
        {
            Setstyle(Controlstyles.AllPaintingInWmPaint |
                Controlstyles.DoubleBuffer |
                Controlstyles.OptimizedDoubleBuffer true);               //双缓冲防止重绘时闪烁
            Setstyle(Controlstyles.UserPaint true);                      //自定义绘制控件内容
            Setstyle(Controlstyles.SupportsTransparentBackColor true);   //模拟透明
            Setstyle(Controlstyles.Selectable true);                     //接收焦点
            Setstyle(Controlstyles.ResizeRedraw true);
            Size = new Size(73 81);                                      //初始大小
            Font = new Font(“微软雅黑“ 9);                               //控件字体
            BackColor = Color.Transparent;
        }
        #endregion

        #region//属性
        /// 
        /// 获取或设置控件显示的图片
        /// 

        [Description(“获取或设置控件显示的图标“)]
        public Bitmap Icon
        {
            get { return _icon; }
            set {
                _icon = value;
                Invalidate(false);
            }
        }

        /// 
        /// 重写控件焦点属性
        /// 

        [Description(“重写控件焦点属性“)]
        public new bool Focused
        {
            get { return _focused; }
            set
            {
                _focused = value;

                if (_focused)
                    state = State.Focused;
                else
                    state = State.LostFocused;

                Invalidate(false);
            }
        }

        /// 
        /// 与控件关联的文本
        /// 

        [Description(“与控件关联的文本。“)DefaultValue(null)]
        public new string Text
        {
            get {
                return _text;
            }
            set {
                _text = value;
                Invalidate(false);
            }
        }
        #endregion

        #region

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      37376  2012-09-26 10:59  GlassButton\GlassButton\bin\Release\GlassButton.dll

     文件       8236  2012-09-26 10:56  GlassButton\GlassButton\GlassButton.cs

     文件       3355  2012-09-26 10:53  GlassButton\GlassButton\GlassButton.csproj

     文件       5985  2012-09-26 10:58  GlassButton\GlassButton\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       3914  2012-09-26 10:58  GlassButton\GlassButton\obj\Debug\GenerateResource-ResGen.read.1.tlog

     文件        338  2012-09-26 10:58  GlassButton\GlassButton\obj\Debug\GenerateResource-ResGen.write.1.tlog

     文件       1591  2012-09-26 10:58  GlassButton\GlassButton\obj\Debug\GlassButton.csproj.FileListAbsolute.txt

     文件        866  2011-11-02 17:48  GlassButton\GlassButton\obj\Debug\GlassButton.csproj.GenerateResource.Cache

     文件      37888  2012-09-26 10:58  GlassButton\GlassButton\obj\Debug\GlassButton.dll

     文件      24064  2012-09-26 10:58  GlassButton\GlassButton\obj\Debug\GlassButton.pdb

     文件      28370  2012-09-26 10:58  GlassButton\GlassButton\obj\Debug\GlassButton.Properties.Resources.resources

     文件       5120  2012-09-26 10:39  GlassButton\GlassButton\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll

     文件       5983  2013-01-03 21:40  GlassButton\GlassButton\obj\Release\DesignTimeResolveAssemblyReferencesInput.cache

     文件       3914  2012-09-26 10:59  GlassButton\GlassButton\obj\Release\GenerateResource-ResGen.read.1.tlog

     文件        342  2012-09-26 10:59  GlassButton\GlassButton\obj\Release\GenerateResource-ResGen.write.1.tlog

     文件       2196  2012-09-26 10:59  GlassButton\GlassButton\obj\Release\GlassButton.csproj.FileListAbsolute.txt

     文件        866  2011-11-09 14:18  GlassButton\GlassButton\obj\Release\GlassButton.csproj.GenerateResource.Cache

     文件      37376  2012-09-26 10:59  GlassButton\GlassButton\obj\Release\GlassButton.dll

     文件      28370  2012-09-26 10:59  GlassButton\GlassButton\obj\Release\GlassButton.Properties.Resources.resources

     文件       5120  2012-09-26 10:38  GlassButton\GlassButton\obj\Release\TempPE\Properties.Resources.Designer.cs.dll

     文件       1354  2011-09-14 15:20  GlassButton\GlassButton\Properties\AssemblyInfo.cs

     文件       3603  2012-09-26 10:38  GlassButton\GlassButton\Properties\Resources.Designer.cs

     文件       6813  2012-09-26 10:38  GlassButton\GlassButton\Properties\Resources.resx

     文件       1096  2011-09-14 15:20  GlassButton\GlassButton\Properties\Settings.Designer.cs

     文件        249  2011-09-14 15:20  GlassButton\GlassButton\Properties\Settings.settings

     文件       3064  2011-09-15 21:24  GlassButton\GlassButton\Resources\down.png

     文件       3072  2011-09-15 21:24  GlassButton\GlassButton\Resources\enter.png

     文件      14657  2012-09-26 10:38  GlassButton\GlassButton\Resources\icon.png

     文件       1422  2012-09-26 10:13  GlassButton\GlassButton.sln

    ..A..H.     38400  2013-01-04 19:47  GlassButton\GlassButton.suo

............此处省略64个文件信息

评论

共有 条评论