Exemple #1
0
        private void 加入游戏ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            JoinForm joinForm = new JoinForm();

            joinForm.ShowDialog();
            if (Properties.Settings.Default.Host != "" && Properties.Settings.Default.Name != "")
            {
                this.client      = new Client();
                DConsole.client  = this.client;
                DConsole.player1 = this.player1;
                if (this.client.Connection())
                {
                    MessageBox.Show("连接成功", "消息");
                    client.Name = Properties.Settings.Default.Name;
                    this.lblClient1Name.Text = "server";
                    btnOK.Enabled            = true;
                    btnOK.Visible            = true; //启用"准备"按钮
                    ToolStripMenuItem tsmi = (ToolStripMenuItem)(this.menuStrip1.Items["游戏ToolStripMenuItem"]);
                    tsmi.DropDownItems["创建游戏ToolStripMenuItem"].Enabled  = false;
                    tsmi.DropDownItems["自定义分数ToolStripMenuItem"].Enabled = false;
                    tsmi.DropDownItems["加入游戏ToolStripMenuItem"].Enabled  = false; //禁用相关菜单
                }
                else
                {
                    MessageBox.Show("连接失败", "消息");
                }
            }
        }
 private void 加入游戏ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     JoinForm joinForm = new JoinForm();
     joinForm.ShowDialog();
     if (Properties.Settings.Default.Host != "" && Properties.Settings.Default.Name != "")
     {
         this.client = new Client();
         DConsole.client = this.client;
         DConsole.player1 = this.player1;
         if (this.client.Connection())
         {
             MessageBox.Show("连接成功", "消息");
             client.Name = Properties.Settings.Default.Name;
             this.lblClient1Name.Text = "server";
             btnOK.Enabled = true;
             btnOK.Visible = true;   //启用"准备"按钮
             ToolStripMenuItem tsmi = (ToolStripMenuItem)(this.menuStrip1.Items["游戏ToolStripMenuItem"]);
             tsmi.DropDownItems["创建游戏ToolStripMenuItem"].Enabled = false;
             tsmi.DropDownItems["自定义分数ToolStripMenuItem"].Enabled = false;
             tsmi.DropDownItems["加入游戏ToolStripMenuItem"].Enabled = false;  //禁用相关菜单
         }
         else
         {
             MessageBox.Show("连接失败", "消息");
         }
     }
 }