private void MovieContainer_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            Border          border    = sender as Border;
            MovieEntity     movie     = border.DataContext as MovieEntity;
            MovieListEntity movieList = ViewModelLocator.Instance.MovieListEntity;

            if (movieList != null)
            {
                movieList.SelectedMovie = movie;
            }
        }
Example #2
0
        /// <summary>
        /// Bind <see cref="IMovie"/> entities to the container.
        /// </summary>
        /// <typeparam name="T">The <see cref="IMovie"/> type.</typeparam>
        private void BindIMovieEntities <T>() where T : IMovie
        {
            ApiManager api = new ApiManager();

            // Get all movies from the API and cast them to the correct movie type.
            List <BaseMovie> baseMovieList = api.GetMovies().Cast <BaseMovie>().ToList();

            MovieListEntity movieList = new MovieListEntity
            {
                // Run base movie filter
                Movies = BaseMovieFilterManager.FilterAllMovies(baseMovieList),

                // Filter movies by popularity.
                PopularMovies = BaseMovieFilterManager.FilterPopular(baseMovieList)
            };

            // TODO: Find a better place for this code?
            // Get the current movie list
            switch (Get <ApplicationEntity>().CurrentPage)
            {
            case ApplicationPage.AllMovies:
                movieList.CurrentMovieList = movieList.Movies;
                break;

            case ApplicationPage.PopularMovies:
                movieList.CurrentMovieList = movieList.PopularMovies;
                break;

            default:
                movieList.CurrentMovieList = movieList.PopularMovies;
                break;
            }

            // Bind the list of movies to IoC container.
            Kernel.Bind <MovieListEntity>().ToConstant(movieList);
        }