/* * METHOD : writeToBroadcastChatTab() * * DESCRIPTION : Display message field text string to broadcast chat text box * and relayed it to queue. * * PARAMETERS : STRING : messageText * * RETURNS : N/A */ public void writeToBroadcastChatTab(string messageText) { BroadcastChatTab.Focus(); BroadcastTabTextBox.AppendText("You Say: " + messageText + "\n"); packetBuffer = userNameTextBox.Text + "," + guiPacketBuffer.MessageType + "," + Environment.MachineName + "," + messageText + "," + guiPacketBuffer.RequestToChat; WriteToQueue(packetBuffer); }
/* * METHOD : selectAllButton_Click() * * DESCRIPTION : Select all clients in the list box. For a broadcast chat. * Will update the broad cast chat tab with graphical notifications depending on which packet is determining * the message type. * * RETURNS : N/A */ private void selectAllButton_Click(object sender, RoutedEventArgs e) { if (ClientListBox.Items.Count > 0) { BroadcastChatTab.Focus(); BroadcastChatTab.Foreground = new SolidColorBrush(Colors.Goldenrod); PrivateChatTab.Foreground = new SolidColorBrush(Colors.Black); GroupChatTab.Foreground = new SolidColorBrush(Colors.Black); ClientListBox.SelectAll(); // enable button SendButton.IsEnabled = true; // Prepares for a broadcast chat - text all users on all computers on the same server. Array clientSelected = Array.CreateInstance(typeof(string), ClientListBox.SelectedItems.Count); ClientListBox.SelectedItems.CopyTo(clientSelected, 0); for (int i = 0; i < ClientListBox.Items.Count; i++) { guiPacketBuffer.RequestToChat = guiPacketBuffer.RequestToChat + clientSelected.GetValue(i); if (i < (clientSelected.Length - 1)) { guiPacketBuffer.RequestToChat = guiPacketBuffer.RequestToChat + "|"; } guiPacketBuffer.MessageType = "B"; // signals broadcast chat type } } else { MessageBox.Show("You must have online clients in your queue in order to send a message."); } }