private void multiPlayButton_Click(object sender, EventArgs e) { Hide(); MultiPlayForm multiPlayForm = new MultiPlayForm(); multiPlayForm.FormClosed += new FormClosedEventHandler(childForm_Closed); multiPlayForm.Show(); }
private void multiPlayButton_Click(object sender, EventArgs e) { Hide(); // 현재 창 숨기기 MultiPlayForm multiPlayForm = new MultiPlayForm(); // 멀티플레이창 생성 multiPlayForm.FormClosed += new FormClosedEventHandler(childForm_Closed); // 멀티플레이창 소멸시 함수설정. multiPlayForm.Show(); // 멀티플레이창 보이기. }
private void button1_Click(object sender, EventArgs e) { string chanel = this.textBox1.Text; Hide(); MultiPlayForm multiPlayForm = new MultiPlayForm(chanel); multiPlayForm.FormClosed += new FormClosedEventHandler(childForm_Closed); multiPlayForm.Show(); }
private void multiPlayButton_Click(object sender, EventArgs e) { Hide(); MultiPlayForm multiPlayForm = new MultiPlayForm(); // 폼이 닫히면 이벤트 핸들러로 등록된 childForm_Closed를 실행시킴. 즉, 현재 Menu Form을 Show() 해줌. multiPlayForm.FormClosed += new FormClosedEventHandler(childForm_Closed); multiPlayForm.Show(); }
private void read() { while (true) { byte[] buf = new byte[1024]; int bufBytes = stream.Read(buf, 0, buf.Length); string message = Encoding.UTF8.GetString(buf, 0, bufBytes); if (message.Contains("[People]")) { string[] s = message.Split(']')[1].Split(','); peopleListView.Invoke((MethodInvoker) delegate() { peopleListView.Items.Clear(); foreach (var word in s) { ListViewItem item = new ListViewItem(word); peopleListView.Items.Add(item); } }); } else if (message.Contains("[Room]")) { string[] s = message.Split(']')[1].Split(';'); roomListView.Invoke((MethodInvoker) delegate() { roomListView.Items.Clear(); foreach (var item in s) { string[] temp = item.Split(','); ListViewItem lvitem = new ListViewItem(temp); roomListView.Items.Add(lvitem); } }); } else if (message.Contains("[Chat]")) { string s = message.Split(']')[1].Replace((char)0x02, ']'); for (int i = 0; i < s.Length; i++) { if (s[i] == ' ') { s = s.Insert(i, "] "); break; } } chatTextBox.Invoke((MethodInvoker) delegate() { chatTextBox.Text += ("[" + s + Environment.NewLine); chatTextBox.SelectionStart = chatTextBox.Text.Length; chatTextBox.ScrollToCaret(); }); } else if (message.Contains("[Create]")) { string s = message.Split(']')[1]; Room.currentRoomNum = int.Parse(s); BeginInvoke(new Action(() => { if (thread.IsAlive) { thread.Abort(); } if (timer != null) { timer.Stop(); } inviteButton.Visible = false; inviteTimePrg.Visible = false; Hide(); multiPlayForm = new MultiPlayForm(); multiPlayForm.FormClosed += new FormClosedEventHandler(childForm_Closed); multiPlayForm.Show(); })); } else if (message.Contains("[Join]")) { string[] s = message.Split(']')[1].Split(','); if (s[0] == "succ") { if (s[1] == "Player") { Status.player = true; } else if (s[1] == "Observer") { Status.player = false; } Room.currentRoomNum = int.Parse(s[2]); BeginInvoke(new Action(() => { if (thread.IsAlive) { thread.Abort(); } if (timer != null) { timer.Stop(); } inviteButton.Visible = false; inviteTimePrg.Visible = false; Hide(); multiPlayForm = new MultiPlayForm(); multiPlayForm.FormClosed += new FormClosedEventHandler(childForm_Closed); multiPlayForm.Show(); })); } else if (s[0] == "fail") { MessageBox.Show("접속실패"); } } else if (message.Contains("[Refresh]")) { string s = message.Split(']')[1]; string[] room = s.Split('/')[0].Split(';'); string[] people = s.Split('/')[1].Split(','); if (InvokeRequired == true) { roomListView.Invoke((MethodInvoker) delegate() { peopleListView.Invoke((MethodInvoker) delegate() { roomListView.Items.Clear(); peopleListView.Items.Clear(); if (!(room[0] == "empty")) { foreach (var item in room) { string[] temp = item.Split(','); ListViewItem lvitem = new ListViewItem(temp); roomListView.Items.Add(lvitem); } } foreach (var word in people) { ListViewItem item = new ListViewItem(word); peopleListView.Items.Add(item); } }); }); } else { roomListView.Items.Clear(); peopleListView.Items.Clear(); if (!(room[0] == "empty")) { foreach (var item in room) { string[] temp = item.Split(','); ListViewItem lvitem = new ListViewItem(temp); roomListView.Items.Add(lvitem); } } foreach (var word in people) { ListViewItem item = new ListViewItem(word); peopleListView.Items.Add(item); } } } else if (message.Contains("[Invite]")) { string s = message.Split(']')[1]; inviteRoomNum = int.Parse(s); inviteButton.Invoke((MethodInvoker) delegate() { inviteButton.Text = $"{s}번 방에서 초대가 왔습니다."; inviteButton.Visible = true; inviteTimePrg.Value = 10; inviteTimePrg.Visible = true; if (timer != null) { timer.Dispose(); } timer = new System.Windows.Forms.Timer(); timer.Interval = 1000; timer.Tick += new EventHandler(inviteTime); timer.Start(); }); } } }