コード例 #1
0
        public FanartContainer(ImageEntityType imageType, object poster)
        {
            ImageType    = imageType;
            FanartObject = poster;

            switch (ImageType)
            {
            case ImageEntityType.TvDB_FanArt:
                VM_TvDB_ImageFanart tvFanart = (VM_TvDB_ImageFanart)FanartObject;
                IsImageEnabled = tvFanart.Enabled == 1;
                IsImageDefault = tvFanart.IsImageDefault;
                FanartSource   = "TvDB";
                break;

            case ImageEntityType.MovieDB_FanArt:
                VM_MovieDB_Fanart movieFanart = (VM_MovieDB_Fanart)FanartObject;
                IsImageEnabled = movieFanart.Enabled == 1;
                IsImageDefault = movieFanart.IsImageDefault;
                FanartSource   = "MovieDB";
                break;

            case ImageEntityType.Trakt_Fanart:
                VM_Trakt_ImageFanart traktFanart = (VM_Trakt_ImageFanart)FanartObject;
                IsImageEnabled = traktFanart.Enabled == 1;
                IsImageDefault = traktFanart.IsImageDefault;
                FanartSource   = "Trakt";
                break;
            }
        }
コード例 #2
0
        public void DownloadTvDBFanart(VM_TvDB_ImageFanart fanart, bool forceDownload)
        {
            if (string.IsNullOrEmpty(fanart.BannerPath))
            {
                return;
            }

            try
            {
                ImageDownloadRequest req = new ImageDownloadRequest(ImageEntityType.TvDB_FanArt, fanart, forceDownload);

                // check if this file has already been downloaded and exists
                if (!req.ForceDownload)
                {
                    // check to make sure the file actually exists
                    if (!File.Exists(fanart.FullImagePath) || !File.Exists(fanart.FullThumbnailPath))
                    {
                        imagesToDownload.Enqueue(req);
                        OnQueueUpdateEvent(new QueueUpdateEventArgs(QueueCount));
                        return;
                    }

                    // the file exists so don't download it again
                    return;
                }

                imagesToDownload.Enqueue(req);
                OnQueueUpdateEvent(new QueueUpdateEventArgs(QueueCount));
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
コード例 #3
0
        private string GetEntityID(ImageDownloadRequest req)
        {
            switch (req.ImageType)
            {
            case ImageEntityType.AniDB_Cover:

                VM_AniDB_Anime anime = req.ImageData as VM_AniDB_Anime;
                return(anime?.AnimeID.ToString());

            case ImageEntityType.TvDB_Cover:

                VM_TvDB_ImagePoster poster = req.ImageData as VM_TvDB_ImagePoster;
                return(poster?.TvDB_ImagePosterID.ToString());

            case ImageEntityType.TvDB_Banner:

                VM_TvDB_ImageWideBanner banner = req.ImageData as VM_TvDB_ImageWideBanner;
                return(banner?.TvDB_ImageWideBannerID.ToString());

            case ImageEntityType.TvDB_Episode:

                VM_TvDB_Episode episode = req.ImageData as VM_TvDB_Episode;
                return(episode?.TvDB_EpisodeID.ToString());

            case ImageEntityType.TvDB_FanArt:

                VM_TvDB_ImageFanart fanart = req.ImageData as VM_TvDB_ImageFanart;
                return(fanart?.TvDB_ImageFanartID.ToString());

            case ImageEntityType.MovieDB_Poster:

                VM_MovieDB_Poster moviePoster = req.ImageData as VM_MovieDB_Poster;
                return(moviePoster?.MovieDB_PosterID.ToString());

            case ImageEntityType.MovieDB_FanArt:

                VM_MovieDB_Fanart movieFanart = req.ImageData as VM_MovieDB_Fanart;
                return(movieFanart?.MovieDB_FanartID.ToString());

            case ImageEntityType.AniDB_Character:

                VM_AniDB_Character chr = req.ImageData as VM_AniDB_Character;
                return(chr?.AniDB_CharacterID.ToString());

            case ImageEntityType.AniDB_Creator:

                VM_AniDB_Seiyuu cre = req.ImageData as VM_AniDB_Seiyuu;
                return(cre?.AniDB_SeiyuuID.ToString());

            default:
                return(string.Empty);
            }
        }
コード例 #4
0
        void setFanartPreviewBackground(FanartContainer fanart)
        {
            if (fanart == null)
            {
                ClearGUIProperty(GuiProperty.FanArt_SelectedFanartResolution);
                ClearGUIProperty(GuiProperty.FanArt_SelectedPreview);
                ClearGUIProperty(GuiProperty.FanArt_SelectedFanartIsDisabled);
                ClearGUIProperty(GuiProperty.FanArt_SelectedFanartIsDefault);
                ClearGUIProperty(GuiProperty.FanArt_Source);
                return;
            }

            if (fanart.ImageType == ImageEntityType.TvDB_FanArt)
            {
                VM_TvDB_ImageFanart fanartTvDb = fanart.FanartObject as VM_TvDB_ImageFanart;
                if (fanartTvDb != null)
                {
                    SetGUIProperty(GuiProperty.FanArt_SelectedFanartResolution, fanartTvDb.BannerType2);
                }
                else
                {
                    ClearGUIProperty(GuiProperty.FanArt_SelectedFanartResolution);
                }
            }
            else
            {
                ClearGUIProperty(GuiProperty.FanArt_SelectedFanartResolution);
            }

            SetGUIProperty(GuiProperty.FanArt_SelectedFanartIsDisabled, fanart.IsImageEnabled ? Translation.No : Translation.Yes);
            SetGUIProperty(GuiProperty.FanArt_SelectedFanartIsDefault, fanart.IsImageDefault ? Translation.Yes : Translation.No);
            SetGUIProperty(GuiProperty.FanArt_Source, fanart.FanartSource);

            string preview;

            if (File.Exists(fanart.FullImagePath))
            {
                // Ensure Fanart on Disk is valid as well
                ImageAllocator.LoadImageFastFromFile(fanart.FullImagePath);
                // Should be safe to assign fullsize fanart if available
                preview = ImageAllocator.GetOtherImage(fanart.FullImagePath, default(Size), false);
            }
            else
            {
                preview = m_Facade.SelectedListItem.IconImageBig;
            }

            SetGUIProperty(GuiProperty.FanArt_SelectedPreview, preview);
        }
コード例 #5
0
        public static void SetDefaultFanart(bool isDefault, FanartContainer fanart, int animeID)
        {
            if (!VM_ShokoServer.Instance.ServerOnline)
            {
                return;
            }

            try
            {
                switch (fanart.ImageType)
                {
                case ImageEntityType.TvDB_FanArt:
                    VM_TvDB_ImageFanart tvFanart = (VM_TvDB_ImageFanart)fanart.FanartObject;
                    VM_ShokoServer.Instance.ShokoServices.SetDefaultImage(isDefault, animeID,
                                                                          tvFanart.TvDB_ImageFanartID, (int)ImageEntityType.TvDB_FanArt, (int)ImageSizeType.Fanart);
                    tvFanart.IsImageDefault = isDefault;
                    break;

                /*
                 * case ImageEntityType.Trakt_Fanart:
                 * VM_Trakt_ImageFanart traktFanart = (VM_Trakt_ImageFanart) fanart.FanartObject;
                 * VM_ShokoServer.Instance.ShokoServices.SetDefaultImage(isDefault, animeID,
                 *  traktFanart.Trakt_ImageFanartID, (int) ImageEntityType.Trakt_Fanart, (int) ImageSizeType.Fanart);
                 * traktFanart.IsImageDefault = isDefault;
                 * break;
                 */
                case ImageEntityType.MovieDB_FanArt:
                    VM_MovieDB_Fanart movieFanart = (VM_MovieDB_Fanart)fanart.FanartObject;
                    VM_ShokoServer.Instance.ShokoServices.SetDefaultImage(isDefault, animeID,
                                                                          movieFanart.MovieDB_FanartID, (int)ImageEntityType.MovieDB_FanArt, (int)ImageSizeType.Fanart);
                    movieFanart.IsImageDefault = isDefault;
                    break;
                }
                fanart.IsImageDefault = isDefault;
            }
            catch (Exception ex)
            {
                BaseConfig.MyAnimeLog.Write("SetDefaultPoster: " + ex.Message);
            }
        }
コード例 #6
0
        public static void EnableDisableFanart(bool enabled, FanartContainer fanart, int animeID)
        {
            try
            {
                if (!enabled && fanart.IsImageDefault)
                {
                    SetDefaultFanart(false, fanart, animeID);
                }

                switch (fanart.ImageType)
                {
                case ImageEntityType.TvDB_FanArt:
                    VM_TvDB_ImageFanart tvFanart = (VM_TvDB_ImageFanart)fanart.FanartObject;
                    VM_ShokoServer.Instance.ShokoServices.EnableDisableImage(enabled, tvFanart.TvDB_ImageFanartID, (int)ImageEntityType.TvDB_FanArt);
                    tvFanart.Enabled = enabled ? 1 : 0;
                    break;

                /*
                 * case ImageEntityType.Trakt_Fanart:
                 * VM_Trakt_ImageFanart traktFanart = (VM_Trakt_ImageFanart) fanart.FanartObject;
                 * VM_ShokoServer.Instance.ShokoServices.EnableDisableImage(enabled, traktFanart.Trakt_ImageFanartID, (int) ImageEntityType.Trakt_Fanart);
                 * traktFanart.Enabled = enabled ? 1 : 0;
                 * break;
                 */
                case ImageEntityType.MovieDB_FanArt:
                    VM_MovieDB_Fanart movieFanart = (VM_MovieDB_Fanart)fanart.FanartObject;
                    VM_ShokoServer.Instance.ShokoServices.EnableDisableImage(enabled, movieFanart.MovieDB_FanartID, (int)ImageEntityType.MovieDB_FanArt);
                    movieFanart.Enabled = enabled ? 1 : 0;
                    break;
                }
                fanart.IsImageEnabled = enabled;
            }
            catch (Exception ex)
            {
                BaseConfig.MyAnimeLog.Write("SetDefaultPoster: " + ex.Message);
            }
        }
コード例 #7
0
        private string GetFileName(ImageDownloadRequest req, bool thumbNailOnly)
        {
            switch (req.ImageType)
            {
            case ImageEntityType.AniDB_Cover:

                VM_AniDB_Anime anime = req.ImageData as VM_AniDB_Anime;
                return(anime?.PosterPathNoDefaultPlain);

            case ImageEntityType.TvDB_Cover:

                VM_TvDB_ImagePoster poster = req.ImageData as VM_TvDB_ImagePoster;
                return(poster?.FullImagePathPlain);

            case ImageEntityType.TvDB_Banner:

                VM_TvDB_ImageWideBanner banner = req.ImageData as VM_TvDB_ImageWideBanner;
                return(banner?.FullImagePathPlain);

            case ImageEntityType.TvDB_Episode:

                VM_TvDB_Episode episode = req.ImageData as VM_TvDB_Episode;
                return(episode?.FullImagePathPlain);

            case ImageEntityType.TvDB_FanArt:

                VM_TvDB_ImageFanart fanart = req.ImageData as VM_TvDB_ImageFanart;

                if (thumbNailOnly)
                {
                    return(fanart?.FullThumbnailPathPlain);
                }
                else
                {
                    return(fanart?.FullImagePathPlain);
                }

            case ImageEntityType.MovieDB_Poster:

                VM_MovieDB_Poster moviePoster = req.ImageData as VM_MovieDB_Poster;
                return(moviePoster?.FullImagePathPlain);

            case ImageEntityType.MovieDB_FanArt:

                VM_MovieDB_Fanart movieFanart = req.ImageData as VM_MovieDB_Fanart;
                return(movieFanart?.FullImagePathPlain);

            case ImageEntityType.AniDB_Character:

                VM_AniDB_Character chr = req.ImageData as VM_AniDB_Character;
                return(chr?.ImagePathPlain);

            case ImageEntityType.AniDB_Creator:

                VM_AniDB_Seiyuu cre = req.ImageData as VM_AniDB_Seiyuu;
                return(cre?.ImagePathPlain);

            default:
                return(string.Empty);
            }
        }
コード例 #8
0
        private string GetEntityID(ImageDownloadRequest req)
        {
            switch (req.ImageType)
            {
            case ImageEntityType.AniDB_Cover:

                VM_AniDB_Anime anime = req.ImageData as VM_AniDB_Anime;
                return(anime.AnimeID.ToString());

            case ImageEntityType.TvDB_Cover:

                VM_TvDB_ImagePoster poster = req.ImageData as VM_TvDB_ImagePoster;
                return(poster.TvDB_ImagePosterID.ToString());

            case ImageEntityType.TvDB_Banner:

                VM_TvDB_ImageWideBanner banner = req.ImageData as VM_TvDB_ImageWideBanner;
                return(banner.TvDB_ImageWideBannerID.ToString());

            case ImageEntityType.TvDB_Episode:

                VM_TvDB_Episode episode = req.ImageData as VM_TvDB_Episode;
                return(episode.TvDB_EpisodeID.ToString());

            case ImageEntityType.TvDB_FanArt:

                VM_TvDB_ImageFanart fanart = req.ImageData as VM_TvDB_ImageFanart;
                return(fanart.TvDB_ImageFanartID.ToString());

            case ImageEntityType.MovieDB_Poster:

                VM_MovieDB_Poster moviePoster = req.ImageData as VM_MovieDB_Poster;
                return(moviePoster.MovieDB_PosterID.ToString());

            case ImageEntityType.MovieDB_FanArt:

                VM_MovieDB_Fanart movieFanart = req.ImageData as VM_MovieDB_Fanart;
                return(movieFanart.MovieDB_FanartID.ToString());

            case ImageEntityType.Trakt_Poster:

                VM_Trakt_ImagePoster traktPoster = req.ImageData as VM_Trakt_ImagePoster;
                return(traktPoster.Trakt_ImagePosterID.ToString());

            case ImageEntityType.Trakt_Fanart:

                VM_Trakt_ImageFanart trakFanart = req.ImageData as VM_Trakt_ImageFanart;
                return(trakFanart.Trakt_ImageFanartID.ToString());

            case ImageEntityType.Trakt_CommentUser:

                VM_Trakt_CommentUser traktShoutUser = req.ImageData as VM_Trakt_CommentUser;
                return(traktShoutUser.User.Trakt_FriendID.ToString());

            case ImageEntityType.Trakt_Episode:

                VM_Trakt_Episode trakEp = req.ImageData as VM_Trakt_Episode;
                return(trakEp.Trakt_EpisodeID.ToString());

            case ImageEntityType.AniDB_Character:

                VM_AniDB_Character chr = req.ImageData as VM_AniDB_Character;
                return(chr.AniDB_CharacterID.ToString());

            case ImageEntityType.AniDB_Creator:

                VM_AniDB_Seiyuu cre = req.ImageData as VM_AniDB_Seiyuu;
                return(cre.AniDB_SeiyuuID.ToString());

            default:
                return("");
            }
        }