using System;
using System.Drawing;
using System.Windows.Forms;

namespace UAS_MES_NEW.CustomControl.TextBoxWithIcon
{
    public partial class EnterTextBox : TextBox
    {
        //传值的备用字符串
        private string ID1;
        private string Power1;
        private string str;
        private string str1;
        private string str2;
        /// <summary>
        /// 设置锁定字段
        /// </summary>
        string AllPower1;

        public override string Text
        {
            get
            {
                return base.Text.Trim();
            }

            set
            {
                base.Text = value;
            }
        }

        public string AllPower
        {
            get { return AllPower1; }
            set { AllPower1 = value; }
        }

        public string ID
        {
            get { return ID1; }
            set { ID1 = value; }
        }

        public string Str
        {
            get { return str; }
            set { str = value; }
        }

        public string Str1
        {
            get { return str1; }
            set { str1 = value; }
        }

        public string Str2
        {
            get { return str2; }
            set { str2 = value; }
        }

        public string Power
        {
            get { return Power1; }
            set { Power1 = value; }
        }

        public EnterTextBox()
        {
            InitializeComponent();
            this.KeyDown += EnterTextBox_KeyDown;
            BackColor = System.Drawing.Color.White;
        }

        private void EnterTextBox_Enter(object sender, EventArgs e)
        {
            this.BackColor = Color.GreenYellow;
        }

        private void EnterTextBox_Leave(object sender, EventArgs e)
        {
            this.BackColor = Color.White;
        }
        //手动添加全选功能

        private void EnterTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Modifiers.CompareTo(Keys.Control) == 0 && e.KeyCode == Keys.A)
                this.SelectAll();
        }

        private void EnterTextBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == System.Convert.ToChar(13))
            {
                e.Handled = true;
            }
        }
    }
}