virtual protected void OnChatReceived(CChatContentEventArgs e) { if (ChatReceived != null) { ChatReceived(this, e); } }
private void CClient_ChatReceived(object sender, CChatContentEventArgs e) { // Chat wird nur komplett aktualisert, wenn man einen neuen Kontakt auswählt if (selectedContact[0] != selectedContact[1]) { Application.Current.Dispatcher.Invoke((Action) delegate { splChat.Children.Clear(); //Stackpanel säubern }); DataTable tmp = e.DtChat; foreach (DataRow row in tmp.Rows) { Application.Current.Dispatcher.Invoke((Action) delegate { //TODO: Nach einer anderen Lösungsmöglichkeit recherchieren if (row["main_email"].ToString() == "Sie") { UserControlMessageSent messagesent = new UserControlMessageSent(row["message"].ToString(), row["thetime"].ToString()); splChat.Children.Add(messagesent); } else { UserControlMessageReceived messagereceived = new UserControlMessageReceived(row["message"].ToString(), row["thetime"].ToString()); splChat.Children.Add(messagereceived); } }); } // Nach unten scrollen Application.Current.Dispatcher.Invoke((Action) delegate { chatViewScroller.ScrollToBottom(); }); } }