⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wndlessboxbutton.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Client.Pc.BizControls
{
    using Imps.Client.Pc;
    using Imps.Client.Pc.Theme;
    using System;
    using System.Drawing;
    using System.Windows.Forms;

    public class WndlessBoxButton : XFormWndlessControl
    {
        private int _iImageHeight;
        private int _iImageWidth;
        private System.Windows.Forms.ImageList _imageList;
        private BoxButtonState _state;

        public WndlessBoxButton(Image image, int ColumnCount, int RowCount)
        {
            this.InitClass(image, ColumnCount, RowCount);
        }

        public WndlessBoxButton(string imageFileName, int ColumnCount, int RowCount)
        {
            Image image = Image.FromFile(imageFileName);
            this.InitClass(image, ColumnCount, RowCount);
        }

        private void _timer_OnTick(object sender, EventArgs e)
        {
        }

        public override void Dispose()
        {
            if (this._imageList != null)
            {
                this._imageList.Dispose();
                this._imageList = null;
            }
        }

        public void HideTooltip(System.Drawing.Point pt)
        {
            this.ShowToolTipText("", pt);
        }

        private void InitClass(Image image, int ColumnCount, int RowCount)
        {
            if (image != null)
            {
                this._imageList = ThemeManager.GetImageList((Image) image.Clone(), ColumnCount, RowCount, false);
                try
                {
                    this._iImageWidth = this._imageList.Images[0].Width;
                    this._iImageHeight = this._imageList.Images[0].Height;
                }
                catch
                {
                    this._iImageWidth = 9;
                    this._iImageHeight = 7;
                }
            }
        }

        public override bool OnMouseDown(MouseEventArgs e)
        {
            if (!base.Visible || base.NonClientArea)
            {
                return false;
            }
            this.State = BoxButtonState.Pressed;
            base.Invalidate();
            return true;
        }

        public override void OnMouseLeave(EventArgs e)
        {
            this.State = BoxButtonState.Normal;
            base.Invalidate();
        }

        public override bool OnMouseMove(MouseEventArgs e)
        {
            if (!base.Visible || base.NonClientArea)
            {
                return false;
            }
            this.State = BoxButtonState.Hover;
            base.Invalidate();
            return true;
        }

        public override bool OnNcMouseDown(Graphics g, System.Drawing.Point pt, MouseButtons button)
        {
            if (!base.Visible)
            {
                return false;
            }
            if (button == MouseButtons.Right)
            {
                return false;
            }
            Rectangle rect = new Rectangle(base.Left + ((base.Width - this._iImageWidth) / 2), base.Top + ((base.Height - this._iImageHeight) / 2), this._iImageWidth, this._iImageHeight);
            this.State = BoxButtonState.Pressed;
            DrawHelper.DrawImageList(g, this._imageList, (int) this._state, rect);
            return true;
        }

        public override void OnNcMouseLeave(EventArgs e)
        {
            this.State = BoxButtonState.Normal;
            base.Invalidate();
        }

        public override bool OnNcMouseMove(Graphics g, System.Drawing.Point pt)
        {
            if (!base.Visible || !base.NonClientArea)
            {
                return false;
            }
            Rectangle rect = new Rectangle(base.Left + ((base.Width - this._iImageWidth) / 2), base.Top + ((base.Height - this._iImageHeight) / 2), this._iImageWidth, this._iImageHeight);
            DrawHelper.DrawImageList(g, this._imageList, (int) this._state, rect);
            BoxButtonState state1 = this._state;
            return true;
        }

        public override bool OnNcMouseUp(Graphics g, System.Drawing.Point pt, MouseButtons button)
        {
            if (base.Visible)
            {
                if (button == MouseButtons.Right)
                {
                    return false;
                }
                if (this.State == BoxButtonState.Pressed)
                {
                    EventArgs e = new EventArgs();
                    base.RaiseClick(base._parent, e);
                    this._state = BoxButtonState.Normal;
                    return true;
                }
            }
            return false;
        }

        public override void OnNcPaint(Graphics g, Rectangle clipRectangle)
        {
            Rectangle rect = new Rectangle(base.Left + ((base.Width - this._iImageWidth) / 2), base.Top + ((base.Height - this._iImageHeight) / 2), this._iImageWidth, this._iImageHeight);
            if ((base.Visible && base.NonClientArea) && clipRectangle.IntersectsWith(base.Rectangle))
            {
                DrawHelper.DrawImageList(g, this._imageList, (int) this._state, rect);
            }
        }

        public override void OnPaint(Graphics g, Rectangle clipRectangle)
        {
            Rectangle rect = new Rectangle(base.Left + ((base.Width - this._iImageWidth) / 2), base.Top + ((base.Height - this._iImageHeight) / 2), this._iImageWidth, this._iImageHeight);
            if ((base.Visible && !base.NonClientArea) && clipRectangle.IntersectsWith(base.Rectangle))
            {
                DrawHelper.DrawImageList(g, this._imageList, (int) this._state, rect);
            }
        }

        private void showTipHandler(string sText, System.Drawing.Point pt)
        {
        }

        public void ShowTooltip(System.Drawing.Point pt)
        {
            this.ShowToolTipText(base.ToolTipText, pt);
        }

        private void ShowToolTipText(string tooltip, System.Drawing.Point pt)
        {
            if (tooltip.Equals(string.Empty))
            {
            }
        }

        public void UpdateImage(Image image, int ColumnCount, int RowCount)
        {
            this.InitClass(image, ColumnCount, RowCount);
        }

        public bool Hover
        {
            get
            {
                if (this._state != BoxButtonState.Hover)
                {
                    return false;
                }
                return true;
            }
        }

        public System.Windows.Forms.ImageList ImageList
        {
            get
            {
                return this._imageList;
            }
        }

        public bool Pressed
        {
            get
            {
                if (this._state != BoxButtonState.Pressed)
                {
                    return false;
                }
                return true;
            }
        }

        public BoxButtonState State
        {
            get
            {
                return this._state;
            }
            set
            {
                BoxButtonState state = this._state;
                this._state = value;
                if (this._state != state)
                {
                    base.Invalidate();
                }
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -