Exemplo n.º 1
0
 private void SendButton_Click(object sender, RoutedEventArgs e)
 {
     if (MessageTextBox.Text.Length == 0)
     {
         return;
     }
     Server.SendMessageToALL(MessageTextBox.Text, UserNameTextBox.Text);
     TakeMessage(MessageTextBox.Text, "You");
     MessageTextBox.Text = "";
 }
Exemplo n.º 2
0
 private void sendMessage(object sender, RoutedEventArgs e)
 {
     if (chatEntryField.Text.Length == 0)
     {
         return;
     }
     //TODO: figure out how to send everyone message WCF
     Server.SendMessageToALL(chatEntryField.Text, loggedInUser.username);
     TakeMessage(chatEntryField.Text, loggedInUser.username);
     chatEntryField.Text = "";
 }
        // function setup to record the user select the send button or press enter
        private void SendButton_Click(object sender, RoutedEventArgs e)
        {
            // cancles the message if the message is blank
            if (MessageTextBox.Text.Length == 0)
            {
                return;
            }


            bool important = false;

            // checks to see if the important check box was check
            if (checkBox.IsChecked.Value)
            {
                important = true;
            }

            // if the user has not not selected a user form the online users
            if ((string)UsersListBox.SelectedItem != null)
            {
                // if the user has selected their own name
                if ((string)UsersListBox.SelectedItem == (string)UsernameTextBox.Text)
                {
                    // encrypt the message
                    string message = StringCipher.Encrypt(MessageTextBox.Text, "1q2w3e4r");
                    // send the message to everyone
                    Server.SendMessageToALL(message, UsernameTextBox.Text, important);
                    // display message in textbox
                    TakeMessage(message, "You", false);
                    // clear the input textbox
                    MessageTextBox.Text = "";
                }
                // if the user has selected anyone else but themselfs
                else
                {
                    string        friendName    = (string)UsersListBox.SelectedItem;
                    List <string> usersChatting = new List <string>();
                    usersChatting.Add(UsernameTextBox.Text);
                    usersChatting.Add(friendName);
                    // encrypt the message
                    string message       = StringCipher.Encrypt(MessageTextBox.Text, "1q2w3e4r");
                    string userName      = usersChatting[0];
                    string theiruserName = usersChatting[1];
                    // send the message to everyone
                    Server.SendMessageToPrivate(message, userName, theiruserName, important);
                    // display message in textbox
                    TakeMessage(message, "You to " + theiruserName, false);
                    // clear the input textbox
                    MessageTextBox.Text = "";
                }
            }
            // else the user has selected no one
            else
            {
                //TextDisplayTextBox.Text = "";
                string message = StringCipher.Encrypt(MessageTextBox.Text, "1q2w3e4r");
                Server.SendMessageToALL(message, UsernameTextBox.Text, important);
                TakeMessage(message, "You", false);
                MessageTextBox.Text = "";
            }
        }