Exemple #1
0
        /// <summary>
        /// Register messages
        /// </summary>
        private void RegisterMessages()
        {
            Messenger.Default.Register <ManageExceptionMessage>(this, e =>
            {
                ManageException(e.UnHandledException);
            });

            Messenger.Default.Register <WindowStateChangeMessage>(this, e =>
            {
                OnWindowStateChanged(new WindowStateChangedEventArgs(e.IsMoviePlaying));
            });

            Messenger.Default.Register <LoadMovieMessage>(this, e => { IsMovieFlyoutOpen = true; });

            Messenger.Default.Register <PlayMovieMessage>(this, message =>
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    _moviePlayerViewModel = new MoviePlayerViewModel(ApplicationState, _movieService,
                                                                     _movieHistoryService);
                    _moviePlayerViewModel.LoadMovie(message.Movie);
                    Tabs.Add(_moviePlayerViewModel);
                    SelectedTab       = Tabs.Last();
                    IsMovieFlyoutOpen = false;
                    ApplicationState.IsMoviePlaying = true;
                });
            });

            Messenger.Default.Register <StopPlayingMovieMessage>(
                this,
                message =>
            {
                // Remove the movie tab
                MoviePlayerViewModel moviePlayer = null;
                foreach (var mediaViewModel in Tabs.OfType <MoviePlayerViewModel>())
                {
                    moviePlayer = mediaViewModel;
                }

                if (moviePlayer != null)
                {
                    Tabs.Remove(moviePlayer);
                    moviePlayer.Cleanup();
                    SelectedTab = Tabs.FirstOrDefault();
                }

                IsMovieFlyoutOpen = true;
                ApplicationState.IsMoviePlaying = false;
            });

            Messenger.Default.Register <SearchMovieMessage>(this,
                                                            async message =>
            {
                await SearchMovies(message.Filter);
            });
        }
Exemple #2
0
        /// <summary>
        /// Register messages
        /// </summary>
        private void RegisterMessages()
        {
            Messenger.Default.Register <ManageExceptionMessage>(this, e =>
            {
                ManageException(e.UnHandledException);
            });

            Messenger.Default.Register <LoadMovieMessage>(this, e => { IsMovieFlyoutOpen = true; });

            Messenger.Default.Register <PlayMovieMessage>(this, message =>
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    Tabs.Add(new MoviePlayerViewModel(message.Movie));
                    SelectedTab       = Tabs.Last();
                    IsMovieFlyoutOpen = false;
                    IsMoviePlaying    = true;
                });
            });

            Messenger.Default.Register <StopPlayingMovieMessage>(
                this,
                message =>
            {
                // Remove the movie tab
                MoviePlayerViewModel moviePlayer = null;
                foreach (var tab in Tabs)
                {
                    var mediaViewModel = tab as MoviePlayerViewModel;
                    if (mediaViewModel != null)
                    {
                        moviePlayer = mediaViewModel;
                    }
                }
                if (moviePlayer != null)
                {
                    Tabs.Remove(moviePlayer);
                    moviePlayer.Cleanup();
                    SelectedTab = Tabs.FirstOrDefault();
                }

                IsMovieFlyoutOpen = true;
                IsMoviePlaying    = false;
            });

            Messenger.Default.Register <SearchMovieMessage>(this,
                                                            async message =>
            {
                await SearchMovies(message.Filter);
            });
        }