private void checkBox_CheckedChanged(object sender, EventArgs e) { if (isReceiveCommand == true) { return; } CheckBox checkbox = (CheckBox)sender; if (checkbox.Checked == true) { int i = int.Parse(checkbox.Name.Substring(5, 4)); int j = int.Parse(checkbox.Name.Substring(9, 4)); side = j; service.SendToServer(string.Format("SitDown,{0},{1}", i, j)); formPlaying = new FormPlaying(i, j, sw); formPlaying.Show(); } }
/// <summary>每个CheckBox的Checked属性发生变化都会触发此事件</summary> 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(); } }