using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace YG.Device
{
    public class LableLib
    {
        private static LableLib lableHandle = new LableLib();
        public static LableLib Instance { get { return lableHandle; } }
        /// 
        /// 
        /// 
        /// 
        /// 保持绿灯多少毫秒,-1是长亮
        public void LableColorChange(System.Windows.Forms.Label lb, int sleeptime)
        {
            lb.BeginInvoke(new Action(() =>
            {
                lb.AutoSize = false;
                lb.Text = "";
                lb.Size = new Size(23, 23);
                lb.BackColor = Color.Green;
               
                Task.Factory.StartNew(() =>
                {
                    if (sleeptime > 0)
                    {
                        System.Threading.Thread.Sleep(sleeptime);
                        lb.BackColor = Color.Red;
                    }
                });
            }));
        }
    }
}