Example #1
0
        private void buttonConnect_Click(object sender, EventArgs e)
        {
            try
            {
                client = new TcpClient(Dns.GetHostName(), 51888);
            }
            catch
            {
                MessageBox.Show("与服务器连接失败", "",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            textBoxLocal.Text     = client.Client.LocalEndPoint.ToString();
            textBoxServer.Text    = client.Client.RemoteEndPoint.ToString();
            buttonConnect.Enabled = false;
            //获取网络流
            NetworkStream netStream = client.GetStream();

            sr      = new StreamReader(netStream, System.Text.Encoding.UTF8);
            sw      = new StreamWriter(netStream, System.Text.Encoding.UTF8);
            service = new Service(listBox1, sw);
            //获取服务器各桌信息
            //格式:Login,昵称
            service.SendToServer("Login," + textBoxName.Text.Trim());
            Thread threadReceive = new Thread(new ThreadStart(ReceiveData));

            threadReceive.Start();
        }
Example #2
0
 private void buttonStart_Click(object sender, EventArgs e)
 {
     service.SendToServer(string.Format("Start,{0},{1}", tableIndex, side));
     this.buttonStart.Enabled = false;
     initGrid();
     RePaint();
 }
Example #3
0
        //CheckBox的Checked属性发生变化时触发
        private void checkBox_CheckedChanged(object sender, EventArgs e)
        {
            //是否为服务器更新本桌情况
            if (isReceiveCommand == true)
            {
                return;
            }
            CheckBox checkbox = (CheckBox)sender;

            //若Checked为true,表示玩家坐到第i桌第j位
            if (checkbox.Checked == true)
            {
                int i = int.Parse(checkbox.Name.Substring(5, 4));
                int j = int.Parse(checkbox.Name.Substring(9, 4));
                side = j;
                //格式:SitDown,昵称,桌号,座位号
                service.SendToServer(string.Format("SitDown,{0},{1}", i, j));
                formPlaying = new FormPlaying(i, j, sw);
                formPlaying.Show();
                formPlaying.RePaint();
            }
        }