private void Init_Load() { //asc.controllInitializeSize(this); DataTable tables = AccessFunction.GetTables(); if (tables != null) { int count = tables.Rows.Count; for (int i = 0; i < count; i++) { string a = tables.Rows[i][1].ToString(); string item = tables.Rows[i][2].ToString(); //Console.WriteLine("count" + item); if (IsInts(item) && int.Parse(item) < 40) { //Console.WriteLine("return" + item); continue; } else { //Console.WriteLine(item); if (a == "video") { comboBox_video.Items.Add(item); } else if (a == "vga") { comboBox_vga.Items.Add(item); } else if (a == "dvi") { comboBox_dvi.Items.Add(item); } else if (a == "hdmi") { comboBox_hdmi.Items.Add(item); } } } } }
/// <summary> /// 添加HEX协议 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_AddHex_Click(object sender, EventArgs e) { bool flag = false; if (textBox_num.Text.Length > 0) { if (textBox_h1.Text == "" && textBox_h2.Text == "" && textBox_h3.Text == "" && textBox_h4.Text == "" && textBox_h5.Text == "" && textBox_h6.Text == "" && textBox_h7.Text == "" && textBox_h8.Text == "" && textBox_h9.Text == "") { { string ts = languageFile.ReadString("PROTOCOLFORM", "T4", "添加的协议不能为空,请重新设置!"); string tp = languageFile.ReadString("MESSAGEBOX", "TP", "提示"); MessageBox.Show(ts, tp); } return; } if (IsInts(textBox_num.Text) && int.Parse(textBox_num.Text) < 40) { { string ts = languageFile.ReadString("PROTOCOLFORM", "T5", "此协议编号已存在,请重新设置!"); string tp = languageFile.ReadString("MESSAGEBOX", "TP", "提示"); MessageBox.Show(ts, tp); } return; } if (comboBox_Mt.Text == "video") { for (int i = 0; i < f.comboBox_video.Items.Count; i++) { if (f.comboBox_video.Items[i].ToString() == textBox_num.Text) { flag = true; break; } } } if (comboBox_Mt.Text == "vga") { for (int i = 0; i < f.comboBox_vga.Items.Count; i++) { if (f.comboBox_vga.Items[i].ToString() == textBox_num.Text) { flag = true; break; } } } if (comboBox_Mt.Text == "dvi") { for (int i = 0; i < f.comboBox_dvi.Items.Count; i++) { if (f.comboBox_dvi.Items[i].ToString() == textBox_num.Text) { flag = true; break; } } } if (comboBox_Mt.Text == "hdmi") { for (int i = 0; i < f.comboBox_hdmi.Items.Count; i++) { if (f.comboBox_hdmi.Items[i].ToString() == textBox_num.Text) { flag = true; break; } } } if (!flag) { string[] array = new string[14]; array[0] = textBox_num.Text + "-" + comboBox_Mt.Text; array[1] = comboBox_Mt.Text; array[2] = textBox_num.Text; array[3] = textBox_h1.Text; if (array[3].Length % 2 != 0) { MessageBox.Show("输入错误,请重新输入!", "提示"); return; } array[4] = textBox_h2.Text; array[5] = textBox_h3.Text; array[6] = textBox_h4.Text; array[7] = textBox_h5.Text; array[8] = textBox_h6.Text; array[9] = textBox_h7.Text; array[10] = textBox_h8.Text; array[11] = textBox_h9.Text; array[12] = (radioButton4.Checked ? "2" : "1"); array[12] = array[12] + "0"; array[13] = "2"; AccessFunction.InsertClientProtocol(array); if (comboBox_Mt.Text == "video") { f.comboBox_video.Items.Add(textBox_num.Text); } if (comboBox_Mt.Text == "vga") { f.comboBox_vga.Items.Add(textBox_num.Text); } if (comboBox_Mt.Text == "hdmi") { f.comboBox_hdmi.Items.Add(textBox_num.Text); } if (comboBox_Mt.Text == "dvi") { f.comboBox_dvi.Items.Add(textBox_num.Text); } { string ts = languageFile.ReadString("PROTOCOLFORM", "T6", "添加协议完成!"); string tp = languageFile.ReadString("MESSAGEBOX", "TP", "提示"); MessageBox.Show(ts, tp); } LogHelper.WriteLog("======完成添加矩阵协议======"); } else { string ts = languageFile.ReadString("PROTOCOLFORM", "T7", "协议重复!"); string tp = languageFile.ReadString("MESSAGEBOX", "TP", "提示"); MessageBox.Show(ts, tp); } } }
/// <summary> /// 删除对应协议 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_Del_Click(object sender, EventArgs e) { if (textBox_num.Text.Length > 0) { if (IsInts(textBox_num.Text) && int.Parse(textBox_num.Text) < 40) { string ts = languageFile.ReadString("PROTOCOLFORM", "T1", "此协议禁止删除!"); string tp = languageFile.ReadString("MESSAGEBOX", "TP", "提示"); MessageBox.Show(ts, tp); return; } DataTable clientProtocol = AccessFunction.GetClientProtocol(textBox_num.Text + "-" + comboBox_Mt.Text); if (clientProtocol.Rows.Count != 0) { AccessFunction.DeleteClientProtocol(textBox_num.Text + "-" + comboBox_Mt.Text); if (comboBox_Mt.Text == "hdmi") { for (int i = 0; i < f.comboBox_hdmi.Items.Count; i++) { if (f.comboBox_hdmi.Items[i].ToString() == textBox_num.Text) { if (f.comboBox_hdmi.Text == textBox_num.Text) { f.comboBox_hdmi.SelectedIndex = 0; //settingFile.WriteInteger("Matrix", "HDMIMatrix", 0); } f.comboBox_hdmi.Items.Remove(textBox_num.Text); break; } } } else if (comboBox_Mt.Text == "dvi") { for (int i = 0; i < f.comboBox_dvi.Items.Count; i++) { if (f.comboBox_dvi.Items[i].ToString() == textBox_num.Text) { if (f.comboBox_dvi.Text == textBox_num.Text) { f.comboBox_dvi.SelectedIndex = 0; //settingFile.WriteInteger("Matrix", "DVIMatrix", 0); } f.comboBox_dvi.Items.Remove(textBox_num.Text); break; } } } else if (comboBox_Mt.Text == "vga") { for (int i = 0; i < f.comboBox_vga.Items.Count; i++) { if (f.comboBox_vga.Items[i].ToString() == textBox_num.Text) { if (f.comboBox_vga.Text == textBox_num.Text) { f.comboBox_vga.SelectedIndex = 0; //settingFile.WriteInteger("Matrix", "VGAMatrix", 0); } f.comboBox_vga.Items.Remove(textBox_num.Text); break; } } } else if (comboBox_Mt.Text == "video") { for (int i = 0; i < f.comboBox_video.Items.Count; i++) { if (f.comboBox_video.Items[i].ToString() == textBox_num.Text) { if (f.comboBox_video.Text == textBox_num.Text) { f.comboBox_video.SelectedIndex = 0; //settingFile.WriteInteger("Matrix", "VIDEOMatrix", 0); } f.comboBox_video.Items.Remove(textBox_num.Text); break; } } } { string ts = languageFile.ReadString("PROTOCOLFORM", "T2", "此协议已删除!"); string tp = languageFile.ReadString("MESSAGEBOX", "TP", "提示"); MessageBox.Show(textBox_num.Text + "-" + comboBox_Mt.Text + ts, tp); } } else { string ts = languageFile.ReadString("PROTOCOLFORM", "T3", "此协议不存在!"); string tp = languageFile.ReadString("MESSAGEBOX", "TP", "提示"); MessageBox.Show(ts, tp); } } }