예제 #1
0
        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");
        }
예제 #2
0
 private void getPrimaryBackdropImage()
 {
     if (primaryBackdropImage == null)
     {
         primaryBackdropImage = backdropImage = new AsyncImageLoader(
             () => baseItem.PrimaryBackdropImage,
             null,
             () => this.FirePropertiesChanged("PrimaryBackdropImage"));
         backdropImage.LowPriority = true;
     }
 }
예제 #3
0
 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;
         }
     }
 }
예제 #4
0
 private void EnsureSecondaryImageIsSet()
 {
     if (secondaryImage == null)
     {
         secondaryImage = new AsyncImageLoader(
             () => baseItem.SecondaryImage,
             DefaultImage,
             SecondaryImageChanged);
         var ignore = secondaryImage.Image;
     }
 }
예제 #5
0
 private void EnsureThumbnailImageIsSet()
 {
     if (thumbnailImage == null)
     {
         thumbnailImage = new AsyncImageLoader(
             () => baseItem.ThumbnailImage,
             DefaultImage,
             ThumbnailImageChanged);
         var ignore = thumbnailImage.Image;
     }
 }
예제 #6
0
 private void EnsureLogoImageIsSet()
 {
     if (logoImage == null)
     {
         logoImage = new AsyncImageLoader(
             () => baseItem.LogoImage,
             DefaultImage,
             LogoImageChanged);
         var ignore = logoImage.Image;
     }
 }
예제 #7
0
 private void EnsurePrimaryImageIsSet()
 {
     if (primaryImage == null)
     {
         primaryImage = new AsyncImageLoader(
             () => baseItem.PrimaryImage,
             DefaultImage,
             PrimaryImageChanged);
         var ignore = primaryImage.Image;
     }
 }
예제 #8
0
 private void EnsureDiscImageIsSet()
 {
     if (discImage == null)
     {
         discImage = new AsyncImageLoader(
             () => baseItem.DiscImage,
             DefaultImage,
             DiscImageChanged);
         var ignore = discImage.Image;
     }
 }
예제 #9
0
 private void EnsureArtImageIsSet()
 {
     if (artImage == null)
     {
         artImage = new AsyncImageLoader(
             () => baseItem.ArtImage,
             DefaultImage,
             ArtImageChanged);
         var ignore = artImage.Image;
     }
 }
예제 #10
0
        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;
                        }
                    }
                });
            }
        }
예제 #11
0
        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");
                }
            }
        }
예제 #12
0
        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");
                }
            }
        }