• 大小: 6KB
    文件类型: .cs
    金币: 1
    下载: 0 次
    发布日期: 2021-06-04
  • 语言: C#
  • 标签: button  

资源简介

重写Buttion 实现鼠标移上去改变颜色 和鼠标移出来改变颜色

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;

namespace QLFUI
{
    [DefaultEvent(“Click“)]
    public partial class Button : UserControl
    {
        #region 变量

        //三种不同状态下的图片
        Image _normalImage = null;
        Image _moveImage = null;
        Image _downImage = null; 

        private string _value;
        private string _parentValue;
        private string _parentText;
        #endregion

        #region 属性
        [Description(“实际值“) Category(“QLFSkinDll“)]
        public string Value
        {
            get
            {
                return _value;

            }
            set
            {
                _value = value;
            }
        }
        [Description(“父级实际值“)Category(“QLFSkinDll“)]
        public string ParentValue
        {
            get
            {
                return _parentValue;

            }
            set
            {
                _parentValue = value;
            }
        }
        [Description(“父级显示值“)Category(“QLFSkinDll“)]
        public string ParentText
        {
            get
            {
                return _parentText;

            }
            set
            {
                _parentText = value;
            }
        }

        [Category(“QLFSkinDll“)]
        public Image NormalImage
        {
            get
            {
                return _normalImage;

            }
            set
            {
                _normalImage = value;
            }
        }

        [Category(“QLFSkinDll“)]
        public Image DownImage
        {
            get { return _downImage; }
            set
            {
                _downImage = value;
            }
        }

        [Category(“QLFSkinDll“)]
        public Image MoveImage
        {
            get { return _moveImage; }
            set
            {
                _moveImage = value;
            }
        }

        [Category(“QLFSkinDll“)]
        public string Caption
        {
            get { return this.label1.Text; }   //控件运行时会自动运行get方法得到值
            set
            {
                this.label1.Text = value;
            }
        }
        private Color _MoveColor = Color.FromArgb(255 255 255);//

        private Color _MoveOutColor = Color.FromArgb(93 93 93);//
        [Category(“QLFSkinDll“)]
        public Color MoveColor
        {
            get
            {
                return this._MoveColor;
            }
            set
            {
                this._MoveColor = value;
                this.Invalidate();
            }
        }
        [Category(“QLFSkinDll“)]
        public Color MoveOutColor
        {
            get
            {
                return this._MoveOutColor;
      

评论

共有 条评论