private void TbMessageInput_EnterPressed(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbMessageInput.Text)) { return; } if (lbUserList.SelectedItem == null) { return; } string userName = lbUserList.SelectedItem.Text; connectionManager.SendCustomMessage(new QueuedMessage("PRIVMSG " + userName + " :" + tbMessageInput.Text, QueuedMessageType.CHAT_MESSAGE, 0)); PrivateMessageUser pmUser = privateMessageUsers.Find(u => u.IrcUser.Name == userName); if (pmUser == null) { IRCUser iu = connectionManager.UserList.Find(u => u.Name == userName); if (iu == null) { Logger.Log("Null IRCUser in private messaging?"); return; } pmUser = new PrivateMessageUser(iu); privateMessageUsers.Add(pmUser); } ChatMessage sentMessage = new ChatMessage(ProgramConstants.PLAYERNAME, personalMessageColor, DateTime.Now, tbMessageInput.Text); pmUser.Messages.Add(sentMessage); lbMessages.AddMessage(sentMessage); if (sndMessageSound != null) { sndMessageSound.Play(); } lastConversationPartner = userName; if (tabControl.SelectedTab != 0) { tabControl.SelectedTab = 0; lbUserList.SelectedIndex = lbUserList.Items.FindIndex(i => i.Text == userName); } tbMessageInput.Text = string.Empty; }
private void PrivateMessageHandler_PrivateMessageReceived(object sender, PrivateMessageEventArgs e) { PrivateMessageUser pmUser = privateMessageUsers.Find(u => u.IrcUser.Name == e.Sender); if (pmUser == null) { pmUser = new PrivateMessageUser(e.ircUser); privateMessageUsers.Add(pmUser); if (tabControl.SelectedTab == 0) { string selecterUserName = string.Empty; if (lbUserList.SelectedItem != null) { selecterUserName = lbUserList.SelectedItem.Text; } lbUserList.Clear(); privateMessageUsers.ForEach(pmsgUser => AddPlayerToList(pmsgUser.IrcUser, connectionManager.UserList.Find(u => u.Name == pmsgUser.IrcUser.Name) != null)); lbUserList.SelectedIndex = lbUserList.Items.FindIndex(i => i.Text == selecterUserName); } } ChatMessage message = new ChatMessage(e.Sender, otherUserMessageColor, DateTime.Now, e.Message); pmUser.Messages.Add(message); lastReceivedPMSender = e.Sender; lastConversationPartner = e.Sender; if (!Visible) { HandleNotification(pmUser.IrcUser, e.Message); if (lbUserList.SelectedItem == null || lbUserList.SelectedItem.Text != e.Sender) { return; } } else if (lbUserList.SelectedItem == null || lbUserList.SelectedItem.Text != e.Sender) { HandleNotification(pmUser.IrcUser, e.Message); return; } lbMessages.AddMessage(message); if (sndMessageSound != null) { sndMessageSound.Play(); } }
private void ConnectionManager_PrivateMessageReceived(object sender, PrivateMessageEventArgs e) { PrivateMessageUser pmUser = privateMessageUsers.Find(u => u.IrcUser.Name == e.Sender); IRCUser iu = connectionManager.UserList.Find(u => u.Name == e.Sender); // We don't accept PMs from people who we don't share any channels with if (iu == null) { return; } // Messages from users we've blocked are not wanted if (cncnetUserData.IsIgnored(iu.Ident)) { return; } if (pmUser == null) { pmUser = new PrivateMessageUser(iu); privateMessageUsers.Add(pmUser); if (tabControl.SelectedTab == 0) { string selecterUserName = string.Empty; if (lbUserList.SelectedItem != null) { selecterUserName = lbUserList.SelectedItem.Text; } lbUserList.Clear(); privateMessageUsers.ForEach(pmsgUser => AddPlayerToList(pmsgUser.IrcUser, connectionManager.UserList.Find(u => u.Name == pmsgUser.IrcUser.Name) != null)); lbUserList.SelectedIndex = lbUserList.Items.FindIndex(i => i.Text == selecterUserName); } } ChatMessage message = new ChatMessage(e.Sender, otherUserMessageColor, DateTime.Now, e.Message); pmUser.Messages.Add(message); lastReceivedPMSender = e.Sender; lastConversationPartner = e.Sender; if (!Visible) { HandleNotification(pmUser.IrcUser, e.Message); if (lbUserList.SelectedItem == null || lbUserList.SelectedItem.Text != e.Sender) { return; } } else if (lbUserList.SelectedItem == null || lbUserList.SelectedItem.Text != e.Sender) { HandleNotification(pmUser.IrcUser, e.Message); return; } lbMessages.AddMessage(message); if (sndMessageSound != null) { sndMessageSound.Play(); } }
private void PrivateMessageHandler_PrivateMessageReceived(object sender, PrivateMessageEventArgs e) { if (UserINISettings.Instance.AllowPrivateMessagesFromState == (int)AllowPrivateMessagesFromEnum.None) { return; } PrivateMessageUser pmUser = privateMessageUsers.Find(u => u.IrcUser.Name == e.Sender); if (pmUser == null) { pmUser = new PrivateMessageUser(e.ircUser); privateMessageUsers.Add(pmUser); if (tabControl.SelectedTab == MESSAGES_INDEX) { string selecterUserName = string.Empty; if (lbUserList.SelectedItem != null) { selecterUserName = lbUserList.SelectedItem.Text; } lbUserList.Clear(); privateMessageUsers.ForEach(pmsgUser => AddPlayerToList(pmsgUser.IrcUser, IsPlayerOnline(pmsgUser.IrcUser.Name))); lbUserList.SelectedIndex = FindItemIndexForName(selecterUserName); } } if (UserINISettings.Instance.AllowPrivateMessagesFromState == (int)AllowPrivateMessagesFromEnum.Friends && !cncnetUserData.IsFriend(pmUser.IrcUser.Name)) { return; } ChatMessage message = new ChatMessage(e.Sender, otherUserMessageColor, DateTime.Now, e.Message); pmUser.Messages.Add(message); lastReceivedPMSender = e.Sender; lastConversationPartner = e.Sender; if (!Visible) { HandleNotification(pmUser.IrcUser, e.Message); if (lbUserList.SelectedItem == null || lbUserList.SelectedItem.Text != e.Sender) { return; } } else if (lbUserList.SelectedItem == null || lbUserList.SelectedItem.Text != e.Sender) { HandleNotification(pmUser.IrcUser, e.Message); return; } lbMessages.AddMessage(message); if (sndMessageSound != null) { sndMessageSound.Play(); } }