private void ServerIng() { while (run) { //服务接收处理 Socket QS; QS = qTcpListener.AcceptSocket(); Byte[] Stream = new Byte[1024]; QS.Receive(Stream); string save = System.Text.Encoding.UTF8.GetString(Stream); CheckOutDate(save); switch (parameter[0]) { case "1": //该用户上线 TrafficMsg.PostMessage(ShareDate.MainFormHand, 500, 1, 0); Login.SendMsgToGetOnlineInf(); //获取新的在线用户列表 System.Threading.Thread ShowOnline = new Thread(new ThreadStart(ShowInfWin)); ShowOnline.Start(); break; case "2": //接收到来自用户的消息;格式为(标识;源用户;消息内容) TrafficMsg.PostMessage(ShareDate.MainFormHand, 500, 2, 0); //发送播放声音提示消息 System.Threading.Thread SM = new Thread(new ThreadStart(ShowMsg)); SM.Start(); //创建聊天窗口 break; default: //发送错误参数 break; } QS.Close(); } }
private void notifyIcon1_DoubleClick(object sender, System.EventArgs e) { if (this.IconModel == 1) { this.Visible = true; } else { this.IconModel = 1; for (int i = 0; i < WinName.Count; i++) { string ShowName = UserInf.GetUserNameByUserNumber(this.WinName[i].ToString()) + "(" + this.WinName[i].ToString() + ")"; MsgSend temp = new MsgSend(ShowName, true); ShareDate.WinName.Add(this.WinName[i].ToString()); ShareDate.WinHand.Add(temp.Handle); temp.Show(); TrafficMsg.PostMessage(temp.Handle.ToInt32(), 500, int.Parse(this.MsgId[i].ToString()), 0); WinName.RemoveAt(i); MsgId.RemoveAt(i); } ResourceManager resources = new ResourceManager(typeof(main)); this.ShowIconModel(1); this.timer2.Stop(); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tFriend_DoubleClick( object sender, EventArgs e) { #region object tag = this.tFriend.SelectedNode.Tag; if (tag != null) { Friend currentfriend = getCurrentNodeFriend(tag.ToString()); Friend findfriend = FriendCollector.FindFriend(currentfriend); if (findfriend != null) { if (findfriend._MessageMode == MessageMode.HasPop) { TrafficMsg.PostMessage( int.Parse(findfriend._FrmHandle.ToString()), 501, 0, 0); } else { this.hasNoneFormAndInCache(findfriend); } } else { this.hasNoneFormAndNotCache(currentfriend); } } #endregion }
private void tFriend_DoubleClick(object sender, System.EventArgs e) { string ShowInf; bool online = false; bool IsHaveThisWin = false; int TempWinHand = 0; ShowInf = this.tFriend.SelectedNode.FullPath; if (ShowInf.IndexOf("\\", 0) != -1) { if (this.tFriend.SelectedNode.SelectedImageIndex == 0) { online = false; } else { online = true; } CheckOutNum check = new CheckOutNum(this.tFriend.SelectedNode.Text); for (int i = 0; i < ShareDate.WinName.Count; i++) { if (check.QQnumber.Trim() == ShareDate.WinName[i].ToString().Trim()) { TempWinHand = int.Parse(ShareDate.WinHand[i].ToString()); IsHaveThisWin = true; break; } } if (!IsHaveThisWin) { MsgSend msg = new MsgSend(this.tFriend.SelectedNode.Text, online); IntPtr hand = new IntPtr(); hand = msg.Handle; ShareDate.WinHand.Add(hand); ShareDate.WinName.Add(check.QQnumber); msg.Show(); } else { TrafficMsg.PostMessage(TempWinHand, 501, 0, 0); } } }
private void ShowMsg() { bool isHaveWin = false; int MsgId = 0; int hand = 0; string msg = ""; string FriendName = UserInf.GetUserNameByUserNumber(parameter[1].Trim()); if (FriendName.Trim() == "") { msg += parameter[1].Trim(); } else { msg += FriendName; } msg += ":(" + UserInf.GetTime() + ")\n " + parameter[2].Trim(); for (int i = 0; i < ShareDate.WinName.Count; i++) { if (parameter[1].Trim() == ShareDate.WinName[i].ToString().Trim()) { hand = int.Parse(ShareDate.WinHand[i].ToString()); isHaveWin = true; break; } } MsgId = ShareDate.Msg.Add(msg); if (isHaveWin) { TrafficMsg.PostMessage(hand, 500, MsgId, 0); //向目标窗口发送消息 } else { TrafficMsg.PostMessage(ShareDate.MainFormHand, 501, int.Parse(parameter[1]), MsgId); //闪烁图标 } }