private void ClientReceiveMessage(object sender, ReceiveMessageEventArgs e) { if (e.Type != MessageType.System && e.Type != MessageType.Private) { return; } Dispatcher.BeginInvoke(new Action <ReceiveMessageEventArgs>(args => { switch (args.Type) { case MessageType.Private: using (var client = ClientModel.Get()) { UserViewModel senderUser = AllUsers.Single(uvm => string.Equals(uvm.Info.Nick, args.Sender)); UserViewModel receiverUser = AllUsers.Single(uvm => string.Equals(uvm.Info.Nick, client.User.Nick)); SelectedRoom.AddPrivateMessage(senderUser, receiverUser, args.Message); } break; case MessageType.System: SelectedRoom.AddSystemMessage(Localizer.Instance.Localize(args.SystemMessage, args.SystemMessageFormat)); break; } Alert(); }), e); }
private void ClientReceiveMessage(ReceiveMessageEventArgs e) { if (e.Type != MessageType.System && e.Type != MessageType.Private) { return; } switch (e.Type) { case MessageType.Private: SelectedRoom.AddPrivateMessage(e.Sender, ClientModel.Client.Id, e.Message); break; case MessageType.System: SelectedRoom.AddSystemMessage(Localizer.Instance.Localize(e.SystemMessage, e.SystemMessageFormat)); break; } Alert(); }