private void ButtonSendChat_Click(object sender, RoutedEventArgs e)
        {
            String stringSend  = null;
            String AppUserName = AppUser.Name + " " + AppUser.LastName;
            String ProfilePic  = AppUser.ProfilePic;

            stringSend = AppUserName + "#$#$" + ProfilePic + "#$#$" + TextBoxChat.Text;
            string s = TextBoxChat.Text;

            TextBoxChat.Clear();

            if (!_isConnected)
            {
                MessageBox.Show("Not conected to server"); return;
            }

            ChatBox cb = new ChatBox(false, s, "YOU", ProfilePic);

            cb.HorizontalAlignment = HorizontalAlignment.Right;
            cb.Margin = new Thickness(0, 0, 0, 3);
            StackPanelChat.Children.Add(cb);
            ScrollViewerChat.ScrollToBottom();
            _sWriter = new StreamWriter(_client.GetStream(), Encoding.ASCII);
            _sWriter.WriteLine(stringSend);
            _sWriter.Flush();
        }
示例#2
0
        //Нажали на кнопку "Отправить сообщение"
        private void buttonSendMsg_Click(object sender, EventArgs e)
        {
            if (tbxMsgMode == 1)
            {
                //Если текстбокс в "не рабочем режиме" то ничего не делать
                //Иначе делать
            }
            else
            {
                String[] userQuestion = TextBoxSendMsg.Text.Split(new String[] { "\r\n" },
                                                                  StringSplitOptions.RemoveEmptyEntries);

                string message = userQuestion[0]; // для отправки боту

                userQuestion[0] = userQuestion[0].Insert(0,
                                                         "[" + DateTime.Now.ToString("HH:mm") + "] " + bot.UserName + ": ");

                bot.AddToHistory(userQuestion);

                TextBoxChat.AppendText(userQuestion[0] + "\r\n");
                TextBoxSendMsg.Text = "";
                string[] botAnswer = new string[] { bot.Answer(message) };
                botAnswer[0] = botAnswer[0].Insert(0, "Бот: ");
                TextBoxChat.AppendText(botAnswer[0] + Environment.NewLine);

                bot.AddToHistory(botAnswer);
            }
        }
示例#3
0
 private void ButtonSend_Click(object sender, RoutedEventArgs e)
 {
     if (TextBoxChat.Text == "")
     {
         MessageBox.Show("Hãy nhập nội dung chat");
     }
     else
     {
         socket.Emit("ChatMessage", TextBoxChat.Text);
         TextBoxChat.Clear();
     }
 }
示例#4
0
        private void ClickIconChat(object sender, EventArgs e)
        {
            string message = TextBoxChat.Text;

            if (!string.IsNullOrEmpty(message))
            {
                serverChat.SendMessage(GameId, message);

                string format = "\n" + Properties.Resources.You + ": " + message;
                ChatBox.AppendText(format);
                ChatBox.ScrollToEnd();
                TextBoxChat.Clear();
            }
        }
示例#5
0
        private void buttonTest_Click(object sender, EventArgs e)
        {
            InstanceContext context = new InstanceContext(new MyCallback());

            Proxy.ChatServiceClient server = new Proxy.ChatServiceClient(context);

            var message = TextBoxChat.Text;

            if (!string.IsNullOrEmpty(message))
            {
                server.SendMessage(message);
            }
            LabelTextChat.Content += "\n " + "Tu : " + message;
            TextBoxChat.Clear();
        }
示例#6
0
        private void ClickIconChat(object sender, EventArgs e)
        {
            string message = TextBoxChat.Text;

            if (!string.IsNullOrEmpty(message))
            {
                try
                {
                    server.SendMessage(0, message);

                    string format = "\n" + Properties.Resources.You + ": " + message;
                    ChatBox.AppendText(format);
                    ChatBox.ScrollToEnd();
                    TextBoxChat.Clear();
                }
                catch (CommunicationObjectFaultedException ex)
                {
                    Console.WriteLine(ex.ToString());
                    LabelAlert.Content = Properties.Resources.ServerIsOff;
                }
            }
        }
 private void ChatTextChange(object sender, TextChangedEventArgs e)
 {
     TextBoxChat.ScrollToEnd();
 }
示例#8
0
 /// <summary>
 /// Allows the other pages to return to this menu screen.
 /// </summary>
 public void GoBack()
 {
     TextBoxChat.Clear();
     ChatBox.Clear();
     Content = content;
 }