Example #1
0
 private void Searching(object sender, RoutedEventArgs e)
 {
     try
     {
         if (!Validator.ValidTextBoxes(this.SearchBy.Text, this.TextToSearch.Text))
         {
             MessageBox.Show("Data not input");
         }
         SearchObject sObj = new SearchObject(this.TextToSearch.Text, this.SearchBy.Text);
         ServerObject.SendMessage("14", sObj.ToString());
         this.DataGrid.ItemsSource = new UserList(ServerObject.GetMessage()).GetUsers();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #2
0
 private void UpdateChats()
 {
     try
     {
         while (true)
         {
             ServerObject.SendMessage("17", thisUser.NickName);
             this.Dispatcher.Invoke((Action)(() =>
             {
                 this.Chats.ItemsSource = new ChatList(ServerObject.GetMessage()).GetChats();
             }));
             Thread.Sleep(5000);
         }
     }
     catch (Exception ex)
     {
     }
 }
Example #3
0
 private void UpdateMsgs()
 {
     try
     {
         while (true)
         {
             ServerObject.SendMessage("19", thisChat.ToString());
             MessageList list = new MessageList(ServerObject.GetMessage());
             this.Dispatcher.Invoke((Action)(() =>
             {
             }));
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #4
0
        private void SendMessage(object sender, RoutedEventArgs e)
        {
            if (!Validator.ValidateMessage(this.Message.Text))
            {
                Message msg = new Message(thisChat.ChatName, thisChat.thisUserName, this.Message.Text);
                ServerObject.SendMessage("18", msg.ToString());

                TextBlock tb = new TextBlock();
                tb.Style = this.FindResource("2") as Style;
                tb.Text  = this.Message.Text;
                Messages.Children.Add(tb);
                scroll.ScrollToBottom();
            }
            else
            {
                MessageBox.Show("Please, enter the message");
            }
            this.Message.Text = "Write message...";
        }
Example #5
0
 private void CreateChat(object sender, RoutedEventArgs e)
 {
     try
     {
         if (this.DataGrid.SelectedItems.Count > 4)
         {
             MessageBox.Show("нужно 4 и меньше");
         }
         else if (this.DataGrid.SelectedItems.Count == 0)
         {
             MessageBox.Show("Не выбраны польщователи");
         }
         else
         {
             UserList list = new UserList(this.DataGrid.SelectedItems.Cast <User>().ToList());
             ServerObject.SendMessage("15", thisUser.NickName + ";" + list.ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }