GetRatingOverlay() статический приватный Метод

Get a overlay for images that represent a users rating
static private GetRatingOverlay ( int userRating ) : RatingOverlayImage
userRating int
Результат RatingOverlayImage
        /// <summary>
        /// Loads an Image from memory into a facade item
        /// </summary>
        /// <param name="imageFilePath">Filename of image</param>
        protected void SetImageToGui(string imageFilePath)
        {
            if (string.IsNullOrEmpty(imageFilePath))
            {
                return;
            }

            // determine the overlays to add to poster
            var mainOverlay = MainOverlayImage.None;

            if (Season.IsWatchlisted(Show))
            {
                mainOverlay = MainOverlayImage.Watchlist;
            }
            else if (Season.IsWatched(Show))
            {
                mainOverlay = MainOverlayImage.Seenit;
            }

            // add additional overlay if applicable
            if (Season.IsCollected(Show))
            {
                mainOverlay |= MainOverlayImage.Library;
            }

            RatingOverlayImage ratingOverlay = GUIImageHandler.GetRatingOverlay(Season.UserRating(Show));

            // get a reference to a MediaPortal Texture Identifier
            string suffix  = Enum.GetName(typeof(MainOverlayImage), mainOverlay) + Enum.GetName(typeof(RatingOverlayImage), ratingOverlay);
            string texture = GUIImageHandler.GetTextureIdentFromFile(imageFilePath, suffix);

            // build memory image
            Image memoryImage = null;

            if (mainOverlay != MainOverlayImage.None || ratingOverlay != RatingOverlayImage.None)
            {
                memoryImage = GUIImageHandler.DrawOverlayOnPoster(imageFilePath, mainOverlay, ratingOverlay);
                if (memoryImage == null)
                {
                    return;
                }

                // load texture into facade item
                if (GUITextureManager.LoadFromMemory(memoryImage, texture, 0, 0, 0) > 0)
                {
                    ThumbnailImage = texture;
                    IconImage      = texture;
                    IconImageBig   = texture;
                }
            }
            else
            {
                ThumbnailImage = imageFilePath;
                IconImage      = imageFilePath;
                IconImageBig   = imageFilePath;
            }

            // if selected and is current window force an update of thumbnail
            this.UpdateItemIfSelected(WindowID, ItemId);
        }
        /// <summary>
        /// Loads an Image from memory into a facade item
        /// </summary>
        /// <param name="imageFilePath">Filename of image</param>
        protected void SetImageToGui(string imageFilePath)
        {
            if (string.IsNullOrEmpty(imageFilePath))
            {
                return;
            }

            // check if this user item is a shout
            // we may need to apply a rating overlay to the avatar
            if (TVTag is TraktComment)
            {
                var shout = TVTag as TraktComment;

                // add a rating overlay if user has rated item
                var ratingOverlay = GUIImageHandler.GetRatingOverlay(shout.UserRating);

                // get a reference to a MediaPortal Texture Identifier
                string suffix  = Enum.GetName(typeof(RatingOverlayImage), ratingOverlay);
                string texture = GUIImageHandler.GetTextureIdentFromFile(imageFilePath, suffix);

                // build memory image, resize avatar as they come in different sizes sometimes
                Image memoryImage = null;
                if (ratingOverlay != RatingOverlayImage.None)
                {
                    memoryImage = GUIImageHandler.DrawOverlayOnAvatar(imageFilePath, ratingOverlay, new Size(140, 140));
                    if (memoryImage == null)
                    {
                        return;
                    }

                    // load texture into facade item
                    if (GUITextureManager.LoadFromMemory(memoryImage, texture, 0, 0, 0) > 0)
                    {
                        ThumbnailImage = texture;
                        IconImage      = texture;
                        IconImageBig   = texture;
                    }
                }
                else
                {
                    ThumbnailImage = imageFilePath;
                    IconImage      = imageFilePath;
                    IconImageBig   = imageFilePath;
                }
            }
            else
            {
                ThumbnailImage = imageFilePath;
                IconImage      = imageFilePath;
                IconImageBig   = imageFilePath;
            }

            // if selected and is current window force an update of thumbnail
            this.UpdateItemIfSelected(WindowID, ItemId);
        }
