private void timer1_Tick(object sender, EventArgs e) { PackData pack = new PackData("8"); pack.Start(); sendpack(pack.result, pbdata.ip, pbdata.port); DataAnalysics dataAnalysics = new DataAnalysics(); if (pbdata.roomPlayerNum[0] == 6 || pbdata.roomstate[0] == 1) { room1.Enabled = false; } /*if (pbdata.roomPlayerNum[1] == 6 || pbdata.roomstate[1] == 1) * pictureBox1.Enabled = false; * if (pbdata.roomPlayerNum[2] == 6 || pbdata.roomstate[2] == 1) * pictureBox1.Enabled = false; * if (pbdata.roomPlayerNum[3] == 6 || pbdata.roomstate[3] == 1) * pictureBox1.Enabled = false; * if (pbdata.roomPlayerNum[4] == 6 || pbdata.roomstate[4] == 1) * pictureBox1.Enabled = false; * if (pbdata.roomPlayerNum[5] == 6 || pbdata.roomstate[5] == 1) * pictureBox1.Enabled = false; * if (pbdata.roomPlayerNum[6] == 6 || pbdata.roomstate[6] == 1) * pictureBox1.Enabled = false; * if (pbdata.roomPlayerNum[7] == 6 || pbdata.roomstate[7] == 1) * pictureBox1.Enabled = false; * if (pbdata.roomPlayerNum[8] == 6 || pbdata.roomstate[8] == 1) * pictureBox1.Enabled = false;*/ //Application.DoEvents(); }
public void receive() { UdpClient udpclient = new UdpClient(port); Analyzer = new DataAnalysics(); if (pbdata.IsClose == true) { pbdata.IsClose = false; udpclient.Close(); } if (pbdata.ThreadRunning == false) { System.Diagnostics.Process.GetCurrentProcess().Kill(); } while (pbdata.ThreadRunning /*&&num == verify*/) { IPEndPoint iPEndPoint = null; byte[] bytes = udpclient.Receive(ref iPEndPoint); string data = Encoding.UTF8.GetString(bytes, 0, bytes.Length); Analyzer.AddData(data); Analyzer.Analysics(); //num++; // Isverify = false; string name = Analyzer.AnalysicsName; string roomnumber = Analyzer.AnalysicsRoomnumber; string message = Analyzer.AnalysicsMessage; //Console.WriteLine("name:" + name); //Console.WriteLine("roomnumber:"+roomnumber); //Console.WriteLine("message:" + message); //string data = Encoding.UTF8.GetString(bytes, 0, bytes.Length);//解码接收到的字节流 //Console.WriteLine("{0:HH:mm:ss}->接收数据(from {1}:{2}):{3}", DateTime.Now, iPEndPoint.Address, iPEndPoint.Port, data); } }
static void Main() { DataAnalysics dataAnalysics = new DataAnalysics(); pbdata.ClientMonitor = new Monitor(613); pbdata.MonitorThread = new Thread(new ThreadStart(pbdata.ClientMonitor.receive)); pbdata.MonitorThread.Start(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); login login = new login(); if (login.ShowDialog() == DialogResult.OK) { Application.Run(new allroom()); } }
private void timer1_Tick(object sender, EventArgs e) { DataAnalysics dataAnalysics = new DataAnalysics(); if (pbdata.playerName[0] == pbdata.Name) { startgame.Enabled = true; } roomuser1.Text = pbdata.playerName[0]; roomuser2.Text = pbdata.playerName[1]; roomuser3.Text = pbdata.playerName[2]; roomuser4.Text = pbdata.playerName[3]; roomuser5.Text = pbdata.playerName[4]; roomuser6.Text = pbdata.playerName[5]; scor1.Text = pbdata.playerScore[0]; scor2.Text = pbdata.playerScore[1]; scor3.Text = pbdata.playerScore[2]; scor4.Text = pbdata.playerScore[3]; scor5.Text = pbdata.playerScore[4]; scor6.Text = pbdata.playerScore[5]; //Application.DoEvents(); if (pbdata.gameFlag == true) { if (pbdata.gameName == pbdata.Name) { this.timer1.Stop(); pbImg.Enabled = true; startgame.Enabled = false; word.Text = pbdata.word; this.timer2.Start(); } else { this.timer1.Stop(); word.Text = "游戏开始"; this.timer4.Start(); } } }