private void textBox1_KeyDown(object sender, KeyEventArgs e) { try { if (isServ == true && tserv.client.Connected == true) { if (e.KeyCode == Keys.Enter) { tserv.SendMsg(SendBox1.Text); ReceiveWindowBox.AppendText("송신 : " + GetTimer() + SendBox1.Text + "\n"); ReceiveWindowBox.SelectionStart = ReceiveWindowBox.Text.Length; ReceiveWindowBox.ScrollToCaret(); } } else if (isServ == false && tcla.client.Connected == true) { if (e.KeyCode == Keys.Enter) { tcla.SendMsg(SendBox1.Text); ReceiveWindowBox.AppendText("송신 : " + GetTimer() + SendBox1.Text + "\n"); ReceiveWindowBox.SelectionStart = ReceiveWindowBox.Text.Length; ReceiveWindowBox.ScrollToCaret(); } } } catch (Exception ex) { int lineNum = Convert.ToInt32(ex.StackTrace.Substring(ex.StackTrace.LastIndexOf(' '))); System.Windows.Forms.MessageBox.Show("기타에러 " + lineNum + "에서 발생" + ex.Message); } }
private void BattleGround_PlayMore(string SendBox) // Macro 보내기 전, 통신 방식 확인하고 보내기 위해서 >ㅁ< { int gridcount = PortListGrid.Rows.Count; // 현재 그리드뷰 리스트의 갯수 가져옴 for (int i = 0; i < gridcount; i++) //그리드뷰 리스트 처음부터 순회 { if (GridList[i].Type == "SERIAL" && GridList[i].TxCheckedState == true) // 그리드뷰리스트의 타입이 시리얼, 그리고 송신 체크박스 상태가 체크되어있다면 { serial[GridList[i].Typenum].SerialSend(SendBox); // serial [그리드뷰 객체에 저장된 시리얼 타입 객체의 순번] } if (GridList[i].Type == "TCP Client" && GridList[i].TxCheckedState == true && isServ == true && tserv.m_ClientList.Count > 0) // 서버 -> 클라이언트 { SendThread = new Thread(new ThreadStart(delegate() { this.Invoke(new Action(() => { tserv.SendMsg(SendBox); })); })); SendThread.Start(); } if (GridList[i].Type == "TCP Server" && GridList[i].TxCheckedState == true && isServ == false && tcla.client.Connected == true) // 클라이언트 -> 서버 { SendThread = new Thread(new ThreadStart(delegate() { this.Invoke(new Action(() => { tcla.SendMsg(SendBox); })); })); SendThread.Start(); } } this.Invoke(new Action(() => { ReceiveWindowBox.AppendText("송신 : " + GetTimer() + SendBox + "\n"); ReceiveWindowBox.SelectionStart = ReceiveWindowBox.Text.Length; ReceiveWindowBox.ScrollToCaret(); })); }