Example #1
0
 private void 创建游戏ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     this.server = new Server();  //创建服务器
     DConsole.server = this.server;
     DConsole.player1 = this.player1;
     this.server.listener.Start();  //开始监听
     this.player2 = new Player();
     this.player3 = new Player();
     this.acceptConn = new Thread(new ThreadStart(this.server.Connection)); //新建一个线程用于接受请求连接
     this.acceptConn.IsBackground = true;
     this.acceptConn.Name = "检测客户端的连接并接受的线程";
     this.acceptConn.Start(); //开始线程
     DConsole.Write("[系统消息]:创建游戏成功,等待其他人链接");
     this.timerServer.Enabled = true;
     ToolStripMenuItem tsmi = (ToolStripMenuItem)(this.menuStrip1.Items["游戏ToolStripMenuItem"]);
     tsmi.DropDownItems["创建游戏ToolStripMenuItem"].Enabled = false;
     tsmi.DropDownItems["自定义分数ToolStripMenuItem"].Enabled = false;
     tsmi.DropDownItems["加入游戏ToolStripMenuItem"].Enabled = false;  //禁用相关菜单
 }