private void newRoom_OnParticipantJoin(Room room, RoomParticipant participant) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { TextRange tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd); tr.Text = participant.Nick + " joined the room." + Environment.NewLine; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Yellow); ChatText.ScrollToEnd(); })); }
private void newRoom_OnRoomMessage(object sender, Message msg) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { if (msg.Body != "This room is not anonymous") { TextRange tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd); tr.Text = msg.From.Resource + ": "; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Blue); tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd); tr.Text = msg.InnerText.Replace("<![CDATA[", "").Replace("]]>", "") + Environment.NewLine; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.White); ChatText.ScrollToEnd(); } })); }
private void ChatButton_Click(object sender, RoutedEventArgs e) { TextRange tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd); tr.Text = Client.LoginPacket.AllSummonerData.Summoner.Name + ": "; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Yellow); tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd); tr.Text = ChatTextBox.Text + Environment.NewLine; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.White); if (String.IsNullOrEmpty(ChatTextBox.Text)) { return; } newRoom.PublicMessage(ChatTextBox.Text); ChatTextBox.Text = ""; ChatText.ScrollToEnd(); }