Пример #3
0
        /// <summary>
        /// Loads an Image from memory into a facade item
        /// </summary>
        /// <param name="imageFilePath">Filename of image</param>
        protected void SetImageToGui(string imageFilePath)
        {
            if (string.IsNullOrEmpty(imageFilePath))
            {
                return;
            }

            // determine the overlays to add to poster
            TraktShow        show        = TVTag as TraktShow;
            MainOverlayImage mainOverlay = MainOverlayImage.None;

            if (show.InWatchList)
            {
                mainOverlay = MainOverlayImage.Watchlist;
            }
            //else if (show.Watched)
            //    mainOverlay = MainOverlayImage.Seenit;

            RatingOverlayImage ratingOverlay = GUIImageHandler.GetRatingOverlay(show.RatingAdvanced);

            // get a reference to a MediaPortal Texture Identifier
            string suffix  = Enum.GetName(typeof(MainOverlayImage), mainOverlay) + Enum.GetName(typeof(RatingOverlayImage), ratingOverlay);
            string texture = GUIImageHandler.GetTextureIdentFromFile(imageFilePath, suffix);

            // build memory image
            Image memoryImage = null;

            if (mainOverlay != MainOverlayImage.None || ratingOverlay != RatingOverlayImage.None)
            {
                memoryImage = GUIImageHandler.DrawOverlayOnPoster(imageFilePath, mainOverlay, ratingOverlay);
                if (memoryImage == null)
                {
                    return;
                }

                // load texture into facade item
                if (GUITextureManager.LoadFromMemory(memoryImage, texture, 0, 0, 0) > 0)
                {
                    ThumbnailImage = texture;
                    IconImage      = texture;
                    IconImageBig   = texture;
                }
            }
            else
            {
                ThumbnailImage = imageFilePath;
                IconImage      = imageFilePath;
                IconImageBig   = imageFilePath;
            }

            // if selected and is current window force an update of thumbnail
            this.UpdateItemIfSelected((int)TraktGUIWindows.RelatedShows, ItemId);
        }
Пример #4
0
        /// <summary>
        /// Loads an Image from memory into a facade item
        /// </summary>
        /// <param name="imageFilePath">Filename of image</param>
        protected void SetImageToGui(string imageFilePath)
        {
            if (string.IsNullOrEmpty(imageFilePath))
            {
                return;
            }

            // determine the overlay to add to poster
            var movie       = TVTag as TraktMovie;
            var mainOverlay = MainOverlayImage.None;

            // don't show watchlist overlay in personal watchlist window
            if (WindowID == (int)TraktGUIWindows.WatchedListMovies)
            {
                if ((GUIWatchListMovies.CurrentUser != TraktSettings.Username) && movie.InWatchList)
                {
                    mainOverlay = MainOverlayImage.Watchlist;
                }
                else if (movie.Watched)
                {
                    mainOverlay = MainOverlayImage.Seenit;
                }
            }
            else
            {
                if (movie.InWatchList)
                {
                    mainOverlay = MainOverlayImage.Watchlist;
                }
                else if (movie.Watched)
                {
                    mainOverlay = MainOverlayImage.Seenit;
                }
            }

            // add additional overlay if applicable
            if (movie.InCollection)
            {
                mainOverlay |= MainOverlayImage.Library;
            }

            RatingOverlayImage ratingOverlay = GUIImageHandler.GetRatingOverlay(movie.RatingAdvanced);

            // get a reference to a MediaPortal Texture Identifier
            string suffix  = mainOverlay.ToString().Replace(", ", string.Empty) + Enum.GetName(typeof(RatingOverlayImage), ratingOverlay);
            string texture = GUIImageHandler.GetTextureIdentFromFile(imageFilePath, suffix);

            // build memory image
            Image memoryImage = null;

            if (mainOverlay != MainOverlayImage.None || ratingOverlay != RatingOverlayImage.None)
            {
                memoryImage = GUIImageHandler.DrawOverlayOnPoster(imageFilePath, mainOverlay, ratingOverlay);
                if (memoryImage == null)
                {
                    return;
                }

                // load texture into facade item
                if (GUITextureManager.LoadFromMemory(memoryImage, texture, 0, 0, 0) > 0)
                {
                    ThumbnailImage = texture;
                    IconImage      = texture;
                    IconImageBig   = texture;
                }
            }
            else
            {
                ThumbnailImage = imageFilePath;
                IconImage      = imageFilePath;
                IconImageBig   = imageFilePath;
            }

            // if selected and is current window force an update of thumbnail
            this.UpdateItemIfSelected(WindowID, ItemId);
        }
