예제 #1
0
파일: FrmRooms.cs 프로젝트: usetool/MyQQ
 public static FrmRooms GetFrmRooms(string id)
 {
     if (frmRooms == null)
     {
         frmRooms = new FrmRooms(id);
     }
     return(frmRooms);
 }
예제 #2
0
 //登录按钮的点击事件
 private void pbLoginBtn_Click(object sender, EventArgs e)
 {
     if (CheckInput())
     {
         if (CheckUser())
         {
             FrmRooms rooms = FrmRooms.GetFrmRooms(txtUserName.Text.Trim());
             rooms.Show();
             this.Visible = false;
         }
         else
         {
             UCMessageBox.Show("账号或密码有误!", this);
         }
     }
 }
예제 #3
0
파일: UCTable.cs 프로젝트: usetool/MyQQ
        /// <summary>
        /// 获取玩家数据-头像和昵称,同时切换鼠标悬浮样式
        /// </summary>
        private void GetPlayerData(string uid, int seat)
        {
            DBHelper      dbHelper = new DBHelper();
            string        sql      = string.Format("select nickName,face from users where id={0}", uid);
            SqlDataReader reader   = null;

            try
            {
                dbHelper.Connection.Open();
                SqlCommand command = new SqlCommand(sql, dbHelper.Connection);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                if (reader.Read())
                {
                    string name = reader["nickName"].ToString();
                    string face = reader["face"].ToString();
                    switch (seat)
                    {
                    case 1:
                        lblPlay1Name.Text    = name;
                        lblPlay1Name.Visible = true;
                        //通过头像名字获取对应的资源
                        pbPlay1.Image = Properties.Resources.ResourceManager.GetObject(face) as Image;
                        //头像变圆
                        ControlUtils.ChangeToCircle(pbPlay1);
                        pbPlay1.Tag    = string.Format(pbPlay1.Tag.ToString(), uid);
                        pbPlay1.Cursor = Cursors.Hand;
                        break;

                    case 2:
                        lblPlay2Name.Text    = name;
                        lblPlay2Name.Visible = true;
                        pbPlay2.Image        = Properties.Resources.ResourceManager.GetObject(face) as Image;
                        ControlUtils.ChangeToCircle(pbPlay2);
                        pbPlay2.Tag    = string.Format(pbPlay2.Tag.ToString(), uid);
                        pbPlay2.Cursor = Cursors.Hand;
                        break;

                    case 3:
                        lblPlay3Name.Text    = name;
                        lblPlay3Name.Visible = true;
                        pbPlay3.Image        = Properties.Resources.ResourceManager.GetObject(face) as Image;
                        ControlUtils.ChangeToCircle(pbPlay3);
                        pbPlay3.Tag    = string.Format(pbPlay3.Tag.ToString(), uid);
                        pbPlay3.Cursor = Cursors.Hand;
                        break;

                    case 4:
                        lblPlay4Name.Text    = name;
                        lblPlay4Name.Visible = true;
                        pbPlay4.Image        = Properties.Resources.ResourceManager.GetObject(face) as Image;
                        ControlUtils.ChangeToCircle(pbPlay4);
                        pbPlay4.Tag    = string.Format(pbPlay4.Tag.ToString(), uid);
                        pbPlay4.Cursor = Cursors.Hand;
                        break;
                    }
                }
                else
                {
                    switch (seat)
                    {
                    case 1:
                        lblPlay1Name.Text    = "";
                        lblPlay1Name.Visible = false;
                        //通过头像名字获取对应的资源
                        pbPlay1.Image = Properties.Resources.ResourceManager.GetObject("Seat") as Image;
                        //头像变方
                        ControlUtils.ChangeToRect(pbPlay1);
                        pbPlay1.Tag = "1,{0}";
                        if (roomState == 1)
                        {
                            pbPlay1.Cursor = Cursors.No;
                        }
                        else
                        {
                            pbPlay1.Cursor = Cursors.Hand;
                        }
                        break;

                    case 2:
                        lblPlay2Name.Text    = "";
                        lblPlay2Name.Visible = false;
                        pbPlay2.Image        = Properties.Resources.ResourceManager.GetObject("Seat") as Image;
                        ControlUtils.ChangeToRect(pbPlay2);
                        pbPlay2.Tag = "2,{0}";
                        if (roomState == 1)
                        {
                            pbPlay2.Cursor = Cursors.No;
                        }
                        else
                        {
                            pbPlay2.Cursor = Cursors.Hand;
                        }
                        break;

                    case 3:
                        lblPlay3Name.Text    = "";
                        lblPlay3Name.Visible = false;
                        pbPlay3.Image        = Properties.Resources.ResourceManager.GetObject("Seat") as Image;
                        ControlUtils.ChangeToRect(pbPlay3);
                        pbPlay3.Tag = "3,{0}";
                        if (roomState == 1)
                        {
                            pbPlay3.Cursor = Cursors.No;
                        }
                        else
                        {
                            pbPlay3.Cursor = Cursors.Hand;
                        }
                        break;

                    case 4:
                        lblPlay4Name.Text    = "";
                        lblPlay4Name.Visible = false;
                        pbPlay4.Image        = Properties.Resources.ResourceManager.GetObject("Seat") as Image;
                        ControlUtils.ChangeToRect(pbPlay4);
                        pbPlay4.Tag = "4,{0}";
                        if (roomState == 1)
                        {
                            pbPlay4.Cursor = Cursors.No;
                        }
                        else
                        {
                            pbPlay4.Cursor = Cursors.Hand;
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                UCMessageBox.Show(ex.Message, FrmRooms.GetFrmRooms(id));
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
예제 #4
0
파일: UCTable.cs 프로젝트: usetool/MyQQ
        //获取房间数据
        private void GetRoomData()
        {
            //重置座位数据,用于标记
            pbPlay1.Tag = "1,{0}";
            pbPlay2.Tag = "2,{0}";
            pbPlay3.Tag = "3,{0}";
            pbPlay4.Tag = "4,{0}";
            string        sql      = string.Format(@"select Rooms.state as rstate,id,seat,
            RoomPlayer.state ustate
            from Rooms
            inner join RoomPlayer on Rooms.rid=RoomPlayer.rid
            where Rooms.rid={0}", roomId);
            DBHelper      dbHelper = new DBHelper();
            SqlDataReader reader   = null;

            try
            {
                dbHelper.Connection.Open();
                SqlCommand command = new SqlCommand(sql, dbHelper.Connection);
                reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                for (int i = 1; i <= 4; i++)
                {
                    if (reader.Read())
                    {
                        //将四个头像设置信息
                        roomState = Convert.ToInt32(reader["rstate"]);
                        int id     = Convert.ToInt32(reader["id"]);
                        int seat   = Convert.ToInt32(reader["seat"]);
                        int ustate = Convert.ToInt32(reader["ustate"]);
                        GetPlayerData(id.ToString(), seat);
                    }
                    //GetPlayerData(0.ToString(), tempNum);
                }
                //遍历所有座位,得到没有上座的座位
                for (int i = 1; i <= 4; i++)
                {
                    Control item = this.Controls.Find("pbPlay" + i, true)[0];
                    //座位信息
                    string[] info = item.Tag.ToString().Split(',');
                    if (info[1] == "{0}")
                    {
                        GetPlayerData(0.ToString(), Convert.ToInt32(info[0]));
                    }
                }

                //0为可用,1为已经开始游戏
                if (roomState == 0)
                {
                    pbRoomState.Image = Properties.Resources.tablen;
                }
                else if (roomState == 1)
                {
                    //更换图标
                    pbRoomState.Image = Properties.Resources.tables;
                }
            }
            catch (Exception ex)
            {
                UCMessageBox.Show(ex.Message, FrmRooms.GetFrmRooms(id));
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }