• 大小: 205KB
    文件类型: .zip
    金币: 2
    下载: 2 次
    发布日期: 2021-11-16
  • 语言: C#
  • 标签: C#  

资源简介

支持各种C# 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 = 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-10-31 15:11  C# WinForm各种风格Button\
     目录           0  2018-10-31 15:11  C# WinForm各种风格Button\ButtonExDemo\
     目录           0  2009-07-31 09:42  C# WinForm各种风格Button\ButtonExDemo\ButtonEx\
     目录           0  2009-07-31 09:41  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\
     文件       45488  2009-07-31 11:50  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo.png
     文件        1404  2018-10-31 15:11  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo.sln
     文件       13824  2018-10-31 15:12  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo.suo
     目录           0  2009-07-31 09:41  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\bin\
     目录           0  2018-10-31 15:11  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\bin\Debug\
     文件       14848  2018-10-31 15:11  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\bin\Debug\ButtonEx.dll
     文件       36352  2018-10-31 15:11  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\bin\Debug\ButtonEx.pdb
     文件       22528  2018-10-31 15:11  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\bin\Debug\ButtonExDemo.exe
     文件       26112  2018-10-31 15:11  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\bin\Debug\ButtonExDemo.pdb
     文件       14328  2018-10-31 15:12  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\bin\Debug\ButtonExDemo.vshost.exe
     文件         490  2009-06-11 05:14  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\bin\Debug\ButtonExDemo.vshost.exe.manifest
     文件        4011  2018-10-31 15:11  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\ButtonExDemo.csproj
     文件         523  2009-07-31 11:34  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\Form1.cs
     文件       22079  2009-07-31 11:34  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\Form1.Designer.cs
     文件        5814  2009-07-31 11:34  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\Form1.resx
     目录           0  2009-07-31 09:41  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\obj\
     文件         351  2009-07-31 11:50  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\obj\ButtonExDemo.csproj.FileList.txt
     目录           0  2018-10-31 15:11  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\obj\Debug\
     文件        1391  2018-10-31 15:12  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\obj\Debug\ButtonExDemo.csproj.FileListAbsolute.txt
     文件         774  2018-10-31 15:11  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\obj\Debug\ButtonExDemo.csproj.GenerateResource.Cache
     文件       22528  2018-10-31 15:11  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\obj\Debug\ButtonExDemo.exe
     文件         180  2018-10-31 15:11  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\obj\Debug\ButtonExDemo.Form1.resources
     文件       26112  2018-10-31 15:11  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\obj\Debug\ButtonExDemo.pdb
     文件        8025  2018-10-31 15:11  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\obj\Debug\ButtonExDemo.Properties.Resources.resources
     文件        4562  2018-10-31 15:11  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\obj\Debug\ResolveAssemblyReference.cache
     目录           0  2018-10-31 15:11  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\obj\Debug\TempPE\
     文件        5120  2018-10-31 15:11  C# WinForm各种风格Button\ButtonExDemo\ButtonExDemo\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
............此处省略45个文件信息

评论

共有 条评论