public IList <FanArtImage> GetFanArt(FanArtConstants.FanArtMediaType mediaType, FanArtConstants.FanArtType fanArtType, string name, int maxWidth, int maxHeight, bool singleRandom) { InitProviders(); foreach (IFanArtProvider fanArtProvider in _providerList) { IList <IResourceLocator> fanArtImages; if (fanArtProvider.TryGetFanArt(mediaType, fanArtType, name, maxWidth, maxHeight, singleRandom, out fanArtImages)) { IList <IResourceLocator> result = singleRandom ? GetSingleRandom(fanArtImages) : fanArtImages; return(result.Select(f => FanArtImage.FromResource(f, maxWidth, maxHeight, mediaType, fanArtType, name)).Where(fanArtImage => fanArtImage != null).ToList()); } } foreach (IBinaryFanArtProvider binaryProvider in _providerList.OfType <IBinaryFanArtProvider>()) { if (binaryProvider != null) { IList <FanArtImage> binaryImages; if (binaryProvider.TryGetFanArt(mediaType, fanArtType, name, maxWidth, maxHeight, singleRandom, out binaryImages)) { return(singleRandom ? GetSingleRandom(binaryImages) : binaryImages); } } } return(null); }
public IList <FanArtImage> GetFanArt(string mediaType, string fanArtType, string name, int maxWidth, int maxHeight, bool singleRandom) { InitProviders(); foreach (FanArtProviderSource source in Enum.GetValues(typeof(FanArtProviderSource))) { foreach (IFanArtProvider fanArtProvider in _providerList.Where(p => p.Source == source)) { IList <IResourceLocator> fanArtImages; if (fanArtProvider.TryGetFanArt(mediaType, fanArtType, name, maxWidth, maxHeight, singleRandom, out fanArtImages)) { IList <IResourceLocator> result = singleRandom ? GetSingleRandom(fanArtImages) : fanArtImages; return(result.Select(f => FanArtImage.FromResource(f, maxWidth, maxHeight)).Where(fanArtImage => fanArtImage != null).ToList()); } } foreach (IBinaryFanArtProvider binaryProvider in _providerList.OfType <IBinaryFanArtProvider>().Where(p => p.Source == source)) { if (binaryProvider != null) { IList <FanArtImage> binaryImages; if (binaryProvider.TryGetFanArt(mediaType, fanArtType, name, maxWidth, maxHeight, singleRandom, out binaryImages)) { return(singleRandom ? GetSingleRandom(binaryImages) : binaryImages); } } } } return(null); }
public IList <FanArtImage> GetFanArt(FanArtConstants.FanArtMediaType mediaType, FanArtConstants.FanArtType fanArtType, string name, int maxWidth, int maxHeight, bool singleRandom) { string baseFolder = GetBaseFolder(mediaType, name); // No known series if (baseFolder == null || !Directory.Exists(baseFolder)) { return(null); } string pattern = GetPattern(mediaType, fanArtType); if (string.IsNullOrEmpty(pattern)) { return(null); } DirectoryInfo directoryInfo = new DirectoryInfo(baseFolder); try { List <string> files = directoryInfo.GetFiles(pattern).Select(file => file.FullName).ToList(); List <FanArtImage> fanArtImages = files.Select(f => FanArtImage.FromFile(f, maxWidth, maxHeight)).Where(fanArtImage => fanArtImage != null).ToList(); if (fanArtImages.Count == 0) { return(null); } return(singleRandom ? GetSingleRandom(fanArtImages) : fanArtImages); } catch (DirectoryNotFoundException) { return(null); } }
public IList <FanArtImage> GetFanArt(FanArtConstants.FanArtMediaType mediaType, FanArtConstants.FanArtType fanArtType, string name, int maxWidth, int maxHeight, bool singleRandom) { InitProviders(); foreach (IFanArtProvider fanArtProvider in _providerList) { IList <string> fanArtImages; if (fanArtProvider.TryGetFanArt(mediaType, fanArtType, name, maxWidth, maxHeight, singleRandom, out fanArtImages)) { IList <string> result = singleRandom ? GetSingleRandom(fanArtImages) : fanArtImages; return(result.Select(f => FanArtImage.FromFile(f, maxWidth, maxHeight)).Where(fanArtImage => fanArtImage != null).ToList()); } } return(null); }
protected override object DoDeserializeValue(XmlReader reader, bool isSimpleValue) { ICollection <FanArtImage> result = new List <FanArtImage>(); if (SoapHelper.ReadEmptyStartElement(reader)) // Read start of enclosing element { return(result); } while (reader.NodeType != XmlNodeType.EndElement) { result.Add(FanArtImage.Deserialize(reader)); } reader.ReadEndElement(); // End of enclosing element return(result); }
public override void Allocate() { if (FanArtMediaType == FanArtConstants.FanArtMediaType.Undefined || FanArtType == FanArtConstants.FanArtType.Undefined) { return; } Download_Async(); IList <FanArtImage> possibleSources; lock (_syncObj) possibleSources = _possibleSources; if (possibleSources == null || possibleSources.Count == 0) { return; } if (_texture == null) { FanArtImage image = possibleSources[0]; _texture = ContentManager.Instance.GetTexture(image.BinaryData, image.Name); } if (_texture == null || _texture.IsAllocated) { return; } _texture.Allocate(); if (!_texture.IsAllocated) { return; } _imageContext.Refresh(); FireChanged(); }