private void LoadSmallPrimaryImage() { float aspect = primaryImage.Size.Height / (float)primaryImage.Size.Width; float constraintAspect = aspect; if (preferredImageSmallSize.Height > 0 && preferredImageSmallSize.Width > 0) { constraintAspect = preferredImageSmallSize.Height / (float)preferredImageSmallSize.Width; } primaryImageSmall = new AsyncImageLoader( () => baseItem.PrimaryImage, DefaultImage, PrimaryImageChanged); if (aspect == constraintAspect) { smallImageIsDistorted = false; } else { smallImageIsDistorted = Math.Abs(aspect - constraintAspect) < Config.Instance.MaximumAspectRatioDistortion; } if (smallImageIsDistorted) { primaryImageSmall.Size = preferredImageSmallSize; } else { int width = preferredImageSmallSize.Width; int height = preferredImageSmallSize.Height; if (aspect > constraintAspect || width <= 0) { width = (int)((float)height / aspect); } else { height = (int)((float)width * aspect); } primaryImageSmall.Size = new Size(width, height); } FirePropertyChanged("SmallImageIsDistorted"); }
private void getPrimaryBackdropImage() { if (primaryBackdropImage == null) { primaryBackdropImage = backdropImage = new AsyncImageLoader( () => baseItem.PrimaryBackdropImage, null, () => this.FirePropertiesChanged("PrimaryBackdropImage")); backdropImage.LowPriority = true; } }
private void getRandomBackdropImage() { if (Config.Instance.RotateBackdrops && baseItem.BackdropImages.Count > 1) { //start the rotation so we don't get the first one twice GetNextBackDropImage(); } else { //just a single one required if (baseItem.BackdropImages.Count > 0) { backdropImageIndex = randomizer.Next(baseItem.BackdropImages.Count); backdropImage = new AsyncImageLoader( () => baseItem.BackdropImages[backdropImageIndex], null, () => this.FirePropertyChanged("BackdropImage")); backdropImage.LowPriority = true; } } }
private void EnsureSecondaryImageIsSet() { if (secondaryImage == null) { secondaryImage = new AsyncImageLoader( () => baseItem.SecondaryImage, DefaultImage, SecondaryImageChanged); var ignore = secondaryImage.Image; } }
private void EnsureThumbnailImageIsSet() { if (thumbnailImage == null) { thumbnailImage = new AsyncImageLoader( () => baseItem.ThumbnailImage, DefaultImage, ThumbnailImageChanged); var ignore = thumbnailImage.Image; } }
private void EnsureLogoImageIsSet() { if (logoImage == null) { logoImage = new AsyncImageLoader( () => baseItem.LogoImage, DefaultImage, LogoImageChanged); var ignore = logoImage.Image; } }
private void EnsurePrimaryImageIsSet() { if (primaryImage == null) { primaryImage = new AsyncImageLoader( () => baseItem.PrimaryImage, DefaultImage, PrimaryImageChanged); var ignore = primaryImage.Image; } }
private void EnsureDiscImageIsSet() { if (discImage == null) { discImage = new AsyncImageLoader( () => baseItem.DiscImage, DefaultImage, DiscImageChanged); var ignore = discImage.Image; } }
private void EnsureArtImageIsSet() { if (artImage == null) { artImage = new AsyncImageLoader( () => baseItem.ArtImage, DefaultImage, ArtImageChanged); var ignore = artImage.Image; } }
private void EnsureAllBackdropsAreLoaded() { if (backdropImages == null) { backdropImages = new List<AsyncImageLoader>(); Async.Queue("Backdrop Loader", () => { foreach (var image in baseItem.BackdropImages) { // this is really subtle, we need to capture the image otherwise they will all be the same var captureImage = image; var asyncImage = new AsyncImageLoader( () => captureImage, null, () => this.FirePropertiesChanged("BackdropImages", "BackdropImage")); lock (backdropImages) { backdropImages.Add(asyncImage); // trigger a load var ignore = asyncImage.Image; } } }); } }
public void GetNextBackDropImage() { if (!Config.Instance.RotateBackdrops || Application.CurrentInstance.IsPlayingVideo || Application.CurrentInstance.IsExternalWmcApplicationPlaying) return; // only do this if we want to rotate EnsureAllBackdropsAreLoaded(); var images = new List<AsyncImageLoader>(); lock (backdropImages) { images.AddRange(backdropImages); } if (images != null && images.Count > 1) { if (Config.Instance.RandomizeBackdrops) { int lastOne = backdropImageIndex; while (backdropImageIndex == lastOne) { backdropImageIndex = randomizer.Next(images.Count); } } else { backdropImageIndex++; backdropImageIndex = backdropImageIndex % images.Count; } if (images[backdropImageIndex].Image != null) { backdropImage = images[backdropImageIndex]; FirePropertyChanged("BackdropImage"); } } }
public void GetNextBackDropImage() { backdropImageIndex++; EnsureAllBackdropsAreLoaded(); var images = new List<AsyncImageLoader>(); lock (backdropImages) { images.AddRange(backdropImages); } if (images != null && images.Count > 0) { backdropImageIndex = backdropImageIndex % images.Count; if (images[backdropImageIndex].Image != null) { backdropImage = images[backdropImageIndex]; FirePropertyChanged("BackdropImage"); } } }