private void Channel_Load(object sender, EventArgs e) { foreach (System.Windows.Forms.Control gb in this.Controls) { if (gb is System.Windows.Forms.GroupBox) { foreach (System.Windows.Forms.Control ctr in gb.Controls) { if (ctr is System.Windows.Forms.TextBox) { System.Windows.Forms.TextBox tb = (System.Windows.Forms.TextBox)ctr; tb.ReadOnly = true; } if (ctr is OnOffBtn) { OnOffBtn cb = (OnOffBtn)ctr; cb.Enabled = false; } if (ctr is System.Windows.Forms.ComboBox) { System.Windows.Forms.ComboBox comb = (System.Windows.Forms.ComboBox)ctr; comb.Enabled = false; } if (ctr is System.Windows.Forms.RadioButton) { System.Windows.Forms.RadioButton rb = (System.Windows.Forms.RadioButton)ctr; rb.Enabled = false; } if (ctr is System.Windows.Forms.Panel) { System.Windows.Forms.Panel pl = (System.Windows.Forms.Panel)ctr; foreach (System.Windows.Forms.RadioButton rdb in pl.Controls) { rdb.Enabled = false; } } } } } }
private void onOffButton4_Click(object sender, EventArgs e) { foreach (System.Windows.Forms.Control gb in this.Controls) { if (gb is System.Windows.Forms.GroupBox) { foreach (System.Windows.Forms.Control control in gb.Controls) { if (control is System.Windows.Forms.TextBox) { System.Windows.Forms.TextBox tb = (System.Windows.Forms.TextBox)control; tb.ReadOnly = !tb.ReadOnly; } if (control is UpperComputer.OnOffBtn) { OnOffBtn cb = (OnOffBtn)control; cb.Enabled = !cb.Enabled; } if (control is System.Windows.Forms.ComboBox) { System.Windows.Forms.ComboBox comb = (System.Windows.Forms.ComboBox)control; comb.Enabled = !comb.Enabled; } if (control is System.Windows.Forms.RadioButton) { System.Windows.Forms.RadioButton rb = (System.Windows.Forms.RadioButton)control; rb.Enabled = !rb.Enabled; } if (control is System.Windows.Forms.Panel) { System.Windows.Forms.Panel pl = (System.Windows.Forms.Panel)control; foreach (System.Windows.Forms.RadioButton rdb in pl.Controls) { rdb.Enabled = !rdb.Enabled; } } } } } }
public void BackCheck(OnOffBtn btn, byte[] sendbyte, string type) { bool ack = false; try { CheckHandle ch = new CheckHandle(this.Foo); IAsyncResult ar = ch.BeginInvoke(sendbyte, type, null, ch); ack = ch.EndInvoke(ar); } catch { ack = false; } finally { if (!ack) { btn.isCheck = !btn.isCheck; btn.Invalidate(); /*if (btn.Checked == true) * { * method.ctrChanged(, "1"); * } * if (btn.Checked == false) * { * method.ctrChanged(1, "0"); * }*/ //此处不恢复原来的控制,以便于在配置信号处的使用 MessageBox.Show("信号下发失败!"); //this.richTextBox3.Text = this.richTextBox3.Text + Environment.NewLine + //DateTime.Now.ToLocalTime().ToString() + " 信号下发失败"; } } }