/// <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 main overlay to add to poster
            TraktMovie       movie       = TVTag as TraktMovie;
            MainOverlayImage mainOverlay = MainOverlayImage.None;

            if (movie.InWatchList)
            {
                mainOverlay = MainOverlayImage.Watchlist;
            }
            if (movie.InCollection)
            {
                mainOverlay |= MainOverlayImage.Library;
            }

            // we never show rating movies in Recommendations
            RatingOverlayImage ratingOverlay = RatingOverlayImage.None;

            // 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)
            {
                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.RecommendationsMovies, ItemId);
        }
Ejemplo n.º 2
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
            TraktWatchListShow show        = TVTag as TraktWatchListShow;
            MainOverlayImage   mainOverlay = MainOverlayImage.None;

            // only show watch list icon if viewing someone elses watch list
            if ((GUIWatchListShows.CurrentUser != TraktSettings.Username) && show.InWatchList)
            {
                mainOverlay = MainOverlayImage.Watchlist;
            }

            RatingOverlayImage 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);
                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.WatchedListShows, ItemId);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Draws a trakt overlay, library/seen/watchlist icon on a poster
        /// This is done in memory and wont touch the existing file
        /// </summary>
        /// <param name="origPoster">Filename of the untouched poster</param>
        /// <param name="type">Overlay type enum</param>
        /// <param name="size">Size of returned image</param>
        /// <returns>An image with overlay added to poster</returns>
        public static Bitmap DrawOverlayOnPoster(string origPoster, MainOverlayImage mainType, RatingOverlayImage ratingType, Size size)
        {
            Image image = GUIImageHandler.LoadImage(origPoster);
            if (image == null) return null;

            Bitmap poster = size.IsEmpty ? new Bitmap(image) : new Bitmap(image, size);
            Graphics gph = Graphics.FromImage(poster);

            string mainOverlayImage = TraktHelper.GetThemedSkinFile(SkinThemeType.Image, string.Format("trakt{0}.png", mainType.ToString().Replace(", ", string.Empty)));
            if (mainType != MainOverlayImage.None && File.Exists(mainOverlayImage))
            {
                Bitmap newPoster = new Bitmap(GUIImageHandler.LoadImage(mainOverlayImage));
                gph.DrawImage(newPoster, TraktSkinSettings.PosterMainOverlayPosX, TraktSkinSettings.PosterMainOverlayPosY);
            }

            string ratingOverlayImage = TraktHelper.GetThemedSkinFile(SkinThemeType.Image, string.Format("trakt{0}.png", Enum.GetName(typeof(RatingOverlayImage), ratingType)));
            if (ratingType != RatingOverlayImage.None && File.Exists(ratingOverlayImage))
            {
                Bitmap newPoster = new Bitmap(GUIImageHandler.LoadImage(ratingOverlayImage));
                gph.DrawImage(newPoster, TraktSkinSettings.PosterRatingOverlayPosX, TraktSkinSettings.PosterRatingOverlayPosY);
            }

            gph.Dispose();
            return poster;
        }
        /// <summary>
        /// Draws a trakt overlay, library/seen/watchlist icon on a episode thumb
        /// This is done in memory and wont touch the existing file
        /// </summary>
        /// <param name="origThumb">Filename of the untouched episode thumb</param>
        /// <param name="type">Overlay type enum</param>
        /// <param name="size">Size of returned image</param>
        /// <returns>An image with overlay added to episode thumb</returns>
        public static Bitmap DrawOverlayOnEpisodeThumb(string origThumb, MainOverlayImage mainType, RatingOverlayImage ratingType, Size size)
        {
            Image image = GUIImageHandler.LoadImage(origThumb);
            if (image == null) return null;

            Bitmap thumb = new Bitmap(image, size);
            Graphics gph = Graphics.FromImage(thumb);

            string mainOverlayImage = GUIGraphicsContext.Skin + string.Format(@"\Media\trakt{0}.png", mainType.ToString().Replace(", ", string.Empty));
            if (mainType != MainOverlayImage.None && File.Exists(mainOverlayImage))
            {
                Bitmap newThumb = new Bitmap(GUIImageHandler.LoadImage(mainOverlayImage));
                gph.DrawImage(newThumb, TraktSkinSettings.EpisodeThumbMainOverlayPosX, TraktSkinSettings.EpisodeThumbMainOverlayPosY);
            }

            string ratingOverlayImage = GUIGraphicsContext.Skin + string.Format(@"\Media\trakt{0}.png", Enum.GetName(typeof(RatingOverlayImage), ratingType));
            if (ratingType != RatingOverlayImage.None && File.Exists(ratingOverlayImage))
            {
                Bitmap newThumb = new Bitmap(GUIImageHandler.LoadImage(ratingOverlayImage));
                gph.DrawImage(newThumb, TraktSkinSettings.EpisodeThumbRatingOverlayPosX, TraktSkinSettings.EpisodeThumbRatingOverlayPosY);
            }

            gph.Dispose();
            return thumb;
        }
