private void ShowTrailersMenu(TraktTrendingMovie movie)
        {
            IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
            dlg.Reset();
            dlg.SetHeading(Translation.Trailer);

            foreach (TrailerSite site in Enum.GetValues(typeof(TrailerSite)))
            {
                string menuItem = Enum.GetName(typeof(TrailerSite), site);
                GUIListItem pItem = new GUIListItem(menuItem);
                dlg.Add(pItem);
            }

            dlg.DoModal(GUIWindowManager.ActiveWindow);

            if (dlg.SelectedLabel >= 0)
            {
                string siteUtil = string.Empty;
                string searchParam = string.Empty;

                switch (dlg.SelectedLabelText)
                {
                    case ("IMDb"):
                        siteUtil = "IMDb Movie Trailers";
                        if (!string.IsNullOrEmpty(movie.Imdb))
                            // Exact search
                            searchParam = movie.Imdb;
                        else
                            searchParam = movie.Title;
                        break;

                    case ("iTunes"):
                        siteUtil = "iTunes Movie Trailers";
                        searchParam = movie.Title;
                        break;

                    case ("YouTube"):
                        siteUtil = "YouTube";
                        searchParam = movie.Title;
                        break;
                }

                string loadingParam = string.Format("site:{0}|search:{1}|return:Locked", siteUtil, searchParam);
                // Launch OnlineVideos Trailer search
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.OnlineVideos, loadingParam);
            }
        }
        private void RateMovie(TraktTrendingMovie movie)
        {
            // default rating to love if not already set
            TraktRateMovie rateObject = new TraktRateMovie
            {
                IMDBID = movie.Imdb,
                Title = movie.Title,
                Year = movie.Year,
                Rating = movie.Rating,
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password
            };

            string prevRating = movie.Rating;
            movie.Rating = GUIUtils.ShowRateDialog<TraktRateMovie>(rateObject);

            // if previous rating not equal to current rating then
            // update skin properties to reflect changes so we dont
            // need to re-request from server
            if (prevRating != movie.Rating)
            {
                if (prevRating == "false")
                {
                    movie.Ratings.Votes++;
                    if (movie.Rating == "love")
                        movie.Ratings.LovedCount++;
                    else
                        movie.Ratings.HatedCount++;
                }

                if (prevRating == "love")
                {
                    movie.Ratings.LovedCount--;
                    movie.Ratings.HatedCount++;
                }

                if (prevRating == "hate")
                {
                    movie.Ratings.LovedCount++;
                    movie.Ratings.HatedCount--;
                }

                movie.Ratings.Percentage = (int)Math.Round(100 * (movie.Ratings.LovedCount / (float)movie.Ratings.Votes));
            }
        }
        private void RemoveMovieFromWatchList(TraktTrendingMovie movie)
        {
            Thread syncThread = new Thread(delegate(object obj)
            {
                TraktAPI.TraktAPI.SyncMovieLibrary(CreateSyncData(obj as TraktTrendingMovie), TraktSyncModes.unwatchlist);
            })
            {
                IsBackground = true,
                Name = "Removing Movie from Watch List"
            };

            syncThread.Start(movie);
        }
 private void PublishMovieSkinProperties(TraktTrendingMovie movie)
 {
     SetProperty("#Trakt.Movie.Imdb", movie.Imdb);
     SetProperty("#Trakt.Movie.Certification", movie.Certification);
     SetProperty("#Trakt.Movie.Overview", string.IsNullOrEmpty(movie.Overview) ? Translation.NoMovieSummary : movie.Overview);
     SetProperty("#Trakt.Movie.Released", movie.Released.FromEpoch().ToShortDateString());
     SetProperty("#Trakt.Movie.Runtime", movie.Runtime.ToString());
     SetProperty("#Trakt.Movie.Tagline", movie.Tagline);
     SetProperty("#Trakt.Movie.Title", movie.Title);
     SetProperty("#Trakt.Movie.Tmdb", movie.Tmdb);
     SetProperty("#Trakt.Movie.Trailer", movie.Trailer);
     SetProperty("#Trakt.Movie.Url", movie.Url);
     SetProperty("#Trakt.Movie.Year", movie.Year);
     SetProperty("#Trakt.Movie.PosterImageFilename", movie.Images.PosterImageFilename);
     SetProperty("#Trakt.Movie.FanartImageFilename", movie.Images.FanartImageFilename);
     SetProperty("#Trakt.Movie.InCollection", movie.InCollection.ToString());
     SetProperty("#Trakt.Movie.InWatchList", movie.InWatchList.ToString());
     SetProperty("#Trakt.Movie.Plays", movie.Plays.ToString());
     SetProperty("#Trakt.Movie.Watchers", movie.Watchers.ToString());
     SetProperty("#Trakt.Movie.Watchers.Extra", movie.Watchers > 1 ? string.Format(Translation.PeopleWatching, movie.Watchers) : Translation.PersonWatching);
     SetProperty("#Trakt.Movie.Watched", (movie.Plays > 0).ToString());
     SetProperty("#Trakt.Movie.Rating", movie.Rating);
     SetProperty("#Trakt.Movie.Ratings.Icon", (movie.Ratings.LovedCount > movie.Ratings.HatedCount) ? "love" : "hate" );
     SetProperty("#Trakt.Movie.Ratings.HatedCount", movie.Ratings.HatedCount.ToString());
     SetProperty("#Trakt.Movie.Ratings.LovedCount", movie.Ratings.LovedCount.ToString());
     SetProperty("#Trakt.Movie.Ratings.Percentage", movie.Ratings.Percentage.ToString());
     SetProperty("#Trakt.Movie.Ratings.Votes", movie.Ratings.Votes.ToString());
 }
        private void MarkMovieAsWatched(TraktTrendingMovie movie)
        {
            Thread syncThread = new Thread(delegate(object obj)
            {
                TraktAPI.TraktAPI.SyncMovieLibrary(CreateSyncData(obj as TraktTrendingMovie), TraktSyncModes.seen);
            })
            {
                IsBackground = true,
                Name = "Mark Movie as Watched"
            };

            syncThread.Start(movie);
        }
        private TraktMovieSync CreateSyncData(TraktTrendingMovie movie)
        {
            if (movie == null) return null;

            List<TraktMovieSync.Movie> movies = new List<TraktMovieSync.Movie>();

            TraktMovieSync.Movie syncMovie = new TraktMovieSync.Movie
            {
                IMDBID = movie.Imdb,
                Title = movie.Title,
                Year = movie.Year
            };
            movies.Add(syncMovie);

            TraktMovieSync syncData = new TraktMovieSync
            {
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password,
                MovieList = movies
            };

            return syncData;
        }
        private void AddMovieToLibrary(TraktTrendingMovie movie)
        {
            Thread syncThread = new Thread(delegate(object obj)
            {
                TraktAPI.TraktAPI.SyncMovieLibrary(CreateSyncData(obj as TraktTrendingMovie), TraktSyncModes.library);
            })
            {
                IsBackground = true,
                Name = "Add Movie to Library"
            };

            syncThread.Start(movie);
        }
 private void PublishMovieSkinProperties(TraktTrendingMovie movie)
 {
     GUICommon.SetProperty("#Trakt.Movie.Watchers", movie.Watchers.ToString());
     GUICommon.SetProperty("#Trakt.Movie.Watchers.Extra", movie.Watchers > 1 ? string.Format(Translation.PeopleWatching, movie.Watchers) : Translation.PersonWatching);
     GUICommon.SetMovieProperties(movie);
 }