private void toolStripMenuItem_AsMaster_Click(object sender, EventArgs e) { try { panel_master.Controls.Clear(); IPModule ipmodule = new IPModule(); if (dataGridView_IPSearch[0, _row].Value == null) { MessageBox.Show("IP輸入不允許為空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!myFunc.checkIPStringIsLegal(dataGridView_IPSearch[0, _row].Value.ToString())) { MessageBox.Show("IP輸入不合法!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ipmodule._IPAddr = m_MasterIPInfo._IP = dataGridView_IPSearch[0, _row].Value.ToString(); if (dataGridView_IPSearch[1, _row].Value != null) { m_MasterIPInfo._MAC = dataGridView_IPSearch[1, _row].Value.ToString(); } if (dataGridView_IPSearch[2, _row].Value == null) { MessageBox.Show("工作端口輸入不允許為空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ipmodule._Port = m_MasterIPInfo._WorkPort = Convert.ToInt32(dataGridView_IPSearch[2, _row].Value.ToString()); ipmodule.Parent = panel_master; } catch { } }
//設定IP private void SetIPAddr(string str) { bool result = true; Regex reg = new Regex(@"[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"); if (!myfunc.checkIPStringIsLegal(str)) { m_IPAddr_ScanEquip = "0.0.0.0"; } else { string[] _strList = str.Split('.'); for (int i = 0; i < 4; i++) { result &= checkInputIsValid(_strList[i]); result &= (Convert.ToInt32(_strList[i]) <= 255); } if (result) { m_IPAddr_ScanEquip = str; textBox_ip1.Text = _strList[0]; textBox_ip2.Text = _strList[1]; textBox_ip3.Text = _strList[2]; textBox_ip4.Text = _strList[3]; } else { m_IPAddr_ScanEquip = "0.0.0.0"; } } }