/// <summary> /// 发送红包 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripButton9_Click(object sender, EventArgs e) { this.redBtn.Enabled = false; RedOut redOut = new RedOut(); redOut.Show(); redOut.sendBtn.Click += (paramSender, paramE) => { RedOut tmpRedOut = (paramSender as Button).Parent.Parent as RedOut; double money = Double.Parse(redOut.money.Text.Trim()); toInfo.msgType = MsgType.私发红包; toInfo.content = money + ""; SocketUtils.SendToSingleClient(toInfo); toInfo.content = GGUserUtils.ShowNickAndId(SingleUtils.LOGINER) + "给" + GGUserUtils.ShowNickAndId(SingleUtils.toUser) + "发了一个" + money + "元的红包"; ChatRecordUtils.AppendMsgToClient(this.chatRecords, toInfo); tmpRedOut.Close(); this.redBtn.Enabled = true; }; redOut.button2.Click += (paramSender, paramE) => { this.redBtn.Enabled = true; }; int x = this.Left + (this.chatRecords.Width - redOut.Width) / 2; int y = this.Top + (this.chatRecords.Height) / 2; redOut.Location = new Point(x, y); }
/// <summary> /// 发起震动 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripButton8_Click(object sender, EventArgs e) { //发送至服务器 toInfo.msgType = MsgType.私发抖动; SocketUtils.SendToSingleClient(toInfo); toInfo.content = "你给" + GGUserUtils.ShowNickAndId(SingleUtils.toUser) + "发了一个抖动"; ChatRecordUtils.AppendMsgToClient(this.chatRecords, toInfo); }
/// <summary> /// 红包回调 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void pictureBox1_Click0(object sender, EventArgs e) { string str = string.Format("恭喜你,抢到了{0}元的红包", r.Next(1, 10) + Convert.ToDecimal(r.NextDouble().ToString().Substring(0, 4))); toInfo.content = str; toInfo.dateTime = DateTime.Now; ChatRecordUtils.AppendMsgToClient(this.chatRecords, toInfo); SingleUtils.redForm.Close(); this.redBtn.Enabled = true; }
/// <summary> /// 委托方法的实现 /// </summary> /// <param name="serverMsg"></param> public void ShowMsgDelMethodImpl(MessageInfo fromInfo) { if (fromInfo.msgType == MsgType.私聊) { if (fromInfo.fromId != SingleUtils.LOGINER.userId && fromInfo.fromNoRead != 1) { SoundUtils.NewestInfoCome(); } ChatRecordUtils.AppendMsgToClient(this.chatRecords, fromInfo); } if (fromInfo.msgType == MsgType.系统消息) { SoundUtils.SystemSound(); ChatRecordUtils.AppendMsgToClient(this.chatRecords, fromInfo); } else if (fromInfo.msgType == MsgType.私发红包) { Thread thread = new Thread((obj) => { MessageInfo tmpFromInfo = obj as MessageInfo; int money = Convert.ToInt32(tmpFromInfo.content); SingleUtils.redForm = new RedIn(); SingleUtils.redForm.pictureBox1.Click += (sender, e) => { string str = string.Format("收到{0}发来的{1}元的红包", GGUserUtils.ShowNickAndId(tmpFromInfo.fromUser), r.Next(1, 10)); toInfo.content = str; toInfo.dateTime = DateTime.Now; ChatRecordUtils.AppendMsgToClient(this.chatRecords, toInfo); SingleUtils.redForm.Close(); this.redBtn.Enabled = true; }; SingleUtils.redForm.Text = "金额=" + money; Application.Run(SingleUtils.redForm); }) { IsBackground = true }; thread.Start(fromInfo); } else if (fromInfo.msgType == MsgType.私发抖动) { ChatRecordUtils.AppendMsgToClient(this.chatRecords, fromInfo); WinUtils.WindowShake(this); } }
/// <summary> /// 发送回信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void skinButton_send_Click(object sender, EventArgs e) { if (!SingleUtils.LOGINER.canSpeak) { return; } string sendMsg = this.msgContent.Rtf; if (sendMsg.Length >= 10000000)//千万个字符 { MessageBox.Show("内容太多或内容太大无法发送"); return; } //发送至服务器 toInfo.content = sendMsg; toInfo.msgType = MsgType.私聊; SocketUtils.SendToSingleClient(toInfo); ChatRecordUtils.AppendMsgToClient(this.chatRecords, toInfo); }
private void searchBtn_Click(object sender, EventArgs e) { string start = this.start.Value.ToString("yyyy-MM-dd"); string end = this.end.Value.AddDays(1).ToString("yyyy-MM-dd"); string sql = string.Format(@"SELECT [recordAutoId] ,[sendId] ,[receiveId] ,[msgType] ,[content] ,[datetime] FROM [GGChatDB].[dbo].[Records] where [datetime] between '{0}' and '{1}' and ([sendId]='{2}' or [receiveId]='{2}') ", start, end, SingleUtils.LOGINER.userId); List <Records> recordsList = DBHelper.ConvertToExtModel <Records>(sql); foreach (Records item in recordsList) { MessageInfo toInfo = new MessageInfo() { content = item.content, dateTime = item.datetime, fromId = item.sendId, msgType = (MsgType)item.msgType, toId = item.receiveId }; ChatRecordUtils.AppendMsgToClient(this.list, toInfo); } this.Text = string.Format("找到{0}至{1}范围内{2}条记录", start, end, recordsList.Count); }