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

namespace CarMeterSystem
{
    public partial class frmWelcome : Form
    {
        public frmWelcome()
        {
            InitializeComponent();
        }

        private void pictureBox1_DoubleClick(object sender, EventArgs e)
        {
            panel1.Visible = true;
            //this.Visible = false;
        }

        private void frmWelcome_Load(object sender, EventArgs e)
        {
            panel1.Visible = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Trim() == "88888888")
            {
                System.Environment.Exit(0);
            }
            else
            {
                textBox1.Text = "";
                textBox1.Focus();
                label2.Visible = true;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            label2.Visible = false;
            panel1.Visible = false;
        }

        #region 信息提示框
        public void setLogin() 
        {
            setLoginInfo(panel1,"1");
            setLoginInfo(textBox1, "2");
            setLoginInfo(label2, "3");
        }

        private void setLoginInfo(Control cn,string sType)
        {
            setLoginPl(cn, sType);
        }

        private void setLoginPl(Control control,string sType)
        {
            if (control.InvokeRequired)
            {
                Action<Control, string> action = new Action<Control, string>(setLoginInfo);
                Invoke(action, new object[] { control, sType });
            }
            else
            {
                //panel1.Visible = false;
                switch (sType) 
                {
                    case "1":
                        ((Panel)control).Visible = false;
                        ; break;
                    case "2":
                        ((TextBox)control).Text = "";
                        ; break;
                    case "3":
                        ((Label)control).Visible = false;
                        ; break;
                }
            }
        }
        #endregion
    }
}
