private void SendButton_Click_1(object sender, RoutedEventArgs e) { if (MessageTextBox.Text.Length == 0) { return; } string message = StringCipher.Encrypt(MessageTextBox.Text, "1q2w3e4r"); string userName = usersChatting[0]; string theiruserName = usersChatting[1]; Server.SendMessageToPrivate(message, userName, theiruserName, false); TakeMessage(message, "You"); MessageTextBox.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 = ""; } }