Esempio n. 1
0
 /*
  * METHOD : writeToPrivateChatTab()
  *
  * DESCRIPTION : Display message field text string to private chat text box
  * and relayed it to queue.
  * PARAMETERS : STRING : messageText
  *
  * RETURNS    : N/A
  */
 public void writeToPrivateChatTab(string messageText)
 {
     PrivateChatTab.Focus();
     PrivateChatTabTextBox.AppendText("You Say: " + messageText + "\n"); //Allows text to be displayed multiline
     packetBuffer = userNameTextBox.Text + "," + guiPacketBuffer.MessageType + "," + Environment.MachineName + "," + messageText + "," + guiPacketBuffer.Alias;
     WriteToQueue(packetBuffer);                                         //write to queue
 }
Esempio n. 2
0
        /*
         * EVENT : selectButton_Click()
         *
         * DESCRIPTION :  Select individual clients in the list box.
         *  Will update the relevant tabs with graphical notifications depending on which packet is determining
         *  the message type.
         * PARAMETERS : object : sender
         *            : RoutedEventArgs : e
         *
         * RETURNS    : N/A
         */
        private void selectButton_Click(object sender, RoutedEventArgs e)
        {
            if (ClientListBox.Items.Count > 0)
            {
                SendButton.IsEnabled          = true;
                guiPacketBuffer.RequestToChat = "";
                guiPacketBuffer.MessageType   = "";


                if (ClientListBox.SelectedItems.Count > 1)
                {
                    GroupChatTab.Focus();
                    GroupChatTab.Foreground     = new SolidColorBrush(Colors.Goldenrod);
                    PrivateChatTab.Foreground   = new SolidColorBrush(Colors.Black);
                    BroadcastChatTab.Foreground = new SolidColorBrush(Colors.Black);

                    Array clientSelected = Array.CreateInstance(typeof(string), ClientListBox.SelectedItems.Count);
                    ClientListBox.SelectedItems.CopyTo(clientSelected, 0);

                    //Messages all clients that local user wishes to communicate with.
                    for (int i = 0; i < clientSelected.Length; i++)
                    {
                        string   aliasBuffer  = clientSelected.GetValue(i).ToString();
                        string[] removeStatus = aliasBuffer.Split(' ');
                        guiPacketBuffer.RequestToChat = guiPacketBuffer.RequestToChat + clientSelected.GetValue(i);
                        if (i < (clientSelected.Length - 1))
                        {
                            guiPacketBuffer.RequestToChat = guiPacketBuffer.RequestToChat + "|"; //delimites clients with pipe symbol
                        }
                        guiPacketBuffer.MessageType = "G";                                       //for group chat type communications
                    }
                }
                else
                {
                    if (ClientListBox.SelectedItems.Count > 0)
                    {
                        PrivateChatTab.Focus();
                        PrivateChatTab.Foreground   = new SolidColorBrush(Colors.Goldenrod);
                        GroupChatTab.Foreground     = new SolidColorBrush(Colors.Black);
                        BroadcastChatTab.Foreground = new SolidColorBrush(Colors.Black);

                        string   aliasBuffer  = ClientListBox.SelectedItem.ToString();
                        string[] removeStatus = aliasBuffer.Split(' '); //delimites with blank space
                        guiPacketBuffer.Alias       = removeStatus[0];
                        guiPacketBuffer.MessageType = "P";              //for private chat type communications
                    }
                    else
                    {
                        MessageBox.Show("Please select a client before clicking the select button.");
                    }
                }
            }
            else
            {
                MessageBox.Show("You must have online clients in your queue in order to send a message.");
            }
        }