예제 #1
0
 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
       });
     }
   }));
 }
예제 #2
0
 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;
       }
     }));
 }
예제 #3
0
    public static void HandleEvent(FriendRemovedEvent e, MainViewModel dataContext)
    {

    }
예제 #4
0
 public static void HandleEvent(FriendRequestEvent e, MainViewModel dataContext)
 {
   dataContext.MessageText += $"Friend request was receieved from {e.SenderAccountName}!\n";
 }
예제 #5
0
 public static void HandleEvent(MessageEvent e, MainViewModel dataContext)
 {
   dataContext.MessageText += $"[From: {e.Sender}] {e.Message}\n";
 }
예제 #6
0
 public void SetDataContext(MainViewModel dataContext)
 {
   this.DataContext = dataContext;
 }