Beispiel #1
0
 private void UpdateGui(string strMessage, string transmitter, string receiver, string MessageType)
 {
     if (_client.connected == true)
     {
         btnConnect.Content = "Disconnect";
         txtIp.IsEnabled    = false;
         txtUser.IsEnabled  = false;
         ContextMenuService.SetIsEnabled(listUser, true);
     }
     else
     {
         btnConnect.Content = "Connect";
         txtIp.IsEnabled    = true;
         txtUser.IsEnabled  = true;
         ContextMenuService.SetIsEnabled(listUser, false);
     }
     if (strMessage.Length != 0)
     {
         string completeMessage = transmitter + ": " + strMessage;
         if (transmitter == "Administrator")
         {
             txtLog.Document.Blocks.Add(_parser.parse(completeMessage));
             txtLog.ScrollToEnd();
             if (_client.checkIfAdminMessage(completeMessage) == true)
             {
                 _client.manageAdminMessage(completeMessage);
                 listUser.ItemsSource = new ObservableCollection <string>(_client.getUsers());
             }
         }
         else
         {
             if (receiver == "global")
             {
                 txtLog.Document.Blocks.Add(_parser.parse(completeMessage));
                 txtLog.ScrollToEnd();
             }
             else
             {
                 if (MessageType == Chatmessage.MESSAGE_TYPE_USER_INFO)
                 {
                     MessageBox.Show(strMessage);
                 }
                 else
                 {
                     if (_privateChats.ContainsKey(transmitter) == false)
                     {
                         PrivateWindow newWindow = new PrivateWindow(transmitter);
                         newWindow.setOwner(this);
                         newWindow.Show();
                         _privateChats.Add(transmitter, newWindow);
                     }
                     PrivateWindow partnerWindow = (PrivateWindow)_privateChats[transmitter];
                     partnerWindow.Show();
                     partnerWindow.txtLog.Document.Blocks.Add(_parser.parse(completeMessage));
                     partnerWindow.txtLog.ScrollToEnd();
                 }
             }
         }
     }
 }