private void UserServiceProxy_OnLoginEvent(object sender, OnLoginEventArgs e) { OnlineUsers = new ObservableCollection <UserDTO>(ContactStateManager.GetOnlineContacts()); OfflineUsers = new ObservableCollection <UserDTO>(ContactStateManager.GetOfflineContacts()); ConsoleLog.Document = e.UserName + "has loged in"; //OnlineUsers.Add(new UserDTO {UserName= e.UserName }); }
//ctor: public ContactListViewModel() { onlineUsers = new ObservableCollection <UserDTO>(ContactStateManager.GetOnlineContacts()); offlineUsers = new ObservableCollection <UserDTO>(ContactStateManager.GetOfflineContacts()); ConsoleLog = new ConsoleLog(); //init proxies: UserServiceProxy = UserServiceProxy.Instance; //TODO: is needed? UserServiceProxy.OnLoginEvent += UserServiceProxy_OnLoginEvent; UserServiceProxy.OnSignedUpEvent += UserServiceProxy_OnSignedUp; UserServiceProxy.OnLogoutEvent += UserServiceProxy_OnLogout; ChatServiceProxy = ChatServiceProxy.Instance; ChatServiceProxy.OnMessageSentEvent += ChatServiceProxy_OnMessageSent; GameServiceProxy = GameServiceProxy.Instance; GameServiceProxy.OnGameEvent += GameServiceProxy_OnGameEvent; //init ICommands: SendGameRequestCommand = new MyCommand(SendGameRequest); OpenChatWindowCommand = new MyCommand(OpenChatWindow); //subscribe to Closing Window event: Application.Current.MainWindow.Closing += MainWindow_OnWindowClosing; }
private void UserServiceProxy_OnLogout(object sender, OnLogoutEventArgs e) { OnlineUsers = new ObservableCollection <UserDTO>(ContactStateManager.GetOnlineContacts()); OfflineUsers = new ObservableCollection <UserDTO>(ContactStateManager.GetOfflineContacts()); ConsoleLog.Document += $"{e.UserName} has loged out"; }
private void UserServiceProxy_OnSignedUp(object sender, OnSignedUpEventArgs e) { //Getting the updated Offline contacts list: OfflineUsers = new ObservableCollection <UserDTO>(ContactStateManager.GetOfflineContacts()); ConsoleLog.Document = e.UserName + "has singed up"; }