Ejemplo n.º 5
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;
            }

            if (Show == null || Episode == null)
            {
                return;
            }

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

            // don't show watchlist overlay in personal watchlist window
            if (WindowID == (int)TraktGUIWindows.WatchedListEpisodes)
            {
                if ((GUIWatchListEpisodes.CurrentUser != TraktSettings.Username) && Episode.IsWatchlisted())
                {
                    mainOverlay = MainOverlayImage.Watchlist;
                }
                else if (Episode.IsWatched(Show))
                {
                    mainOverlay = MainOverlayImage.Seenit;
                }
            }
            else
            {
                if (Episode.IsWatchlisted())
                {
                    mainOverlay = MainOverlayImage.Watchlist;
                }
                else if (Episode.IsWatched(Show))
                {
                    mainOverlay = MainOverlayImage.Seenit;
                }
            }

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

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

            // 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 in case 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(WindowID, ItemId);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Draws a trakt overlay, library/seen/watchlist icon on a episode thumb
        /// This is done in memory and wont touch the existing file
        /// </summary>
        /// <param name="origThumb">Filename of the untouched episode thumb</param>
        /// <param name="type">Overlay type enum</param>
        /// <param name="size">Size of returned image</param>
        /// <returns>An image with overlay added to episode thumb</returns>
        public static Bitmap DrawOverlayOnEpisodeThumb(string origThumb, MainOverlayImage mainType, RatingOverlayImage ratingType, Size size)
        {
            Image image = GUIImageHandler.LoadImage(origThumb);

            if (image == null)
            {
                return(null);
            }

            Bitmap   thumb = new Bitmap(image, size);
            Graphics gph   = Graphics.FromImage(thumb);

            string mainOverlayImage = GUIGraphicsContext.Skin + string.Format(@"\Media\trakt{0}.png", mainType.ToString().Replace(", ", string.Empty));

            if (mainType != MainOverlayImage.None && File.Exists(mainOverlayImage))
            {
                Bitmap newThumb = new Bitmap(GUIImageHandler.LoadImage(mainOverlayImage));
                gph.DrawImage(newThumb, TraktSkinSettings.EpisodeThumbMainOverlayPosX, TraktSkinSettings.EpisodeThumbMainOverlayPosY);
            }

            string ratingOverlayImage = GUIGraphicsContext.Skin + string.Format(@"\Media\trakt{0}.png", Enum.GetName(typeof(RatingOverlayImage), ratingType));

            if (ratingType != RatingOverlayImage.None && File.Exists(ratingOverlayImage))
            {
                Bitmap newThumb = new Bitmap(GUIImageHandler.LoadImage(ratingOverlayImage));
                gph.DrawImage(newThumb, TraktSkinSettings.EpisodeThumbRatingOverlayPosX, TraktSkinSettings.EpisodeThumbRatingOverlayPosY);
            }

            gph.Dispose();
            return(thumb);
        }
Ejemplo n.º 7
0
        protected void SetImageToGui(string imageFilePath, Size size)
        {
            if (string.IsNullOrEmpty(imageFilePath))
            {
                return;
            }

            // determine the overlay to add to poster
            TraktUserListItem listItem    = TVTag as TraktUserListItem;
            MainOverlayImage  mainOverlay = MainOverlayImage.None;

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

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

            RatingOverlayImage ratingOverlay = GUIImageHandler.GetRatingOverlay(listItem.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((int)TraktGUIWindows.ListItems, ItemId);
        }
        /// <summary>
        /// Draws a trakt overlay, library/seen/watchlist icon on a poster
        /// This is done in memory and wont touch the existing file
        /// </summary>
        /// <param name="origPoster">Filename of the untouched poster</param>
        /// <param name="type">Overlay type enum</param>
        /// <param name="size">Size of returned image</param>
        /// <returns>An image with overlay added to poster</returns>
        public static Bitmap DrawOverlayOnPoster(string origPoster, MainOverlayImage mainType, RatingOverlayImage ratingType, Size size)
        {
            Image image = GUIImageHandler.LoadImage(origPoster);

            if (image == null)
            {
                return(null);
            }

            Bitmap   poster = size.IsEmpty ? new Bitmap(image) : new Bitmap(image, size);
            Graphics gph    = Graphics.FromImage(poster);

            string mainOverlayImage = TraktHelper.GetThemedSkinFile(SkinThemeType.Image, string.Format("trakt{0}.png", mainType.ToString().Replace(", ", string.Empty)));

            if (mainType != MainOverlayImage.None && File.Exists(mainOverlayImage))
            {
                Bitmap newPoster = new Bitmap(GUIImageHandler.LoadImage(mainOverlayImage));
                gph.DrawImage(newPoster, TraktSkinSettings.PosterMainOverlayPosX, TraktSkinSettings.PosterMainOverlayPosY);
            }

            string ratingOverlayImage = TraktHelper.GetThemedSkinFile(SkinThemeType.Image, string.Format("trakt{0}.png", Enum.GetName(typeof(RatingOverlayImage), ratingType)));

            if (ratingType != RatingOverlayImage.None && File.Exists(ratingOverlayImage))
            {
                Bitmap newPoster = new Bitmap(GUIImageHandler.LoadImage(ratingOverlayImage));
                gph.DrawImage(newPoster, TraktSkinSettings.PosterRatingOverlayPosX, TraktSkinSettings.PosterRatingOverlayPosY);
            }

            gph.Dispose();
            return(poster);
        }