public static void HandleEvent(FriendRequestAcceptedEvent e, MainViewModel dataContext) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { foreach (var friend in e.Friends) { dataContext.Friends.Add(new FriendViewModel { FriendName = friend.UserName, Presence = friend.Presence, Id = friend.Id }); } })); }
public static void HandleEvent(PresenceChangeEvent e, MainViewModel dataContext) { Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.Background, new Action(() => { if (dataContext.Friends.All(friend => friend.FriendName != e.AccountName)) { dataContext.Friends.Add(new FriendViewModel { FriendName = e.AccountName, Presence = e.PresenceStatus }); } else { var friend = dataContext.Friends.First(f => f.FriendName == e.AccountName); friend.Presence = e.PresenceStatus; } })); }
public static void HandleEvent(FriendRemovedEvent e, MainViewModel dataContext) { }
public static void HandleEvent(FriendRequestEvent e, MainViewModel dataContext) { dataContext.MessageText += $"Friend request was receieved from {e.SenderAccountName}!\n"; }
public static void HandleEvent(MessageEvent e, MainViewModel dataContext) { dataContext.MessageText += $"[From: {e.Sender}] {e.Message}\n"; }
public void SetDataContext(MainViewModel dataContext) { this.DataContext = dataContext; }