private void Connection_MessageReceived(object sender, MessageEventArgs e) { if (e.Message.Type == MessageType.Chat) { Application.Current.Dispatcher.Invoke(() => MessageLog.AddMessage(e.Message, true)); Application.Current.Dispatcher.Invoke(() => StatusTextBlock.Text = LocaleSelector.GetLocaleString("StatusIndicator_StrangerIdle")); } else if (e.Message.Type == MessageType.Topic) { Application.Current.Dispatcher.Invoke(() => MessageLog.AddTopic(e.Message)); } }
private void FillMessageLog(string path) { Application.Current.Dispatcher.Invoke(() => { using (var sr = new StreamReader(path)) { var array = sr.ReadToEnd().Split('\n'); foreach (var s in array) { object item; try { item = Presence.Parse(s); } catch { try { item = Message.Parse(s); } catch { try { item = Topic.Parse(s); } catch { return; } } } if (item is Presence) { var p = item as Presence; MessageLog.AddPresence(p.Connect); } if (item is Message) { var m = item as Message; MessageLog.AddMessage( new ObcyProtoRev.Protocol.Client.Message( m.Body, -1, -1, MessageType.Chat ), m.Incoming, m.Timestamp.FromUnixTimestamp() ); } if (item is Topic) { var t = item as Topic; MessageLog.AddTopic( new ObcyProtoRev.Protocol.Client.Message( t.Body, 0, 0, MessageType.Topic ) ); } } } }); }