private void btnLink_Click(object sender, EventArgs e) { if (this.tbIp.Text.Trim().Length == 0 || this.tbIp.Text.Trim().Length == 0) { MessageBox.Show("IP and Port is required!"); return; } int port = 0; if (!int.TryParse(this.tbPort.Text.Trim(), out port)) { MessageBox.Show("Port must be number!"); return; } ServiceAgent.SetParas(this.tbIp.Text.Trim(), port); if (int.TryParse(this.tbFilePort.Text.Trim(), out port)) { FileAgent.SetParas(this.tbIp.Text.Trim(), port); } GlobalStaticObj_Server.Instance.StationID = this.tbSendMsg.Text.Split('$')[0]; if (ServiceAgent.ServiceTest() || FileAgent.ServiceTest()) { if (this.startFlag) { this.startFlag = false; AutoTask.StartTest(this.dateTimePicker1.Value.Ticks); } else { AutoTask.Continue(); } this.btnLink.Text = "已连接"; this.btnLink.Enabled = false; this.btnClose.Enabled = true; } }