void form_LastWordChanged(bool isGroup, string friendOrGroup, LastWordsRecord record) { IUnit unit = isGroup ? (IUnit)this.globalUserCache.GetGroup(friendOrGroup) : this.globalUserCache.GetUser(friendOrGroup); unit.Tag = record; this.recentListBox1.LastWordChanged(unit); }
//发送 private void btnSend_Click(object sender, EventArgs e) { if (this.globalUserCache.GetGroup(currentGroup.ID).NoSpeakList != null) { if (this.globalUserCache.GetGroup(currentGroup.ID).NoSpeakList.Contains(this.mine.UserID)) { this.AppendSysMessage("您已经被禁言!"); return; } } ChatBoxContent content = this.chatBoxSend.GetContent(); if (content.IsEmpty()) { return; } try { byte[] buff = CompactPropertySerializer.Default.Serialize(content); byte[] encrypted = buff; if (GlobalResourceManager.Des3Encryption != null) { encrypted = GlobalResourceManager.Des3Encryption.Encrypt(buff); } ++this.sendingCount; this.gifBox_wait.Visible = true; UIResultHandler handler = new UIResultHandler(this, this.HandleSentResult); this.rapidPassiveEngine.ContactsOutter.BroadcastBlob(this.currentGroup.GroupID, BroadcastTypes.BroadcastChat, encrypted, null, 2048, handler.Create(), null); this.AppendChatBoxContent(string.Format("{0}({1})", this.mine.Name, this.mine.UserID), null, content, Color.Green); ChatMessageRecord record = new ChatMessageRecord(this.mine.UserID, this.currentGroup.GroupID, buff, true, false); GlobalResourceManager.ChatMessageRecordPersister.InsertChatMessageRecord(record); //清空输入框 this.chatBoxSend.Text = string.Empty; this.chatBoxSend.Focus(); if (this.LastWordChanged != null) { LastWordsRecord lastWordsRecord = new LastWordsRecord(this.mine.ID, this.mine.Name, true, content); this.LastWordChanged(true, this.currentGroup.GroupID, lastWordsRecord); } } catch { this.AppendSysMessage("发送消息失败!"); } }
private void DoHandleReceivedMessage(string broadcasterID, int broadcastType, byte[] content, bool flash) { if (broadcastType == BroadcastTypes.BroadcastChat) { ChatBoxContent chatBoxContent = CompactPropertySerializer.Default.Deserialize <ChatBoxContent>(content, 0); GGUser user = this.globalUserCache.GetUser(broadcasterID); string talker = string.Format("{0}({1})", broadcasterID, broadcasterID); if (user != null) { talker = string.Format("{0}({1})", user.Name, user.UserID); } this.AppendChatBoxContent(talker, null, chatBoxContent, Color.Blue); this.FlashChatWindow(flash); if (this.LastWordChanged != null) { LastWordsRecord lastWordsRecord = new LastWordsRecord(broadcasterID, user == null ? broadcasterID : user.Name, false, chatBoxContent); this.LastWordChanged(true, this.currentGroup.GroupID, lastWordsRecord); } return; } else { string c = System.Text.Encoding.UTF8.GetString(content); //ChatBoxContent chatBoxContent = CompactPropertySerializer.Default.Deserialize<ChatBoxContent>(content, 0); ChatBoxContent chatBoxContent = new ChatBoxContent(); chatBoxContent.Text = c; GGUser user = this.globalUserCache.GetUser(broadcasterID); string talker = string.Format("{0}({1})", broadcasterID, broadcasterID); if (user != null) { talker = string.Format("{0}({1})", user.Name, user.UserID); } this.AppendChatBoxContent(talker, null, chatBoxContent, Color.Blue); this.FlashChatWindow(flash); if (this.LastWordChanged != null) { LastWordsRecord lastWordsRecord = new LastWordsRecord(broadcasterID, user == null ? broadcasterID : user.Name, false, chatBoxContent); this.LastWordChanged(true, this.currentGroup.GroupID, lastWordsRecord); } return; } }
public GroupChatForm(IRapidPassiveEngine engine, string groupID, GlobalUserCache cache, IChatSupporter supporter) { this.rapidPassiveEngine = engine; this.globalUserCache = cache; this.mine = this.globalUserCache.GetUser(this.rapidPassiveEngine.CurrentUserID); this.ggSupporter = supporter; this.currentGroup = this.globalUserCache.GetGroup(groupID); InitializeComponent(); this.chatBoxSend.Initialize(GlobalResourceManager.EmotionDictionary); this.chatBox_history.Initialize(GlobalResourceManager.EmotionDictionary); this.chatBoxSend.Font = SystemSettings.Singleton.Font; this.chatBoxSend.ForeColor = SystemSettings.Singleton.FontColor; this.Size = SystemSettings.Singleton.ChatFormSize; this.linkLabel_softName.Text = GlobalResourceManager.SoftwareName; this.toolShow.SetToolTip(this.panelFriendHeadImage, this.currentGroup.GroupID); this.Text = string.Format("{0}({1})", this.currentGroup.Name, this.currentGroup.GroupID); this.labelGroupName.Text = this.currentGroup.Name; this.label_announce.Text = this.currentGroup.Announce; this.chatBoxSend.Focus(); this.emotionForm = new EmotionForm(); this.emotionForm.Load += new EventHandler(emotionForm_Load); this.emotionForm.Initialize(GlobalResourceManager.EmotionList); this.emotionForm.EmotionClicked += new CbGeneric <int, Image>(emotionForm_Clicked); this.emotionForm.Visible = false; this.emotionForm.LostFocus += new EventHandler(emotionForm_LostFocus); foreach (string memberID in this.currentGroup.MemberList) { GGUser friend = this.globalUserCache.GetUser(memberID); this.AddUserItem(friend); } if (SystemSettings.Singleton.LoadLastWordsWhenChatFormOpened) { LastWordsRecord record = this.currentGroup.Tag as LastWordsRecord; if (record != null) { string talker = string.Format("{0}({1})", record.SpeakerName, record.SpeakerID); this.AppendChatBoxContent(talker, record.SpeakTime, record.ChatBoxContent, Color.Blue); } } }