Exemple #1
0
        public MainWindowViewModel(IViewController views, ChatClient client, ConnectionManager connection, Dispatcher dispatcher)
        {
            this.views      = views;
            this.client     = client;
            this.connection = connection;
            this.dispatcher = dispatcher;

            ChangeNameCommand   = new RelayCommand(_ => ChangeName());
            ChangeFontCommand   = new RelayCommand(_ => ChangeFont());
            ChangeStatusCommand = new RelayCommand(_ => ChangeStatus(_ as string), _ => CanChangeStatus(_ as string));
            CloseChatCommand    = new RelayCommand(_ => CloseConversation(_ as ConversationViewModel));
            LogoutCommand       = new RelayCommand(_ => LogOut());
            QuitCommand         = new RelayCommand(_ => Quit());
            ViewEmotesCommand   = new RelayCommand(_ => ViewEmotes());

            stateDetector = new UserStateDetector();
            stateDetector.IdleTimeThreshold = 60 * 5;             // 5 minutes
            stateDetector.IsIdleEnabled     = true;
            stateDetector.IsBusyEnabled     = true;
            stateDetector.UserIdleChanged  += OnUserIdleChanged;
            stateDetector.UserBusyChanged  += OnUserBusyChanged;

            client.StreamError += OnStreamError;
            me            = new UserViewModel(client, client.Me);
            conversations = new ConversationManager(client);
            conversations.NewConversation += OnNewConversation;

            openTabsView = new ListCollectionView(openTabs);
            openTabsView.CurrentChanged += OnCurrentTabChanged;

            var newTabVM = new NewTabViewModel(client);

            newTabVM.StartChat += OnStartChat;
            openTabs.Add(newTabVM);

            tabHighlightTimer.Elapsed += OnTabHighlight;

            client.ListFriends();
            client.ListGroups();
        }
        public MainWindowViewModel(IViewController views, ChatClient client, ConnectionManager connection, Dispatcher dispatcher)
        {
            this.views = views;
            this.client = client;
            this.connection = connection;
            this.dispatcher = dispatcher;

            ChangeNameCommand = new RelayCommand(_ => ChangeName());
            ChangeFontCommand = new RelayCommand(_ => ChangeFont());
            ChangeStatusCommand = new RelayCommand(_ => ChangeStatus(_ as string), _ => CanChangeStatus(_ as string));
            CloseChatCommand = new RelayCommand(_ => CloseConversation(_ as ConversationViewModel));
            LogoutCommand = new RelayCommand(_ => LogOut());
            QuitCommand = new RelayCommand(_ => Quit());
            ViewEmotesCommand = new RelayCommand(_ => ViewEmotes());

            stateDetector = new UserStateDetector();
            stateDetector.IdleTimeThreshold = 60 * 5; // 5 minutes
            stateDetector.IsIdleEnabled = true;
            stateDetector.IsBusyEnabled = true;
            stateDetector.UserIdleChanged += OnUserIdleChanged;
            stateDetector.UserBusyChanged += OnUserBusyChanged;

            client.StreamError += OnStreamError;
            me = new UserViewModel(client, client.Me);
            conversations = new ConversationManager(client);
            conversations.NewConversation += OnNewConversation;

            openTabsView = new ListCollectionView(openTabs);
            openTabsView.CurrentChanged += OnCurrentTabChanged;

            var newTabVM = new NewTabViewModel(client);
            newTabVM.StartChat += OnStartChat;
            openTabs.Add(newTabVM);

            tabHighlightTimer.Elapsed += OnTabHighlight;

            client.ListFriends();
            client.ListGroups();
        }