private void SetValidSN(INFO_LEVEL level)
        {
            if (this.pictureBox_SN.InvokeRequired)//如果调用控件的线程和创建创建控件的线程不是同一个则为True
            {
                while (!this.pictureBox_SN.IsHandleCreated)
                {
                    //解决窗体关闭时出现“访问已释放句柄“的异常
                    if (this.pictureBox_SN.Disposing || this.pictureBox_SN.IsDisposed)
                    {
                        return;
                    }
                }
                SetValidSNCallback d = new SetValidSNCallback(SetValidSN);
                this.pictureBox_SN.Invoke(d, new object[] { level });
            }
            else
            {
                switch (level)
                {
                case INFO_LEVEL.INIT:
                    this.pictureBox_SN.Visible = false;
                    break;

                case INFO_LEVEL.PASS:
                    this.pictureBox_SN.Visible = true;
                    this.pictureBox_SN.Image   = global::RK7001Test.Properties.Resources.OK;
                    break;

                case INFO_LEVEL.FAIL:
                    this.pictureBox_SN.Visible = true;
                    this.pictureBox_SN.Image   = global::RK7001Test.Properties.Resources.Shape;
                    break;

                case INFO_LEVEL.PROCESS:
                    this.pictureBox_SN.Visible = true;
                    this.pictureBox_SN.Image   = global::RK7001Test.Properties.Resources.ic_loading;
                    break;
                }
            }
        }
Exemple #2
0
        private void SetValidSN(INFO_LEVEL level)
        {
            if (this.lbItemValidSN.InvokeRequired)//如果调用控件的线程和创建创建控件的线程不是同一个则为True
            {
                while (!this.lbItemValidSN.IsHandleCreated)
                {
                    //解决窗体关闭时出现“访问已释放句柄“的异常
                    if (this.lbItemValidSN.Disposing || this.lbItemValidSN.IsDisposed)
                    {
                        return;
                    }
                }
                SetValidSNCallback d = new SetValidSNCallback(SetValidSN);
                this.lbItemValidSN.Invoke(d, new object[] { level });
            }
            else
            {
                switch (level)
                {
                case INFO_LEVEL.INIT:
                    this.lbItemValidSN.BackColor = Color.White;
                    break;

                case INFO_LEVEL.PASS:
                    this.lbItemValidSN.BackColor = Color.Green;
                    break;

                case INFO_LEVEL.FAIL:
                    this.lbItemValidSN.BackColor = Color.Red;
                    break;

                case INFO_LEVEL.PROCESS:
                    this.lbItemValidSN.BackColor = Color.Yellow;
                    break;
                }
            }
        }