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

📄 moodphraselabel.cs

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

    [Obsolete("该控件目前无人使用!", false)]
    public class MoodPhraseLabel : WndlessMixedLabel
    {
        private string _flyingText = string.Empty;
        private string _hintText = string.Empty;
        private System.Windows.Forms.TextBox _tbPhrase;

        public event EventHandler TextBoxAccepted;

        private void HideTextBox()
        {
            this._flyingText = string.Empty;
            Control ownerControl = base.OwnerControl;
            if (ownerControl != null)
            {
                ownerControl.Controls.Remove(this._tbPhrase);
            }
            base.DoAutoSize(true);
        }

        protected override void OnBoundsChanged(EventArgs e)
        {
            base.OnBoundsChanged(e);
            System.Windows.Forms.TextBox tb = this.TextBox;
            if (tb.Visible)
            {
                this.ReplaceTextBox(tb);
            }
        }

        protected override void OnDropDownIconClick(EventArgs e)
        {
            if (this._tbPhrase != null)
            {
                this.HideTextBox();
            }
            base.OnDropDownIconClick(e);
        }

        protected override void OnLabelClick(EventArgs e)
        {
            Control ownerControl = base.OwnerControl;
            if (ownerControl != null)
            {
                System.Windows.Forms.TextBox tb = this.TextBox;
                tb.Font = base.Font;
                this.ReplaceTextBox(tb);
                tb.Text = base.Text;
                tb.SelectAll();
                tb.Visible = true;
                ownerControl.Controls.Add(tb);
                tb.Focus();
            }
        }

        private void OnTextBoxAccepted(EventArgs e)
        {
            EventHandler textBoxAccepted = this.TextBoxAccepted;
            if (textBoxAccepted != null)
            {
                textBoxAccepted(this, e);
            }
        }

        private void ReplaceTextBox(System.Windows.Forms.TextBox tb)
        {
            Rectangle bounds = base.Bounds;
            bounds.Width -= base.ButtonRectangle.Width;
            tb.SetBounds(bounds.Left, bounds.Top, bounds.Width, base.Height, BoundsSpecified.All);
        }

        public string HintText
        {
            get
            {
                return this._hintText;
            }
            set
            {
                this._hintText = value ?? string.Empty;
            }
        }

        public override Size PreferredClientSize
        {
            get
            {
                if (this._flyingText.Length <= 0)
                {
                    return base.PreferredClientSize;
                }
                Size size = TextRenderer.MeasureText(this.Text, base.Font);
                Size size2 = TextRenderer.MeasureText(this._flyingText, base.Font);
                if (size.Width < size2.Width)
                {
                    size.Width = size2.Width;
                }
                if (size.Height < size2.Height)
                {
                    size.Height = size2.Height;
                }
                Rectangle buttonRectangle = base.ButtonRectangle;
                size.Width += buttonRectangle.Width;
                if (size.Height < buttonRectangle.Height)
                {
                    size.Height = buttonRectangle.Height;
                }
                return size;
            }
        }

        public override string Text
        {
            get
            {
                if (base.Text.Length > 0)
                {
                    return base.Text;
                }
                return this._hintText;
            }
            set
            {
                base.Text = value;
            }
        }

        public System.Windows.Forms.TextBox TextBox
        {
            get
            {
                KeyEventHandler handler = null;
                EventHandler handler2 = null;
                EventHandler handler3 = null;
                if (this._tbPhrase == null)
                {
                    this._tbPhrase = new System.Windows.Forms.TextBox();
                    this._tbPhrase.BorderStyle = BorderStyle.FixedSingle;
                    if (handler == null)
                    {
                        handler = delegate (object sender, KeyEventArgs e) {
                            if (e.KeyCode == Keys.Return)
                            {
                                this.HideTextBox();
                                this.OnTextBoxAccepted(EventArgs.Empty);
                            }
                            else if (e.KeyCode == Keys.Escape)
                            {
                                this.HideTextBox();
                            }
                        };
                    }
                    this._tbPhrase.KeyDown += handler;
                    if (handler2 == null)
                    {
                        handler2 = delegate {
                            this.HideTextBox();
                        };
                    }
                    this._tbPhrase.LostFocus += handler2;
                    if (handler3 == null)
                    {
                        handler3 = delegate {
                            this._flyingText = this._tbPhrase.Text;
                            base.DoAutoSize(true);
                        };
                    }
                    this._tbPhrase.TextChanged += handler3;
                }
                return this._tbPhrase;
            }
        }
    }
}

⌨️ 快捷键说明

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