예제 #1
0
        private void onlineUsers_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            String tabUsername = e.Item.Text;

            inviteToGroup.Enabled = false;
            Console.WriteLine(inviteToGroupChat);
            if (inviteToGroupChat && onlineUsers.SelectedItems.Count != 0)
            {
                if (server.IsUserInGroup(tabUsername, selectedGroup))
                {
                    MessageBox.Show(tabUsername + " has already joined \"" + selectedGroup + "\".");
                }
                else
                {
                    Request request = new Request(server, tabUsername, selectedGroup);
                    Thread  oThread = new Thread(new ThreadStart(request.SendGroupChat));
                    oThread.Start();
                    MessageBox.Show(tabUsername + " has been invited to join \"" + selectedGroup + "\".");
                }
                inviteToGroupChat = false;
            }
            else
            {
                if (onlineUsers.SelectedItems.Count == 0)
                {
                    startChat.Enabled = false;
                }
                else if (chatTabs.Contains(tabUsername))
                {
                    groupChatActive = false;
                    ChatTab tab   = (ChatTab)chatTabs[tabUsername];
                    int     index = activeConversations.TabPages.IndexOf(tab.tabPage);
                    activeConversations.SelectedIndex = index;
                    startChat.Enabled = false;
                    if (tab.offline)
                    {
                        DisableSend();
                    }
                    else
                    {
                        msgToSend.Enabled = true;
                    }
                }
                else
                {
                    startChat.Enabled = true;
                }
            }
        }
예제 #2
0
        private void sendBtn_Click(object sender, EventArgs e)
        {
            if (!groupChatActive)
            {
                activeUserRemObj.ReceiveMessage(new Message(username, msgToSend.Text, username));
            }
            else
            {
                server.SendGroupChatMessage(activeUser, new Message(username, msgToSend.Text, activeUser));
            }
            ChatTab tab = (ChatTab)chatTabs[activeUser];

            tab.AddSenderText(msgToSend.Text, username);
            msgToSend.Clear();
        }
예제 #3
0
        public void RequestAccepted(String username, String address)
        {
            ChatTab tab = (ChatTab)chatTabs[username];

            tab.RequestAccepted(username);
            tab.offline = false;
            activeUsers.Add(username, address);

            BeginInvoke(new Action(() =>
            {
                if (activeConversations.SelectedTab == tab.tabPage)
                {
                    ChangeActiveUser(username);
                    msgToSend.Enabled = true;
                }
            }));
        }
예제 #4
0
        private void RemoveUser(String username)
        {
            usersList.Remove(username);
            if (chatTabs.Contains(username))
            {
                ChatTab tab = (ChatTab)chatTabs[username];
                tab.SetOfflineMsg(username);
                if (activeUser.Equals(username))
                {
                    DisableSend();
                }
            }

            foreach (ListViewItem lvI in onlineUsers.Items)
            {
                if (lvI.SubItems[0].Text == username)
                {
                    lvI.Remove();
                    break;
                }
            }
        }
예제 #5
0
        public void RequestRefused(String username)
        {
            ChatTab tab = (ChatTab)chatTabs[username];

            tab.RequestRefused(username);
        }