Пример #5
0
        protected void SetImageToGui(string imageFilePath, Size size)
        {
            if (string.IsNullOrEmpty(imageFilePath))
            {
                return;
            }

            // determine the overlay to add to poster
            var mainOverlay   = MainOverlayImage.None;
            var ratingOverlay = RatingOverlayImage.None;

            if (TVTag is TraktUserListItem)
            {
                var listItem = TVTag as TraktUserListItem;
                if (listItem == null)
                {
                    return;
                }

                if (listItem.InWatchList)
                {
                    mainOverlay = MainOverlayImage.Watchlist;
                }
                else if (listItem.Watched)
                {
                    mainOverlay = MainOverlayImage.Seenit;
                }

                // add additional overlay if applicable
                if (listItem.InCollection)
                {
                    mainOverlay |= MainOverlayImage.Library;
                }

                ratingOverlay = GUIImageHandler.GetRatingOverlay(listItem.RatingAdvanced);
            }
            else if (TVTag is TraktActivity.Activity)
            {
                var activity = TVTag as TraktActivity.Activity;
                if (activity == null)
                {
                    return;
                }

                var movie = activity.Movie;
                var show  = activity.Show;

                if (movie != null && movie.InWatchList)
                {
                    mainOverlay = MainOverlayImage.Watchlist;
                }
                else if (show != null && show.InWatchList)
                {
                    mainOverlay = MainOverlayImage.Watchlist;
                }
                else if (movie != null && movie.Watched)
                {
                    mainOverlay = MainOverlayImage.Seenit;
                }

                // add additional overlay if applicable
                if (movie != null && movie.InCollection)
                {
                    mainOverlay |= MainOverlayImage.Library;
                }

                if (movie != null)
                {
                    ratingOverlay = GUIImageHandler.GetRatingOverlay(movie.RatingAdvanced);
                }
                else
                {
                    ratingOverlay = GUIImageHandler.GetRatingOverlay(show.RatingAdvanced);
                }
            }

            // get a reference to a MediaPortal Texture Identifier
            string suffix  = mainOverlay.ToString().Replace(", ", string.Empty) + Enum.GetName(typeof(RatingOverlayImage), ratingOverlay);
            string texture = GUIImageHandler.GetTextureIdentFromFile(imageFilePath, suffix);

            // build memory image
            Image memoryImage = null;

            if (mainOverlay != MainOverlayImage.None || ratingOverlay != RatingOverlayImage.None)
            {
                memoryImage = GUIImageHandler.DrawOverlayOnPoster(imageFilePath, mainOverlay, ratingOverlay, size);
                if (memoryImage == null)
                {
                    return;
                }

                // load texture into facade item
                if (GUITextureManager.LoadFromMemory(memoryImage, texture, 0, 0, 0) > 0)
                {
                    ThumbnailImage = texture;
                    IconImage      = texture;
                    IconImageBig   = texture;
                }
            }
            else
            {
                ThumbnailImage = imageFilePath;
                IconImage      = imageFilePath;
                IconImageBig   = imageFilePath;
            }

            // if selected and is current window force an update of thumbnail
            this.UpdateItemIfSelected(WindowID, ItemId);
        }
Пример #6
0
        /// <summary>
        /// Loads an Image from memory into a facade item
        /// </summary>
        /// <param name="imageFilePath">Filename of image</param>
        protected void SetImageToGui(string imageFilePath)
        {
            if (string.IsNullOrEmpty(imageFilePath))
            {
                return;
            }

            // determine the overlay to add to poster
            TraktEpisode     episode     = TVTag as TraktEpisode;
            MainOverlayImage mainOverlay = MainOverlayImage.None;

            if (episode.InWatchList)
            {
                mainOverlay = MainOverlayImage.Watchlist;
            }
            else if (episode.Watched)
            {
                mainOverlay = MainOverlayImage.Seenit;
            }

            // add additional overlay if applicable
            if (episode.InCollection)
            {
                mainOverlay |= MainOverlayImage.Library;
            }

            RatingOverlayImage ratingOverlay = GUIImageHandler.GetRatingOverlay(episode.RatingAdvanced);

            // get a reference to a MediaPortal Texture Identifier
            string suffix  = mainOverlay.ToString().Replace(", ", string.Empty) + Enum.GetName(typeof(RatingOverlayImage), ratingOverlay);
            string texture = GUIImageHandler.GetTextureIdentFromFile(imageFilePath, suffix);

            // build memory image, resize thumbnail incase its a fanart
            Image memoryImage = null;

            if (mainOverlay != MainOverlayImage.None || ratingOverlay != RatingOverlayImage.None)
            {
                memoryImage = GUIImageHandler.DrawOverlayOnEpisodeThumb(imageFilePath, mainOverlay, ratingOverlay, new Size(400, 225));
                if (memoryImage == null)
                {
                    return;
                }

                // load texture into facade item
                if (GUITextureManager.LoadFromMemory(memoryImage, texture, 0, 0, 0) > 0)
                {
                    ThumbnailImage = texture;
                    IconImage      = texture;
                    IconImageBig   = texture;
                }
            }
            else
            {
                ThumbnailImage = imageFilePath;
                IconImage      = imageFilePath;
                IconImageBig   = imageFilePath;
            }

            // if selected and is current window force an update of thumbnail
            this.UpdateItemIfSelected((int)TraktGUIWindows.SeasonEpisodes, ItemId);
        }