Beispiel #1
0
        /// <summary>
        /// Creates an instance of the chat room view model and resolves its dependencies
        /// </summary>
        /// <param name="eventAggregator"></param>
        /// <param name="networkConnectionController"></param>
        /// <param name="currentUser"></param>
        /// <param name="chatManager"></param>
        /// <param name="regionManager"></param>
        /// <param name="overlayService"></param>
        public ChatRoomViewModel(IEventAggregator eventAggregator, INetworkConnectionController networkConnectionController, ICurrentUser currentUser, IChatManager chatManager, IRegionManager regionManager, IOverlayService overlayService)
        {
            //assigns local variables
            _eventAggregator             = eventAggregator;
            _networkConnectionController = networkConnectionController;
            _currentUser    = currentUser;
            _chatManager    = chatManager;
            _regionManager  = regionManager;
            _overlayService = overlayService;

            _eventAggregator.GetEvent <UserLoginEvent>().Subscribe(UserLogin);
            _eventAggregator.GetEvent <OfflineUsersLoadedEvent>().Subscribe(() => IsConnectAllowed = true);
            _eventAggregator.GetEvent <UserEditedEvent>().Subscribe((user) => User = user);

            //Sets up the basic server settings
            ServerModel              = new ServerModel();
            ServerModel.IpAddress    = "192.168.1.97";
            ServerModel.Port         = 2500;
            ServerModel.ServerStatus = ServerStatus.Disconnected;

            //Sets up command executions
            ServerConnectCommand      = new DelegateCommand(Connect);
            ToggleBaseCommand         = new DelegateCommand <object>(ToggleBaseColor);
            CurrentUserClickedCommand = new DelegateCommand(CurrentUserClicked);
            LogoutCommand             = new DelegateCommand(Logout);
        }
 public ChatManager(INetworkConnectionController networkConnectionController)
 {
     _networkConnectionController = networkConnectionController;
     _networkConnectionController.MessageReceivedEventHandler += MessageReceived;
     Chats      = new Dictionary <int, List <object> >();
     _callbacks = new List <Action <int> >();
 }
Beispiel #3
0
 public LoginViewModel(IRegionManager regionManager, IPasswordProtectionService passwordProtectionService, IEventAggregator eventAggregator, INetworkConnectionController networkConnectionController, ICurrentUser currentUser, IOverlayService overlayService)
 {
     _regionManager               = regionManager;
     _passwordProtectionService   = passwordProtectionService;
     _eventAggregator             = eventAggregator;
     _networkConnectionController = networkConnectionController;
     _currentUser           = currentUser;
     _overlayService        = overlayService;
     PasswordChangedCommand = new DelegateCommand <object>(PasswordChanged);
     LoginCommand           = new DelegateCommand(Login);
     RegisterCommand        = new DelegateCommand(Register);
 }
        public UsersListViewModel(INetworkConnectionController networkConnectionController, IEventAggregator eventAggregator, IChatManager chatManager, ICurrentUser currentUser)
        {
            _networkConnectionController = networkConnectionController;
            _eventAggregator             = eventAggregator;
            _chatManager = chatManager;
            _currentUser = currentUser;

            _networkConnectionController.MessageReceivedEventHandler += NewMessageFromServer;
            _eventAggregator.GetEvent <LogoffEvent>().Subscribe(Logoff);

            SelectedSocketUser = new SocketUser();
            OnlineSocketUsers  = new ObservableCollection <SocketUser>();
            OfflineSocketUsers = new ObservableCollection <SocketUser>();

            ViewLoadedCommand = new DelegateCommand(LoadView);
        }
Beispiel #5
0
        /// <summary>
        /// Creates an instance of the chat view model and resolves its dependencies
        /// </summary>
        /// <param name="eventAggregator"></param>
        /// <param name="chatManager"></param>
        /// <param name="currentUser"></param>
        /// <param name="networkConnectionController"></param>
        /// <param name="fileProcessorService"></param>
        public ChatViewModel(IEventAggregator eventAggregator, IChatManager chatManager, ICurrentUser currentUser, INetworkConnectionController networkConnectionController, IFileProcessorService fileProcessorService)
        {
            _eventAggregator             = eventAggregator;
            _chatManager                 = chatManager;
            _currentUser                 = currentUser;
            _networkConnectionController = networkConnectionController;
            _fileProcessorService        = fileProcessorService;
            _eventAggregator.GetEvent <UserSelected>().Subscribe(UserSelected);
            _chatManager.NewMessageCallback(UpdateChat);

            Images = new ObservableCollection <byte[]>();

            ChatMessages = new ObservableCollection <object>();

            SendMessageCommand = new DelegateCommand(async() => await SendMessage());

            KeyDownCommand = new DelegateCommand(OnKeyDown);

            SelectImageCommand = new DelegateCommand(SelectImage);

            _networkConnectionController.MessageReceivedEventHandler += MessageReceivedEventHandler;

            _eventAggregator.GetEvent <LogoffEvent>().Subscribe(Logoff);

            ChatMessages.Add(new ChatMessageModel()
            {
                IsSent    = true,
                Message   = "Test Message",
                TimeStamp = DateTime.Now
            });
            ChatMessages.Add(new ChatMessageModel()
            {
                IsSent    = true,
                Message   = "Test Message",
                TimeStamp = DateTime.Now
            });
            ChatMessages.Add(new ChatMessageModel()
            {
                IsSent    = false,
                Message   = "Test Message",
                TimeStamp = DateTime.Now
            });
        }
 public OnlineUsersManager(INetworkConnectionController networkConnectionController, IChatManager chatManager)
 {
     _chatManager = chatManager;
     networkConnectionController.MessageReceivedEventHandler += MessageReceivedEventHandler;
     OnlineUsers = new ObservableCollection <SocketUser>();
 }