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