/// <summary> /// 获取未读信息 /// </summary> private void GetNoReadMsg() { string sql = string.Format("SELECT * FROM [dbo].[{0}] where receiveId='{1}' and isRead=0 ", DBTUtils.DBT_NoReadMsg, SingleUtils.LOGINER.userId); DBHelper.Excute(string.Format("update [dbo].[{0}] set isRead=1 where receiveId='{1}' and isRead=0 ", DBTUtils.DBT_NoReadMsg, SingleUtils.LOGINER.userId)); List <NoReadMsg> list = DBHelper.ConvertToModel <NoReadMsg>(sql); if (list.Count > 0) { SoundUtils.NewestInfoCome(); SingleUtils.isQQTD = true; } foreach (NoReadMsg msg in list) { GGUserInfo fromUser = ChatDBUtils.GetPerInfoByUserId(msg.sendId); MessageInfo fromInfo = new MessageInfo(); fromInfo.fromId = msg.sendId; fromInfo.toId = msg.receiveId; fromInfo.content = msg.content; fromInfo.msgType = msg.msgType; fromInfo.dateTime = msg.datetime; fromInfo.fromNoRead = 1; SingleUtils.noReadDic.Add(fromUser, fromInfo); //添加聊天记录 ChatDBUtils.AddRecords(fromInfo); } }
private void button12_Click(object sender, EventArgs e) { int index = cmbUserList.SelectedIndex; if (index < 0) { MessageBox.Show("请选择用户"); return; } string path = textBox2.Text; string extendName = Path.GetExtension(path); FileType fileType = GetFileExtendName(extendName); using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read)) { foreach (GGUserInfo item in user_list) { byte[] buffer = new byte[1024 * 1024 * 5]; int fileLength = fs.Read(buffer, 0, buffer.Length); GGUserInfo GGUserInfo = user_list[index]; if (item.userNickName == GGUserInfo.userNickName) { AppendMsgToServerChatList("系统给" + GGUserInfo.userNickName + "发送了文件"); Tools.ServerSendMsgToClient(GGUserInfo.UserSocket, Convert.ToByte(MsgType.私发文件), "", Convert.ToByte(fileType), buffer, fileLength); break; } } } }
private void button2_Click(object sender, EventArgs e) { try { string userId = NickUtils.GetUserId(); string nick = this.nick.Text; string pwd = this.pwd.Text; string relPwd = this.relPwd.Text; string qqSign = this.qqSign.Text; string name = userId; string extend = Path.GetExtension(fullFileName); GGUserInfo user = new GGUserInfo() { createTime = DateTime.Now, qqSign = qqSign, userId = userId, userImg = (headImg == null ? "" : name + extend), userNickName = nick, userPwd = pwd }; if (ChatDBUtils.RegisterUser(user)) { HeadImgUtils.SaveRegisterUserHeadImg(this.headImg, user); MessageBox.Show(GGUserUtils.ShowNickAndId(user) + "注册成功"); } else { MessageBox.Show(GGUserUtils.ShowNickAndId(user) + "注册失败"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button10_Click(object sender, EventArgs e) { string name = cmbUserList.Text; try { foreach (GGUserInfo item in MainForm.user_list) { int index = cmbUserList.SelectedIndex; if (index < 0) { MessageBox.Show("请选择用户"); return; } GGUserInfo GGUserInfo = MainForm.user_list[index]; if (item.userNickName == GGUserInfo.userNickName) { string msg = serverMsgContent.Rtf; if (msg == "") { return; } AppendMsgToServerChatList("系统给" + GGUserInfo.userNickName + "发送了消息|" + msg); Tools.ServerSendMsgToClient(GGUserInfo.UserSocket, Convert.ToByte(MsgType.普通信息), "系统|" + msg); break; } } } catch (Exception) { MessageBox.Show(name + "已下线"); RefreshOnLineUser(); } }
/// <summary> /// 服务端将字节发送信息给好友客户端 /// </summary> /// <param name="onLineUser"></param> /// <param name="messageInfo"></param> public static void SendToOnlineFriendClients(Dictionary <string, GGUserInfo> onLineUser, List <GGUserInfo> friendList, MessageInfo messageInfo) { try { List <GGUserInfo> onlineList = onLineUser.Values.ToList <GGUserInfo>(); List <GGUserInfo> clientList = new List <GGUserInfo>(); foreach (GGUserInfo item in onlineList) { GGUserInfo tmpUser = friendList.Where(i => i.userId == item.userId).SingleOrDefault(); if (tmpUser != null) { clientList.Add(item); } } string info = SerializerUtil.ObjectToJson <MessageInfo>(messageInfo); byte[] bytes = Encoding.UTF8.GetBytes(info); foreach (GGUserInfo user in clientList) { user.socket.Send(bytes); } } catch (Exception ex) { MessageBox.Show("服务端将字节发送信息给客户端," + ex.Message); } }
/// <summary> /// 选择tab显示相关信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { int selectedIndex = tabControl1.SelectedIndex; //选择tab显示已经打开的聊天窗口 if (selectedIndex == 1) { this.chatFromList.Items.Clear(); foreach (string user in SingleUtils.chatForm.Keys) { ListViewItem item = new ListViewItem(user); this.chatFromList.Items.Add(item); } } else if (selectedIndex == 2) { this.noReadMsgList.Items.Clear(); foreach (KeyValuePair <GGUserInfo, MessageInfo> user in SingleUtils.noReadDic) { GGUserInfo tmpUser = user.Key; MessageInfo tmpMsg = user.Value; string msg = tmpUser.userNickName + ":[" + tmpMsg.msgType + "]" + tmpMsg.content; ListViewItem item = new ListViewItem(msg); this.noReadMsgList.Items.Add(item); } } }
/// <summary> /// 记住密码 /// </summary> /// <param name="filePath"></param> /// <param name="content"></param> public static void RemeberPwd(GGUserInfo loginUser) { //541789021 000 遗忘成事 4.png string content = string.Format("{0} {1} {2} {3}", loginUser.userId, loginUser.userPwd, loginUser.userNickName, loginUser.userImg); FileUtils.AppendTxt(ToolUtils.GetRemPwdFile(), content); }
private void button5_Click(object sender, EventArgs e) { string name = cmbUserList.Text; try { if (OnlineUserUtils.GetAllOnlineClients().Count > 0) { string userId = cmbUserList.SelectedText; GGUserInfo user = OnlineUserUtils.GetSingleOnlineClient(userId); toInfo.msgType = MsgType.踢出聊天室; toInfo.content = GGUserUtils.ShowNickAndId(user) + "被踢出聊天室"; //显示到服务器端 ChatUtils.AppendMsgToServerChatList(this.serverChatRecords, toInfo); //发送到客户端 SocketUtils.SendToMultiClients(OnlineUserUtils.GetAllOnlineClients(), toInfo); //客户端下线 OnlineUserUtils.RemoveOnlineClient(user.userId); //刷新客户端 this.RefreshOnLineUser(); } } catch (Exception ex) { toInfo.msgType = MsgType.异常报告; toInfo.content = "踢人下线时抛出异常:" + ex.Message; //显示到服务器端 ChatUtils.AppendMsgToServerChatList(this.serverChatRecords, toInfo); //刷新客户端 this.RefreshOnLineUser(); } }
public ChatForm(GGUserInfo fromUser, GGUserInfo toUser) { InitializeComponent();//选择好友私聊 Control.CheckForIllegalCrossThreadCalls = false; this.showMsgDelMethod = this.ShowMsgDelMethodImpl; SingleUtils.fromUser = fromUser; SingleUtils.toUser = toUser; toInfo.toId = toUser.userId; toInfo.toUser = SingleUtils.toUser; string chatFormKey = GGUserUtils.GetChatFormKey(SingleUtils.fromUser, SingleUtils.toUser); SingleUtils.AddChatForm(chatFormKey, this); this.Size = new System.Drawing.Size(400, 400); this.Tag = chatFormKey; this.Text = "你" + GGUserUtils.ShowNickAndId(SingleUtils.fromUser) + "正在和" + GGUserUtils.ShowNickAndId(SingleUtils.toUser) + "聊天 chatFormKey=" + chatFormKey; //表情选择面板 SingleUtils.emojiForm.VisibleChanged += new EventHandler(this.GetEmoji); SingleUtils.emojiForm.Show(); SingleUtils.emojiForm.WindowState = FormWindowState.Minimized; SingleUtils.emojiForm.Visible = false; }
/// <summary> /// 加载好友信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainForm_Load(object sender, EventArgs e) { notifyIcon1.Text = string.Format("QQ:{0}({1})\r\n声音:{2}\r\n消息提示:{3}\r\n会话消息:{4}", user.userNickName, user.userId, "未开启", "开启", "头像闪烁"); this.Location = frmLogin.Location; user = this.Tag as GGUserInfo; userImg.BackgroundImage = Image.FromFile(tools.substringFromLast(Application.StartupPath, @"\", 2, @"\Images\userImg\") + user.userImg); nickName.Text = user.userNickName; QQSign.Text = user.qqSign; //得到分组 string sql = string.Format("select groupName, members from GGGroup where createId='{0}'", user.userId); DataTable dt = DBHelper.Select(sql); friendsList.Items.Clear(); foreach (DataRow group in dt.Rows) { ChatListItem cItem = new ChatListItem(group["groupName"].ToString()); if (!string.IsNullOrEmpty(group["members"].ToString())) { sql = string.Format("select userId,userNickName,qqSign,userImg from GGUser where userAutoid in({0})", group["members"]); dt = DBHelper.Select(sql); foreach (DataRow friend in dt.Rows) { ChatListSubItem.UserStatus state = ChatListSubItem.UserStatus.DontDisturb; Image img = Image.FromFile(tools.substringFromLast(Application.StartupPath, @"\", 2, @"\Images\userImg\") + friend["userImg"]); ChatListSubItem csItem = new ChatListSubItem(friend["userId"].ToString(), "00", friend["userNickName"].ToString(), friend["qqSign"].ToString(), state, img); cItem.SubItems.Add(csItem); friendsList.Items.Add(cItem); } } } }
/// <summary> /// 双击notifyIcon显示聊天面板 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) { SingleUtils.isQQTD = false; try { Dictionary <GGUserInfo, MessageInfo> tmpNoReadDic = new Dictionary <GGUserInfo, MessageInfo>(SingleUtils.noReadDic); foreach (KeyValuePair <GGUserInfo, MessageInfo> item in tmpNoReadDic) { GGUserInfo fromUser = item.Key; MessageInfo fromInfo = item.Value; string chatFormKey = GGUserUtils.GetChatFormKey(fromUser, SingleUtils.LOGINER); ChatForm chatFrom = null; if (SingleUtils.chatForm.ContainsKey(chatFormKey)) { chatFrom = SingleUtils.chatForm[chatFormKey] as ChatForm; chatFrom.WindowState = FormWindowState.Normal; } else { chatFrom = new ChatForm(SingleUtils.LOGINER, fromUser); chatFrom.Show(); } chatFrom.showMsgDelMethod(fromInfo); } SingleUtils.noReadDic.Clear(); } catch (Exception ex) { SoundUtils.playSound("notifyIcon1_MouseDoubleClick [ 异常:" + ex.Message + " ]", EndPointEnum.PC端); //MessageBox.Show("notifyIcon1_MouseDoubleClick [ 异常:" + ex.Message + " ]"); } }
public void GetClientConnection() { try { while (true) { //接收客户端发来的身份信息 Socket clientSocket = serverSocket.Accept(); object obj = clientSocket.RemoteEndPoint; string nameAndPwd = Tools.GetString(clientSocket); string[] arr = nameAndPwd.Split('|'); string sql = string.Format("select*from GGUser where userId='{0}' and userPwd='{1}'", arr[0], arr[1]); DataTable dt = DBHelper.Select(sql); GGUserInfo user = new GGUserInfo(); if (dt.Rows.Count == 1) { foreach (DataRow item in dt.Rows) { user.createTime = Convert.ToDateTime(item["createTime"]); user.qqSign = item["qqSign"].ToString(); user.userAutoid = Convert.ToInt32(item["userAutoid"]); user.userImg = item["userImg"].ToString(); user.userNickName = item["userNickName"].ToString(); user.userId = item["userId"].ToString(); user.isOnLine = Convert.ToBoolean(item["isOnLine"]); } IPEndPoint clientIPEndPoint = new IPEndPoint(IPAddress.Parse(arr[2]), Convert.ToInt32(arr[3])); Socket tempClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); } else { } return; user_list.Add(user); //保存用户信息 RefreshOnLineUser(); //刷新用户 ServerDelegate temp = msg => { byte[] bytes = Encoding.UTF8.GetBytes(arr[0]); AppendMsgToServerChatList(msg + "进入了聊天室" + Environment.NewLine + clientSocket.RemoteEndPoint + "连接到服务器", null, false); }; serverChatRecords.Invoke(temp, arr[0]); ServerThread myThread = new ServerThread(user, serverChatRecords, cmbUserList, label6); foreach (GGUserInfo item in user_list) { if (item.userNickName != arr[0]) { Tools.ServerSendMsgToClient(item.UserSocket, Convert.ToByte(MsgType.刷新在线用户), "【" + arr[0] + "】进入了聊天室"); } } } } catch (Exception ex) { MessageBox.Show("服务端接受连接的客户端:" + ex.Message); } }
private void UserInfoForm_VisibleChanged(object sender, EventArgs e) { GGUserInfo user = this.Tag as GGUserInfo; userHeadImg.Image = HeadImgUtils.ShowHeadImg(user); userName.Text = user.userNickName; userQm.Text = user.qqSign; }
/// <summary> /// 登陆 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonLogin_Click(object sender, EventArgs e) { try { string userId = textBoxId.SkinTxt.Text.Trim(); string userPwd = textBoxPwd.SkinTxt.Text.Trim(); SingleUtils.address = IPAddress.Parse(ToolUtils.GetServerIP()); SingleUtils.port = ToolUtils.GetServerPort(); SingleUtils.serverIPEndPoint = new IPEndPoint(SingleUtils.address, SingleUtils.port); SingleUtils.serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); SingleUtils.serverSocket.Connect(SingleUtils.serverIPEndPoint); toInfo.fromId = userId; toInfo.fromPwd = userPwd; toInfo.socket = SingleUtils.serverSocket; toInfo.dateTime = DateTime.Now; //1. 将登陆信息发送给服务器 //2. 服务器接收登陆信息判断账户是否可用 //3. 客户端接收服务器发送的验证信息进行信息展示 //4. 成功登陆获取在线客户端信息 SocketUtils.SendToSingleClient(toInfo); string json = ToolUtils.GetString(SingleUtils.serverSocket); MessageInfo fromInfo = SerializerUtil.JsonToObject <MessageInfo>(json); if (fromInfo.msgType == MsgType.登陆成功) { GGUserInfo loginUser = SerializerUtil.JsonToObject <GGUserInfo>(fromInfo.content); loginUser.socket = SingleUtils.serverSocket; loginUser.canSpeak = true; loginUser.isOnLine = true; SingleUtils.LOGINER = loginUser; this.Hide(); new MainClientForm(this).Show(); //记住密码 if (checkBoxRememberPwd.Checked) { if (!remeberList.Contains(loginUser.userId)) { FileUtils.RemeberPwd(loginUser); } } } else if (fromInfo.msgType == MsgType.已登录) { MessageBox.Show(fromInfo.content); } else { MessageBox.Show(fromInfo.content); } } catch (Exception ex) { SoundUtils.playSound("登陆客户端[ " + this.GetType() + this.Name + " ]错误:" + ex.Message, EndPointEnum.PC端); } }
/// <summary> /// 创建分组 /// </summary> /// <param name="gGUserInfo"></param> /// <param name="groupName"></param> /// <returns></returns> public static bool CreateGroup(GGUserInfo gGUserInfo, string groupName, bool isDefault = false) { string sql = "INSERT INTO [dbo].[" + DBTUtils.DBT_GGGroup + "]([groupId],[groupName],[createId],[members],[createTime],[isDefault])VALUES(@@groupId, @@groupName, @@createId, @@members, @@createTime, @@isDefault )"; object[] valArr = { "group" + gGUserInfo.userId, groupName, gGUserInfo.userId, "", DateTime.Now, isDefault ? 1 : 0 }; int row = DBHelper.Excute(sql, valArr); return(row > 0 ? true : false); }
/// <summary> /// 检查是否存在默认分组,不存在则添加 /// </summary> /// <param name="fromInfo"></param> private static void CheckDefaultGroup(MessageInfo fromInfo) { GGUserInfo tmpUser = ChatDBUtils.GetPerInfoByUserId(fromInfo.fromId); GGGroup defaultGroup = ChatDBUtils.GetDefaultGroup(tmpUser.userId); if (defaultGroup == null) { ChatDBUtils.CreateGroup(tmpUser, "我的好友", true); } }
/// <summary> /// 不显示当前所在分组 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void moveToGroup_MouseEnter(object sender, EventArgs e) { try { ListViewItem lvi = this.friendsList.SelectedItems[0] as ListViewItem; GGUserInfo user = lvi.Tag as GGUserInfo; List <GGGroup> groupList = SingleUtils.FriendsGroupList.Where(i => i.groupAutoId != user.groupAutoId).ToList(); this.InitMoveGroup(groupList); } catch (Exception ex) { } }
private void cmbUserList_SelectedIndexChanged(object sender, EventArgs e) { string index = cmbUserList.SelectedItem.ToString(); if (string.IsNullOrEmpty(index)) { return; } GGUserInfo GGUserInfo = OnlineUserUtils.GetSingleOnlineClient(index); button8.Enabled = !GGUserInfo.canSpeak; button9.Enabled = !button8.Enabled; }
private void button9_Click(object sender, EventArgs e) { string index = this.cmbUserList.SelectedText; GGUserInfo GGUserInfo = OnlineUserUtils.GetSingleOnlineClient(index); toInfo.msgType = MsgType.解除禁言; toInfo.content = GGUserInfo.userNickName + "可以发言了"; //显示到服务器端 ChatUtils.AppendMsgToServerChatList(this.serverChatRecords, toInfo); //发送给其他客户端 toInfo.content = "系统:你可以发言了"; SocketUtils.SendToSingleClient(toInfo); }
private void cmbUserList_SelectedIndexChanged(object sender, EventArgs e) { int index = cmbUserList.SelectedIndex; if (index < 0) { return; } GGUserInfo GGUserInfo = user_list[index]; button8.Enabled = !GGUserInfo.canSpeak; button9.Enabled = !button8.Enabled; }
public ServerThread(GGUserInfo userInfo, RtfRichTextBox serverChatRecords, ComboBox ComboBox, Label label) { this.currentUser = userInfo; this.serverChatRecords = serverChatRecords; this.ComboBox = ComboBox; this.label = label; this.userThread = new Thread(this.GetClientMsg) { IsBackground = true }; this.userThread.Start(); ChatDBUtils.onlineUserStr = OnlineUserUtils.GetOnlineUserStr(); }
private void button10_Click(object sender, EventArgs e) { string content = this.serverMsgContent.Text; string name = cmbUserList.Text; GGUserInfo toUser = OnlineUserUtils.GetSingleOnlineClient(name); toInfo.content = content; toInfo.toId = toUser.userId; toInfo.toUser = toUser; //显示到服务器端 ChatUtils.AppendMsgToServerChatList(this.serverChatRecords, toInfo); //发送给其他客户端 SocketUtils.SendToSingleClient(toInfo); }
private void RefreshCanSpeak() { string index = cmbUserList.SelectedItem.ToString(); if (string.IsNullOrEmpty(index)) { return; } GGUserInfo GGUserInfo = OnlineUserUtils.GetSingleOnlineClient(index); GGUserInfo.canSpeak = !GGUserInfo.canSpeak; button8.Enabled = !GGUserInfo.canSpeak; button9.Enabled = !button8.Enabled; }
private void RefreshCanSpeak() { int index = cmbUserList.SelectedIndex; if (index < 0) { return; } GGUserInfo GGUserInfo = user_list[index]; GGUserInfo.canSpeak = !GGUserInfo.canSpeak; button8.Enabled = !GGUserInfo.canSpeak; button9.Enabled = !button8.Enabled; }
/// <summary> /// 私聊 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void friendsList_DoubleClickSubItem(object sender, ChatListEventArgs e) { ChatListSubItem item = e.SelectSubItem; item.IsTwinkle = false; string name = item.DisplayName; GGUserInfo receiveUser = new GGUserInfo() { userNickName = name, iPEndPoint = new IPEndPoint(IPAddress.Parse("10.10.19.5"), new Random().Next(1000, 9999)) }; ChatForm f = new ChatForm(user, receiveUser, this); f.Show(); }
/// <summary> /// 加载记住密码的账户信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LoginForm_Load(object sender, EventArgs e) { string remPwdTxtPath = ToolUtils.GetRemPwdFile(); string[] remPwdArr = FileUtils.ReadRemeberInfo(remPwdTxtPath); GGUserInfo user = new GGUserInfo() { isOnLine = true, userImg = remPwdArr[0].Split(' ')[3].ToString() }; string user_userId = remPwdArr[0].Split(' ')[0].ToString(), user_userPwd = remPwdArr[0].Split(' ')[1].ToString(); Image user_userImg = HeadImgUtils.ShowHeadImg(user); for (int i = 0; i < remPwdArr.Length; i++) { string[] userItem = remPwdArr[i].Split(' '); string userId = userItem[0]; remeberList.Add(userId); string userPwd = userItem[1]; string userNickName = userItem[2]; string userImg = userItem[3]; user = new GGUserInfo() { userId = userId, userPwd = userPwd, userNickName = userNickName, userImg = userImg, isOnLine = true }; ToolStripMenuItem item = new ToolStripMenuItem(); item.AutoSize = false; item.Size = new System.Drawing.Size(182, 45); item.Text = userNickName + "\n" + userId; item.Tag = new string[] { userId, userPwd }; //Tag用于存储 userId 和 userPwd try { item.Image = HeadImgUtils.ShowHeadImg(user); } catch (Exception) { } item.Click += new EventHandler(toolStripMenuItemID_Click); menuStripId.Height += 45; menuStripId.Items.Add(item); } //显示第一项 textBoxId.SkinTxt.Text = user_userId; this.textBoxPwd.SkinTxt.Text = user_userPwd; panelHeadImage.BackgroundImage = user_userImg; this.checkBoxRememberPwd.Checked = true; }
public MainForm(Form frmLogin, GGUserInfo user) { InitializeComponent(); this.frmLogin = frmLogin; this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); Control.CheckForIllegalCrossThreadCalls = false; this.user = user; //this.Text = "欢迎您【" + user.userNickName + "】,连接到" + user.serverIP + "的" + user.point + "端口"; this.Text = user.serverIP + " " + user.serverPoint; user.UserSocket.Connect(user.iPEndPoint); user.UserSocket.Send(tools.StrToByte(user.userNickName)); getMsgThread = new Thread(GetServerMsg); getMsgThread.IsBackground = true; getMsgThread.Start(); }
private void 除好友ToolStripMenuItem1_Click(object sender, EventArgs e) { ListViewItem item = this.friendsList.SelectedItems[0]; GGUserInfo user = item.Tag as GGUserInfo; DialogResult dr = MessageBox.Show("确认删除" + GGUserUtils.ShowNickAndId(user) + "?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { toInfo.msgType = MsgType.除好友; toInfo.toId = user.userAutoid.ToString(); toInfo.toUser = user; toInfo.content = user.groupAutoId.ToString(); SocketUtils.SendToSingleClient(toInfo); } }
private void button9_Click(object sender, EventArgs e) { foreach (GGUserInfo item in MainForm.user_list) { int index = cmbUserList.SelectedIndex; GGUserInfo GGUserInfo = MainForm.user_list[index]; if (item.userNickName == GGUserInfo.userNickName) { if (!GGUserInfo.canSpeak) { AppendMsgToServerChatList(GGUserInfo.userNickName + "可以发言了"); } Tools.ServerSendMsgToClient(GGUserInfo.UserSocket, Convert.ToByte(MsgType.解除禁言), "系统:你可以发言了"); RefreshCanSpeak(); break; } } }
/// <summary> /// 设置头像 /// </summary> /// <param name="heaImg"></param> /// <param name="userImg"></param> /// <returns></returns> private static void SaveHeadImg(Image image, GGUserInfo user) { string name = user.userId; string extend = Path.GetExtension(user.userImg); string path = SingleUtils.userImgPath + name + "_" + (user.isOnLine ? HeadImgUtils.ONLINE : HeadImgUtils.OFFLINE) + extend; Image newHeadImg = null; if (user.isOnLine) { newHeadImg = image; } else { newHeadImg = ImageUtils.GetGrayImg(image); } newHeadImg = ImageUtils.GetReducedImage(newHeadImg, 50, 50);//压缩图片 newHeadImg.Save(path); }