Esempio n. 1
0
        // Post DM in async fashion
        private async void PostDMAsync(string message)
        {
            // post message asynchronously
            await WorkHorse.PostDMAsync(MainUser.UserName, WorkHorse.DMReceiver, message);

            // when the task completes, fill the dm chat list box
            FillDMChatList();
        }
Esempio n. 2
0
        // this method will fill the blocked users list box
        // with users who are blocked by the active user
        private void ShowBlockedList()
        {
            List <string> blockedList = WorkHorse.GetBlockedUsers(MainUser.UserName);

            lb_block.Items.Clear();

            if (blockedList != null && blockedList.Count > 0)
            {
                foreach (string s in blockedList)
                {
                    lb_block.Items.Add(s);
                }
            }
        }
Esempio n. 3
0
        private void Btn_search_send_Click(object sender, RoutedEventArgs e)
        {
            string searchKey = txt_search.Text.Trim();

            if (searchKey.Length > 0)
            {
                txt_search.Text = "";
                List <Chat> chatList = WorkHorse.SearchChat(searchKey);
                FillChatBox("search", chatList);
            }
            else
            {
                FillChatBox("search", WorkHorse.ChatList);
            }
        }
Esempio n. 4
0
        private void Btn_direct_message_Click(object sender, RoutedEventArgs e)
        {
            if (!UserLoginCheck())
            {
                return;
            }

            ChangeGrid("dm1");

            // everytime DM page is opened, clear the receiver
            // a new receiver will be set each time
            WorkHorse.DMReceiver = "";

            // clear the dictionary of DMs
            WorkHorse.ClearDMs();
        }
Esempio n. 5
0
        // this method removes the selected user from blocked list
        private void Btn_remove_block_Click(object sender, RoutedEventArgs e)
        {
            // get the selected user
            if (lb_block.SelectedItem == null)
            {
                return;
            }

            string removeUser = lb_block.SelectedItem.ToString();

            if (removeUser != null)
            {
                WorkHorse.UnblockUser(MainUser.UserName, removeUser);

                ShowBlockedList();
            }
        }
Esempio n. 6
0
        private void Btn_block_send_Click(object sender, RoutedEventArgs e)
        {
            string user = txt_block.Text.Trim();

            if (user.Length > 0)
            {
                // prevent self blocking
                if (user.Equals(MainUser.UserName))
                {
                    MessageBox.Show("Sorry! You are not allowed to block yourself!");
                    txt_block.Text = "";
                    return;
                }

                WorkHorse.BlockUser(MainUser.UserName, user);
                txt_block.Text = "";
                ShowBlockedList();
            }
        }
Esempio n. 7
0
        // this will fill the DM Chat List Box with if there is a conversation
        // between active user and the receiver
        private void FillDMChatList()
        {
            // firstly, clear the list box
            lb_direct_message.Items.Clear();

            if (WorkHorse.DMChatList.Count > 0)
            {
                foreach (DirectMessage dm in WorkHorse.DMChatList)
                {
                    string sender  = dm.Fields.Sender;
                    string message = dm.Fields.Message;

                    // also block messages in DM if a user blocked the sender
                    if (WorkHorse.IsBlocked(MainUser.UserName, sender))
                    {
                        message = "*** blocked ***";
                    }

                    lb_direct_message.Items.Add(sender + ": " + message);
                }
            }
        }
Esempio n. 8
0
        private void FillChatBox(string location, List <Chat> chatList)
        {
            if (location.Equals("chat"))
            {
                lb_chat.Items.Clear();
            }

            if (location.Equals("search"))
            {
                lb_search.Items.Clear();
            }

            if (WorkHorse.ChatList.Count > 0)
            {
                foreach (var chat in chatList)
                {
                    string sender  = chat.Fields.Username;
                    string message = chat.Fields.Message;

                    // check if the sender is blocked, if so; block the message
                    if (WorkHorse.IsBlocked(MainUser.UserName, sender))
                    {
                        message = "*** blocked ***";
                    }

                    if (location.Equals("chat"))
                    {
                        lb_chat.Items.Add(sender + ": " + message);
                    }

                    if (location.Equals("search"))
                    {
                        lb_search.Items.Add(sender + ": " + message);
                    }
                }
            }
        }
Esempio n. 9
0
        // get the DMs asynchronously and fill the dm chat list
        private async void GetDMsAsync()
        {
            await WorkHorse.GetDMsAsync(MainUser.UserName, WorkHorse.DMReceiver);

            FillDMChatList();
        }
Esempio n. 10
0
        private async void PostChatAsync(string message)
        {
            await WorkHorse.PostChatAsync(MainUser.UserName, message);

            FillChatBox("chat", WorkHorse.ChatList);
        }
Esempio n. 11
0
        // this method will call the GetChat() method in WorkHorse class
        // and will populate the chat list box with the results
        private async void GetChatAsync()
        {
            await WorkHorse.GetAllChatAsync();

            FillChatBox("chat", WorkHorse.ChatList);
        }
Esempio n. 12
0
        public MainWindow()
        {
            InitializeComponent();

            WorkHorse.GetAllBlockedUsers();
        }