Example #1
0
        private void treeView_Area_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            ClientClass CClass   = new ClientClass();
            string      TemNodeS = e.Node.Name;
            TreeNode    tNode    = new TreeNode();

            if (TemNodeS.IndexOf("Room_") >= 0)
            {
                tNode = e.Node;
                Publec_Class.TRoomM = Convert.ToInt32(tNode.Tag.ToString());
                TreeNode t2Node = new TreeNode();
                t2Node = (TreeNode)tNode.Parent;
                Publec_Class.TAreaM = Convert.ToInt32(t2Node.Tag.ToString());
                if (IAreaM == Publec_Class.TAreaM && IRoomM == Publec_Class.TRoomM)//如果进入的是同一个房间
                {
                    return;
                }

                if (Publec_Class.TAreaM > 0 && Publec_Class.TRoomM > 0)
                {
                    //listView_user.Items.Clear();
                    ClassMsg TeMsg = new ClassMsg();
                    TeMsg.sendKind   = SendKind.SendCommand;
                    TeMsg.msgCommand = MsgCommand.ExitToArea;
                    TeMsg.AreaMark   = IAreaM.ToString();
                    TeMsg.RoomMark   = IRoomM.ToString();
                    TeMsg.UserName   = Publec_Class.UserName;
                    udpSocket1.Send(IPAddress.Parse(Publec_Class.ServerIP), 11000, new ClassSerializers().SerializeBinary(TeMsg).ToArray());
                }

                if (pictureBox_Back.Visible == true)
                {
                    pictureBox_Back.Visible  = false;
                    flowPanel_Oppose.Visible = true;
                    //frmClient.BrushChar(panel_Public);
                }

                //设置要传递的信息
                ClassMsg msg = new ClassMsg();
                msg.AreaMark   = Publec_Class.TAreaM.ToString();
                msg.RoomMark   = Publec_Class.TRoomM.ToString();
                msg.RIP        = PubClass.MyHostIP();
                msg.RPort      = Publec_Class.ServerPort;
                msg.SIP        = Publec_Class.ServerIP;
                msg.SPort      = "11000";
                msg.sendKind   = SendKind.SendCommand;
                msg.msgCommand = MsgCommand.ComeToHall;
                msg.CPhoto     = Publec_Class.CaputID;
                //发送消息
                udpSocket1.Send(IPAddress.Parse(Publec_Class.ServerIP), 11000, new ClassSerializers().SerializeBinary(msg).ToArray());
                CClass.SetLabelModule(flowPanel_Oppose, imageList1);
                IAreaM = Publec_Class.TAreaM;
                IRoomM = Publec_Class.TRoomM;
            }
        }
Example #2
0
        private void treeView_Area_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            ClientClass CClass   = new ClientClass();                               //创建ClientClass对象
            string      TemNodeS = e.Node.Name;                                     //获取当前节点的名称
            TreeNode    tNode    = new TreeNode();                                  //定义一个节点

            if (TemNodeS.IndexOf("Room_") >= 0)                                     //查找节点名中是否有指定的字符串
            {
                tNode = e.Node;                                                     //获取当前节点中的所有信息
                Publec_Class.TRoomM = Convert.ToInt32(tNode.Tag.ToString());        //获取当前节点的房间号
                TreeNode t2Node = new TreeNode();                                   //定义一个节点
                t2Node = (TreeNode)tNode.Parent;                                    //获取当前节点的父节点信息
                Publec_Class.TAreaM = Convert.ToInt32(t2Node.Tag.ToString());       //获取当前房间所在区号
                if (IAreaM == Publec_Class.TAreaM && IRoomM == Publec_Class.TRoomM) //如果进入的是同一个房间
                {
                    return;
                }

                if (Publec_Class.TAreaM > 0 && Publec_Class.TRoomM > 0) //如果进入了房间
                {
                    ClassMsg TeMsg = new ClassMsg();                    //创建ClassMsg对象
                    TeMsg.sendKind   = SendKind.SendCommand;            //将命令设置为发送命令
                    TeMsg.msgCommand = MsgCommand.ExitToArea;           //消息设为ExitToArea
                    TeMsg.AreaMark   = IAreaM.ToString();               //记录当前的区号
                    TeMsg.RoomMark   = IRoomM.ToString();               //记录当前的房间号
                    TeMsg.UserName   = Publec_Class.UserName;           //记录当前用户的名称
                    //将信息发送给服务器端
                    udpSocket1.Send(IPAddress.Parse(Publec_Class.ServerIP), 11000, new ClassSerializers().SerializeBinary(TeMsg).ToArray());
                }

                if (pictureBox_Back.Visible == true)  //如果大厅中的页面图片为显示状态
                {
                    pictureBox_Back.Visible  = false; //隐藏该图片
                    flowPanel_Oppose.Visible = true;  //显示房间的所有座位
                }

                //设置要传递的信息
                ClassMsg msg = new ClassMsg();
                msg.AreaMark   = Publec_Class.TAreaM.ToString(); //记录区号
                msg.RoomMark   = Publec_Class.TRoomM.ToString(); //记录房间号
                msg.RIP        = PubClass.MyHostIP();            //记录当前用户的IP地址
                msg.RPort      = Publec_Class.ServerPort;        //记录当前用户的端口号
                msg.SIP        = Publec_Class.ServerIP;          //记录服务器端的IP地址
                msg.SPort      = "11000";                        //记录服务器端的端口号
                msg.sendKind   = SendKind.SendCommand;           //设置为发送命令
                msg.msgCommand = MsgCommand.ComeToHall;          //设置消息为进入大厅
                msg.CPhoto     = Publec_Class.CaputID;           //记录头像编号
                //发送消息
                udpSocket1.Send(IPAddress.Parse(Publec_Class.ServerIP), 11000, new ClassSerializers().SerializeBinary(msg).ToArray());
                CClass.SetLabelModule(flowPanel_Oppose, imageList1); //对组件进行批量操作
                //记录区号和房间号,用于判断进入的房间是否为同一区的同一个房间,如果是,则不进行操作
                IAreaM = Publec_Class.TAreaM;                        //记录区号
                IRoomM = Publec_Class.TRoomM;                        //记录房间号
            }
        }