Beispiel #1
0
        private void SetFanArtType()
        {
            // Applies only to container Items
            NumItems = null;
            PlayableMediaItem playableMediaItem = SelectedItem as PlayableMediaItem;

            if (playableMediaItem != null)
            {
                MediaItem   = playableMediaItem.MediaItem;
                SimpleTitle = playableMediaItem.SimpleTitle;
            }
            else
            {
                MediaItem   = null;
                SimpleTitle = string.Empty;
            }

            SeriesFilterItem series = SelectedItem as SeriesFilterItem;

            if (series != null)
            {
                MediaItem       = series.MediaItem;
                SimpleTitle     = series.SimpleTitle;
                ItemDescription = series.StoryPlot;
                return;
            }
            SeasonFilterItem season = SelectedItem as SeasonFilterItem;

            if (season != null)
            {
                MediaItem       = season.MediaItem;
                SimpleTitle     = season.SimpleTitle;
                ItemDescription = season.StoryPlot;
                return;
            }
            EpisodeItem episode = SelectedItem as EpisodeItem;

            if (episode != null)
            {
                MediaItem       = episode.MediaItem;
                SimpleTitle     = episode.Series;
                ItemDescription = episode.StoryPlot;
                return;
            }
            MovieFilterItem movieCollection = SelectedItem as MovieFilterItem;

            if (movieCollection != null)
            {
                MediaItem       = movieCollection.MediaItem;
                SimpleTitle     = movieCollection.SimpleTitle;
                ItemDescription = null;
                return;
            }
            MovieItem movie = SelectedItem as MovieItem;

            if (movie != null)
            {
                MediaItem       = movie.MediaItem;
                SimpleTitle     = movie.SimpleTitle;
                ItemDescription = movie.StoryPlot;
                return;
            }
            VideoItem video = SelectedItem as VideoItem;

            if (video != null)
            {
                MediaItem       = video.MediaItem;
                SimpleTitle     = video.SimpleTitle;
                ItemDescription = video.StoryPlot;
                return;
            }
            AlbumFilterItem albumItem = SelectedItem as AlbumFilterItem;

            if (albumItem != null)
            {
                MediaItem       = albumItem.MediaItem;
                SimpleTitle     = albumItem.SimpleTitle;
                ItemDescription = albumItem.Description;
                return;
            }
            AudioItem audioItem = SelectedItem as AudioItem;

            if (audioItem != null)
            {
                MediaItem       = audioItem.MediaItem;
                SimpleTitle     = audioItem.SimpleTitle;
                ItemDescription = string.Empty;
                return;
            }
            ActorFilterItem actorItem = SelectedItem as ActorFilterItem;

            if (actorItem != null)
            {
                MediaItem       = actorItem.MediaItem;
                SimpleTitle     = actorItem.SimpleTitle;
                ItemDescription = actorItem.Description;
                return;
            }
            DirectorFilterItem directorItem = SelectedItem as DirectorFilterItem;

            if (directorItem != null)
            {
                MediaItem       = directorItem.MediaItem;
                SimpleTitle     = directorItem.SimpleTitle;
                ItemDescription = directorItem.Description;
            }
            WriterFilterItem writerItem = SelectedItem as WriterFilterItem;

            if (writerItem != null)
            {
                MediaItem       = writerItem.MediaItem;
                SimpleTitle     = writerItem.SimpleTitle;
                ItemDescription = writerItem.Description;
            }
            ArtistFilterItem artisitItem = SelectedItem as ArtistFilterItem;

            if (artisitItem != null)
            {
                MediaItem       = artisitItem.MediaItem;
                SimpleTitle     = artisitItem.SimpleTitle;
                ItemDescription = artisitItem.Description;
            }
            ComposerFilterItem composerItem = SelectedItem as ComposerFilterItem;

            if (composerItem != null)
            {
                MediaItem       = composerItem.MediaItem;
                SimpleTitle     = composerItem.SimpleTitle;
                ItemDescription = composerItem.Description;
            }
            CharacterFilterItem characterItem = SelectedItem as CharacterFilterItem;

            if (characterItem != null)
            {
                MediaItem       = characterItem.MediaItem;
                SimpleTitle     = characterItem.SimpleTitle;
                ItemDescription = string.Empty;
            }
            CompanyFilterItem companyItem = SelectedItem as CompanyFilterItem;

            if (companyItem != null)
            {
                MediaItem       = companyItem.MediaItem;
                SimpleTitle     = companyItem.SimpleTitle;
                ItemDescription = companyItem.Description;
            }
            TVNetworkFilterItem tvNetworkItem = SelectedItem as TVNetworkFilterItem;

            if (tvNetworkItem != null)
            {
                MediaItem       = tvNetworkItem.MediaItem;
                SimpleTitle     = tvNetworkItem.SimpleTitle;
                ItemDescription = tvNetworkItem.Description;
            }
            FilterItem filterItem = SelectedItem as FilterItem;

            if (filterItem != null)
            {
                MediaItem       = filterItem.MediaItem;
                SimpleTitle     = filterItem.SimpleTitle;
                ItemDescription = string.Empty;
                NumItems        = filterItem.NumItems;
                return;
            }
            ContainerItem containerItem = SelectedItem as ContainerItem;

            if (containerItem != null)
            {
                // Morpheus 2017-04-27: setting the media item for containers lead to unintended layout in views
                // MediaItem = containerItem.FirstMediaItem;
                MediaItem = null;
                if (Guid.TryParse(containerItem.Id, out Guid dirId))
                {
                    MediaItem = new MediaItem(dirId);
                }
                SimpleTitle     = containerItem.SimpleTitle;
                ItemDescription = string.Empty;
                NumItems        = containerItem.NumItems;
                return;
            }
            FanArtMediaType = FanArtMediaTypes.Undefined;
            FanArtName      = string.Empty;
            ItemDescription = string.Empty;
        }
        bool IFanartImageSourceProvider.TryCreateFanartImageSource(ListItem listItem, out FanArtImageSource fanartImageSource)
        {
            string fanArtName = GetFanArtName(listItem);

            SeriesFilterItem series = listItem as SeriesFilterItem;

            if (series != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Series,
                    FanArtName      = fanArtName
                };
                return(true);
            }
            SeasonFilterItem season = listItem as SeasonFilterItem;

            if (season != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.SeriesSeason,
                    FanArtName      = fanArtName
                };
                return(true);
            }
            EpisodeItem episode = listItem as EpisodeItem;

            if (episode != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Episode,
                    FanArtName      = fanArtName
                };
                return(true);
            }
            MovieFilterItem movieCollection = listItem as MovieFilterItem;

            if (movieCollection != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.MovieCollection,
                    FanArtName      = fanArtName
                };
                return(true);
            }
            MovieItem movie = listItem as MovieItem;

            if (movie != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Movie,
                    FanArtName      = fanArtName
                };
                return(true);
            }
            VideoItem video = listItem as VideoItem;

            if (video != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Movie,
                    FanArtName      = fanArtName
                };
                return(true);
            }
            AlbumFilterItem albumItem = listItem as AlbumFilterItem;

            if (albumItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Album,
                    FanArtName      = fanArtName
                };
                return(true);
            }
            AudioItem audioItem = listItem as AudioItem;

            if (audioItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Audio,
                    FanArtName      = fanArtName
                };
                return(true);
            }
            ActorFilterItem actorItem = listItem as ActorFilterItem;

            if (actorItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Actor,
                    FanArtName      = fanArtName
                };
                return(true);
            }
            DirectorFilterItem directorItem = listItem as DirectorFilterItem;

            if (directorItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Director,
                    FanArtName      = fanArtName
                };
                return(true);
            }
            WriterFilterItem writerItem = listItem as WriterFilterItem;

            if (writerItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Writer,
                    FanArtName      = fanArtName
                };
                return(true);
            }
            ArtistFilterItem artisitItem = listItem as ArtistFilterItem;

            if (artisitItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Artist,
                    FanArtName      = fanArtName
                };
                return(true);
            }
            ComposerFilterItem composerItem = listItem as ComposerFilterItem;

            if (composerItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Composer,
                    FanArtName      = fanArtName
                };
                return(true);
            }
            CharacterFilterItem characterItem = listItem as CharacterFilterItem;

            if (characterItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Character,
                    FanArtName      = fanArtName
                };
                return(true);
            }
            CompanyFilterItem companyItem = listItem as CompanyFilterItem;

            if (companyItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Company,
                    FanArtName      = fanArtName
                };
                return(true);
            }
            TVNetworkFilterItem tvNetworkItem = listItem as TVNetworkFilterItem;

            if (tvNetworkItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.TVNetwork,
                    FanArtName      = fanArtName
                };
                return(true);
            }
            ImageItem imgItem = listItem as ImageItem;

            if (imgItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Image,
                    FanArtName      = fanArtName
                };
                return(true);
            }
            fanartImageSource = null;
            return(false);
        }
        bool IFanartImageSourceProvider.TryCreateFanartImageSource(ListItem listItem, out FanArtImageSource fanartImageSource)
        {
            SeriesFilterItem series = listItem as SeriesFilterItem;

            if (series != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Series,
                    FanArtName      = series.MediaItem.MediaItemId.ToString()
                };
                return(true);
            }
            SeasonFilterItem season = listItem as SeasonFilterItem;

            if (season != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.SeriesSeason,
                    FanArtName      = season.MediaItem.MediaItemId.ToString()
                };
                return(true);
            }
            EpisodeItem episode = listItem as EpisodeItem;

            if (episode != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Episode,
                    FanArtName      = episode.MediaItem.MediaItemId.ToString()
                };
                return(true);
            }
            MovieFilterItem movieCollection = listItem as MovieFilterItem;

            if (movieCollection != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.MovieCollection,
                    FanArtName      = movieCollection.MediaItem.MediaItemId.ToString()
                };
                return(true);
            }
            MovieItem movie = listItem as MovieItem;

            if (movie != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Movie,
                    // Fanart loading now depends on the MediaItemId to support local fanart
                    FanArtName = movie.MediaItem.MediaItemId.ToString()
                };
                return(true);
            }
            VideoItem video = listItem as VideoItem;

            if (video != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Movie,
                    // Fanart loading now depends on the MediaItemId to support local fanart
                    FanArtName = video.MediaItem.MediaItemId.ToString()
                };
                return(true);
            }
            AlbumFilterItem albumItem = listItem as AlbumFilterItem;

            if (albumItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Album,
                    // Fanart loading now depends on the MediaItemId to support local fanart
                    FanArtName = albumItem.MediaItem.MediaItemId.ToString()
                };
                return(true);
            }
            AudioItem audioItem = listItem as AudioItem;

            if (audioItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Audio,
                    // Fanart loading now depends on the MediaItemId to support local fanart
                    FanArtName = audioItem.MediaItem.MediaItemId.ToString()
                };
                return(true);
            }
            ActorFilterItem actorItem = listItem as ActorFilterItem;

            if (actorItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Actor,
                    // Fanart loading now depends on the MediaItemId to support local fanart
                    FanArtName = actorItem.MediaItem.MediaItemId.ToString()
                };
                return(true);
            }
            DirectorFilterItem directorItem = listItem as DirectorFilterItem;

            if (directorItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Director,
                    // Fanart loading now depends on the MediaItemId to support local fanart
                    FanArtName = directorItem.MediaItem.MediaItemId.ToString()
                };
                return(true);
            }
            WriterFilterItem writerItem = listItem as WriterFilterItem;

            if (writerItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Writer,
                    // Fanart loading now depends on the MediaItemId to support local fanart
                    FanArtName = writerItem.MediaItem.MediaItemId.ToString()
                };
                return(true);
            }
            ArtistFilterItem artisitItem = listItem as ArtistFilterItem;

            if (artisitItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Artist,
                    // Fanart loading now depends on the MediaItemId to support local fanart
                    FanArtName = artisitItem.MediaItem.MediaItemId.ToString()
                };
                return(true);
            }
            ComposerFilterItem composerItem = listItem as ComposerFilterItem;

            if (composerItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Composer,
                    // Fanart loading now depends on the MediaItemId to support local fanart
                    FanArtName = composerItem.MediaItem.MediaItemId.ToString()
                };
                return(true);
            }
            CharacterFilterItem characterItem = listItem as CharacterFilterItem;

            if (characterItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Character,
                    // Fanart loading now depends on the MediaItemId to support local fanart
                    FanArtName = characterItem.MediaItem.MediaItemId.ToString()
                };
                return(true);
            }
            CompanyFilterItem companyItem = listItem as CompanyFilterItem;

            if (companyItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Company,
                    // Fanart loading now depends on the MediaItemId to support local fanart
                    FanArtName = companyItem.MediaItem.MediaItemId.ToString()
                };
                return(true);
            }
            TVNetworkFilterItem tvNetworkItem = listItem as TVNetworkFilterItem;

            if (tvNetworkItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.TVNetwork,
                    // Fanart loading now depends on the MediaItemId to support local fanart
                    FanArtName = tvNetworkItem.MediaItem.MediaItemId.ToString()
                };
                return(true);
            }
            ImageItem imgItem = listItem as ImageItem;

            if (imgItem != null)
            {
                fanartImageSource = new FanArtImageSource
                {
                    FanArtMediaType = FanArtMediaTypes.Image,
                    // Fanart loading now depends on the MediaItemId to support local fanart
                    FanArtName = imgItem.MediaItem.MediaItemId.ToString()
                };
                return(true);
            }
            fanartImageSource = null;
            return(false);
        }