protected void SetImageToGui(string imageFilePath)
{
if (string.IsNullOrEmpty(imageFilePath) || Movie == null) return;
// determine the overlay to add to poster
var mainOverlay = MainOverlayImage.None;
// don't show watchlist overlay in personal watchlist window
if (WindowID == (int)TraktGUIWindows.WatchedListMovies)
{
if ((GUIWatchListMovies.CurrentUser != TraktSettings.Username) && Movie.IsWatchlisted())
mainOverlay = MainOverlayImage.Watchlist;
else if (Movie.IsWatched())
mainOverlay = MainOverlayImage.Seenit;
}
else
{
if (Movie.IsWatchlisted())
mainOverlay = MainOverlayImage.Watchlist;
else if (Movie.IsWatched())
mainOverlay = MainOverlayImage.Seenit;
}
// add additional overlay if applicable
if (Movie.IsCollected())
mainOverlay |= MainOverlayImage.Library;
RatingOverlayImage ratingOverlay = GUIImageHandler.GetRatingOverlay(Movie.UserRating());
// 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);
}