private void btnSend_Click(object sender, EventArgs e)
 {
     try
     {
         if (rtbWriteMsg.Text.Trim().Length > 0 || rtbWriteMsg.Rtf.Trim().Length > 129)
         {
             chat.SendMessage(Form1.strMe, strUser, rtbWriteMsg.Rtf);
             rtbMessage.SelectedText = Form1.strMe + ": ";
             rtbMessage.SelectedRtf  = rtbWriteMsg.Rtf;
             rtbMessage.ScrollToCaret();
             rtbWriteMsg.Clear();
             rtbWriteMsg.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error in connecting to the chat server. Please try again.");
     }
 }
Пример #2
0
        private async void SendButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                await ChatService?.SendMessage(User?.UserName, SendMessageBox.Text);

                SendMessageBox.Text = "";
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                MessageBox.Show("Возникла ошибка при отправке сообщения!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #3
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (lstSelectUser.Items.Count < 2)
            {
                Close();
            }
            else
            {
                string strUsers = string.Empty;
                for (int i = 0; i < Form1.arrConf.Count - 1; i++)
                {
                    strUsers = strUsers + Form1.arrConf[i].ToString() + "|";
                }
                strUsers = strUsers + Form1.strMe;

                for (int i = 0; i < Form1.arrConf.Count - 1; i++)
                {
                    chat.SendMessage(Form1.strMe, Form1.arrConf[i].ToString(), "(((CONF)))" + strUsers);
                }
                Form f = new Conference();
                f.Show();
            }
        }