public void LocalFileTest()
        {
            var image  = Path.Combine(PlaynitePaths.ProgramPath, "Resources", "Images", "applogo.png");
            var result = ImageSourceManager.GetImage(image, false);

            Assert.AreEqual(typeof(BitmapImage), result.GetType());
        }
示例#2
0
        public void TestThatRefreshSourcesUpdatesCorrectlyWhenUsedAtRuntime()
        {
            var fileSystem = new MockFileSystem();

            AddImageConfigToFileSystem(fileSystem, "Testing");

            var manager = new ImageSourceManager(new NullLogger <ImageSourceManager>(), fileSystem);

            AddImageConfigToFileSystem(fileSystem, "Steve");

            Assert.IsTrue(manager.IsInternalImage(new DockerImageId("Testing", "1.0")));
            Assert.IsFalse(manager.IsInternalImage(new DockerImageId("Steve", "1.0")));

            manager.RefreshInternalSources();

            Assert.IsTrue(manager.IsInternalImage(new DockerImageId("Testing", "1.0")));
            Assert.IsTrue(manager.IsInternalImage(new DockerImageId("Steve", "1.0")));

            RemoveImageConfigFromFileSystem(fileSystem, "Testing");

            manager.RefreshInternalSources();

            Assert.IsFalse(manager.IsInternalImage(new DockerImageId("Testing", "1.0")));
            Assert.IsTrue(manager.IsInternalImage(new DockerImageId("Steve", "1.0")));
        }
        public void ResourceTest()
        {
            var image = ImageSourceManager.GetImage("resources:/Resources/Images/icon_dark.png", false);

            Assert.IsNotNull(image);
            Assert.AreNotEqual(DependencyProperty.UnsetValue, image);
        }
示例#4
0
        private static async void BlurSettingChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            var control = (FadeImage)obj;

            if (control.Source == null)
            {
                return;
            }

            var blurAmount  = control.BlurAmount;
            var blurEnabled = control.IsBlurEnabled;
            var highQuality = control.HighQualityBlur;
            var source      = control.Source;
            var image       = await Task.Factory.StartNew(() =>
            {
                if (source is string str)
                {
                    return(ImageSourceManager.GetImage(str, false));
                }
                else if (source is BitmapLoadProperties props)
                {
                    return(ImageSourceManager.GetImage(props.Source, false, props));
                }
                else
                {
                    return(null);
                }
            });

            if (blurEnabled)
            {
                control.ImageHolder.Effect = new BlurEffect()
                {
                    KernelType    = KernelType.Gaussian,
                    Radius        = blurAmount,
                    RenderingBias = highQuality ? RenderingBias.Quality : RenderingBias.Performance
                };
            }
            else
            {
                control.ImageHolder.Effect = null;
            }

            GC.Collect();

            if (control.currentImage == CurrentImage.Image1)
            {
                control.Image1.Source = image;
            }
            else if (control.currentImage == CurrentImage.Image2)
            {
                control.Image2.Source = image;
            }
            else
            {
                control.Image1.Source = image;
                control.currentImage  = CurrentImage.Image1;
            }
        }
        public void WebTest()
        {
            FileSystem.DeleteDirectory(PlaynitePaths.ImagesCachePath);
            var image  = @"http://playnite.link/applogo.png";
            var result = ImageSourceManager.GetImage(image, false);

            Assert.AreEqual(typeof(BitmapImage), result.GetType());
        }
        public MainWindow()
        {
            InitializeComponent();

            facade = new Facade(ImageSourceManager.GetInstance(this),
                                AzureImageState.GetInstance(this),
                                DetectFacesOnImage.GetInstance(this));
        }
示例#7
0
        public void TestThatIsInternalImageWorks()
        {
            var fileSystem = new MockFileSystem();

            AddImageConfigToFileSystem(fileSystem, "Testing");

            var manager = new ImageSourceManager(new NullLogger <ImageSourceManager>(), fileSystem);

            Assert.IsTrue(manager.IsInternalImage(new DockerImageId("Testing", "1.0")));
        }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
            {
                return(DependencyProperty.UnsetValue);
            }

            var image = ImageSourceManager.GetImage((string)value, Cached);

            return(image ?? DependencyProperty.UnsetValue);
        }
        public void DatabaseTest()
        {
            var file = Path.Combine(PlaynitePaths.ProgramPath, "Resources", "Images", "applogo.png");

            using (var temp = TempDirectory.Create())
            {
                var db = new GameDatabase(temp.TempPath);
                db.OpenDatabase();
                var image = db.AddFile("image.png", File.ReadAllBytes(file), Guid.NewGuid());
                ImageSourceManager.SetDatabase(db);
                var result = ImageSourceManager.GetImage(image, false);
                Assert.AreEqual(typeof(BitmapImage), result.GetType());
            }
        }
        public void SetDefaultBackgroundImage()
        {
            if (GameContext.BackgroundImage.IsNullOrEmpty())
            {
                SetBackgroundImage();
            }
            else
            {
                string PathImage = ImageSourceManager.GetImagePath(GameContext.BackgroundImage);
                if (PathImage.IsNullOrEmpty())
                {
                    PathImage = PluginDatabase.PlayniteApi.Database.GetFullFilePath(GameContext.BackgroundImage);
                }

                SetBackgroundImage(PathImage);
            }
        }
示例#11
0
        private static async void BlurSettingChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            var control = (FadeImage)obj;

            if (control.Source.IsNullOrEmpty())
            {
                return;
            }

            var blurAmount  = control.BlurAmount;
            var blurEnabled = control.IsBlurEnabled;
            var source      = control.Source;
            var image       = await Task.Factory.StartNew(() =>
            {
                var tmp = ImageSourceManager.GetImage(source, false);
                if (tmp == null)
                {
                    return(null);
                }

                //if (blurEnabled)
                //{
                //    tmp = new GaussianBlur(tmp.ToBitmap()).Process(blurAmount).ToBitmapImage();
                //}

                return(tmp);
            });

            // GaussianBlur uses quite of lot of memory that's not immediately released.
            GC.Collect();

            if (control.currentImage == CurrentImage.Image1)
            {
                control.Image1.Source = image;
            }
            else if (control.currentImage == CurrentImage.Image2)
            {
                control.Image2.Source = image;
            }
        }
示例#12
0
        private async void LoadNewSource(string newSource, string oldSource)
        {
            var         blurAmount  = BlurAmount;
            var         blurEnabled = IsBlurEnabled;
            BitmapImage image       = null;

            if (!newSource.IsNullOrEmpty())
            {
                image = await Task.Factory.StartNew(() =>
                {
                    var tmp = ImageSourceManager.GetImage(newSource, false);
                    if (tmp == null)
                    {
                        return(null);
                    }

                    //if (blurEnabled)
                    //{
                    //    tmp = new GaussianBlur(tmp.ToBitmap()).Process(blurAmount).ToBitmapImage();

                    //}
                    return(tmp);
                });
            }

            if (blurEnabled)
            {
                // GaussianBlur uses quite of lot of memory that's not immediately released.
                GC.Collect();
            }

            if (image == null)
            {
                if (currentImage == CurrentImage.None)
                {
                    return;
                }

                if (currentImage == CurrentImage.Image1)
                {
                    Image1FadeOut.Begin();
                    BorderDarkenFadeOut.Begin();
                }
                else if (currentImage == CurrentImage.Image2)
                {
                    Image2FadeOut.Begin();
                    BorderDarkenFadeOut.Begin();
                }

                currentImage = CurrentImage.None;
            }
            else
            {
                if (currentImage == CurrentImage.None)
                {
                    Image1FadeOut.Stop();
                    Image1.Source = image;
                    Image1FadeIn.Begin();
                    BorderDarken.Opacity = 1;
                    BorderDarkenFadeOut.Stop();
                    currentImage = CurrentImage.Image1;
                }
                else if (currentImage == CurrentImage.Image1)
                {
                    Image2FadeOut.Stop();
                    Image2.Source = image;
                    Image2FadeIn.Begin();
                    Image1FadeOut.Begin();
                    BorderDarken.Opacity = 1;
                    BorderDarkenFadeOut.Stop();
                    currentImage = CurrentImage.Image2;
                }
                else if (currentImage == CurrentImage.Image2)
                {
                    Image1FadeOut.Stop();
                    Image1.Source = image;
                    Image1FadeIn.Begin();
                    Image2FadeOut.Begin();
                    BorderDarken.Opacity = 1;
                    BorderDarkenFadeOut.Stop();
                    currentImage = CurrentImage.Image1;
                }
            }
        }
示例#13
0
        private List <GameField> GetDisplayDiffFields(Game oldGame, ComparableMetadatGameData newGame)
        {
            var diffFields = new List <GameField>();

            void checkListChanged <T>(List <T> oldData, List <T> newData, GameField field) where T : DatabaseObject
            {
                if (!oldData.HasItems() && newData.HasItems())
                {
                    diffFields.Add(field);
                    return;
                }

                if (newData.HasItems() && oldData.HasItems() && !oldData.Select(a => a.Id).IsListEqual(newData.Select(b => b.Id)))
                {
                    diffFields.Add(field);
                }
            }

            //void checkItemChanged<T>(T source, string other, GameField field) where T : DatabaseObject
            //{
            //    if (!other.IsNullOrEmpty())
            //    {
            //        if (source != null && !string.Equals(source.Name, other, StringComparison.OrdinalIgnoreCase))
            //        {
            //            diffFields.Add(field);
            //        }
            //    }
            //}

            if (!newGame.Name.IsNullOrEmpty())
            {
                if (!oldGame.Name.IsNullOrEmpty() && !string.Equals(oldGame.Name, newGame.Name, StringComparison.OrdinalIgnoreCase))
                {
                    diffFields.Add(GameField.Name);
                }
            }

            if (!newGame.Description.IsNullOrEmpty())
            {
                if (!oldGame.Description.IsNullOrEmpty() && !string.Equals(oldGame.Description, newGame.Description, StringComparison.Ordinal))
                {
                    diffFields.Add(GameField.Description);
                }
            }

            checkListChanged(oldGame.AgeRatings, newGame.AgeRatings, GameField.AgeRatings);
            checkListChanged(oldGame.Regions, newGame.Regions, GameField.Regions);
            checkListChanged(oldGame.Series, newGame.Series, GameField.Series);
            checkListChanged(oldGame.Platforms, newGame.Platforms, GameField.Platforms);
            checkListChanged(oldGame.Developers, newGame.Developers, GameField.Developers);
            checkListChanged(oldGame.Publishers, newGame.Publishers, GameField.Publishers);
            checkListChanged(oldGame.Genres, newGame.Genres, GameField.Genres);
            checkListChanged(oldGame.Tags, newGame.Tags, GameField.Tags);
            checkListChanged(oldGame.Features, newGame.Features, GameField.Features);

            if (newGame.ReleaseDate != null)
            {
                if (oldGame.ReleaseDate != null && oldGame.ReleaseDate != newGame.ReleaseDate)
                {
                    diffFields.Add(GameField.ReleaseDate);
                }
            }

            if (newGame.Links.HasItems())
            {
                if (oldGame.Links.HasItems() && !oldGame.Links.IsListEqualExact(newGame.Links))
                {
                    diffFields.Add(GameField.Links);
                }
            }

            if (newGame.CriticScore != null)
            {
                if (oldGame.CriticScore != null && oldGame.CriticScore != newGame.CriticScore)
                {
                    diffFields.Add(GameField.CriticScore);
                }
            }

            if (newGame.CommunityScore != null)
            {
                if (oldGame.CommunityScore != null && oldGame.CommunityScore != newGame.CommunityScore)
                {
                    diffFields.Add(GameField.CommunityScore);
                }
            }

            if (newGame.Icon != null && !oldGame.Icon.IsNullOrEmpty())
            {
                var newIcon = ProcessMetadataFile(newGame.Icon, tempIconFileName);
                if (newIcon != null)
                {
                    var currentPath = ImageSourceManager.GetImagePath(EditingGame.Icon);
                    if (currentPath.IsNullOrEmpty() ||
                        !File.Exists(currentPath) ||
                        !FileSystem.AreFileContentsEqual(newIcon, currentPath))
                    {
                        newGame.Icon = new MetadataFile(newIcon);
                        diffFields.Add(GameField.Icon);
                    }
                    else
                    {
                        newGame.Icon = null;
                    }
                }
                else
                {
                    newGame.Icon = null;
                }
            }

            if (newGame.CoverImage != null && !oldGame.CoverImage.IsNullOrEmpty())
            {
                var newCover = ProcessMetadataFile(newGame.CoverImage, tempCoverFileName);
                if (newCover != null)
                {
                    var currentPath = ImageSourceManager.GetImagePath(EditingGame.CoverImage);
                    if (currentPath.IsNullOrEmpty() ||
                        !File.Exists(currentPath) ||
                        !FileSystem.AreFileContentsEqual(newCover, currentPath))
                    {
                        newGame.CoverImage = new MetadataFile(newCover);
                        diffFields.Add(GameField.CoverImage);
                    }
                    else
                    {
                        newGame.CoverImage = null;
                    }
                }
                else
                {
                    newGame.CoverImage = null;
                }
            }

            if (newGame.BackgroundImage != null && !oldGame.BackgroundImage.IsNullOrEmpty())
            {
                var newBack = ProcessMetadataFile(newGame.BackgroundImage, tempBackgroundFileName);
                if (newBack != null)
                {
                    var currentPath = ImageSourceManager.GetImagePath(EditingGame.BackgroundImage);
                    if (currentPath.IsNullOrEmpty() ||
                        !File.Exists(currentPath) ||
                        !FileSystem.AreFileContentsEqual(newBack, currentPath))
                    {
                        newGame.BackgroundImage = new MetadataFile(newBack);
                        diffFields.Add(GameField.BackgroundImage);
                    }
                    else
                    {
                        newGame.BackgroundImage = null;
                    }
                }
                else
                {
                    newGame.BackgroundImage = null;
                }
            }

            return(diffFields);
        }
示例#14
0
 public Facade(ImageSourceManager _imageSourceManager, AzureImageState _azureImageState, DetectFacesOnImage _identifyFaces)
 {
     imageSourceManager = _imageSourceManager;
     azureImageState    = _azureImageState;
     identifyFaces      = _identifyFaces;
 }
示例#15
0
 public DockerClientManager(Uri dockerDaemonUri, ILoggerFactory loggerFactory)
 {
     _dockerDaemonUri    = dockerDaemonUri;
     _imageSourceManager = new ImageSourceManager(loggerFactory.CreateLogger <ImageSourceManager>(), new FileSystem());
     _logger             = loggerFactory.CreateLogger <DockerClientManager>();
 }
示例#16
0
        private async void LoadNewSource(string newSource, string oldSource)
        {
            var         blurAmount  = BlurAmount;
            var         blurEnabled = IsBlurEnabled;
            var         highQuality = HighQualityBlur;
            BitmapImage image       = null;

            if (newSource == currentSource)
            {
                return;
            }

            currentSource = newSource;
            if (!newSource.IsNullOrEmpty())
            {
                image = await Task.Factory.StartNew(() =>
                {
                    return(ImageSourceManager.GetImage(newSource, false));
                });
            }

            if (blurEnabled)
            {
                if (ImageHolder.Effect == null)
                {
                    ImageHolder.Effect = new BlurEffect()
                    {
                        KernelType    = KernelType.Gaussian,
                        Radius        = blurAmount,
                        RenderingBias = highQuality ? RenderingBias.Quality : RenderingBias.Performance
                    };
                }
            }
            else
            {
                if (ImageHolder.Effect != null)
                {
                    ImageHolder.Effect = null;
                }
            }

            GC.Collect();

            if (image == null)
            {
                if (currentImage == CurrentImage.None)
                {
                    return;
                }

                if (currentImage == CurrentImage.Image1)
                {
                    Image1FadeOut.Begin();
                    BorderDarkenFadeOut.Begin();
                }
                else if (currentImage == CurrentImage.Image2)
                {
                    Image2FadeOut.Begin();
                    BorderDarkenFadeOut.Begin();
                }

                currentImage = CurrentImage.None;
            }
            else
            {
                if (currentImage == CurrentImage.None)
                {
                    Image1FadeOut.Stop();
                    Image1.Source = image;
                    Image1FadeIn.Begin();
                    BorderDarken.Opacity = 1;
                    BorderDarkenFadeOut.Stop();
                    currentImage = CurrentImage.Image1;
                }
                else if (currentImage == CurrentImage.Image1)
                {
                    Image2FadeOut.Stop();
                    Image2.Source = image;
                    Image2FadeIn.Begin();
                    Image1FadeOut.Begin();
                    BorderDarken.Opacity = 1;
                    BorderDarkenFadeOut.Stop();
                    currentImage = CurrentImage.Image2;
                }
                else if (currentImage == CurrentImage.Image2)
                {
                    Image1FadeOut.Stop();
                    Image1.Source = image;
                    Image1FadeIn.Begin();
                    Image2FadeOut.Begin();
                    BorderDarken.Opacity = 1;
                    BorderDarkenFadeOut.Stop();
                    currentImage = CurrentImage.Image1;
                }
            }
        }
        private List <GameField> GetDisplayDiffFields(Game testGame, GameMetadata metadata)
        {
            var diffFields = new List <GameField>();
            var newInfo    = metadata.GameInfo;

            void checkListChanged <T>(List <T> source, List <string> other, GameField field) where T : DatabaseObject
            {
                if (other.HasNonEmptyItems())
                {
                    if (source.HasItems() && !source.Select(a => a.Name).IsListEqual(other, new GameFieldComparer()))
                    {
                        diffFields.Add(field);
                    }
                }
            }

            void checkItemChanged <T>(T source, string other, GameField field) where T : DatabaseObject
            {
                if (!other.IsNullOrEmpty())
                {
                    if (source != null && !string.Equals(source.Name, other, StringComparison.OrdinalIgnoreCase))
                    {
                        diffFields.Add(field);
                    }
                }
            }

            if (!newInfo.Name.IsNullOrEmpty())
            {
                if (!testGame.Name.IsNullOrEmpty() && !string.Equals(testGame.Name, newInfo.Name, StringComparison.OrdinalIgnoreCase))
                {
                    diffFields.Add(GameField.Name);
                }
            }

            if (!newInfo.Description.IsNullOrEmpty())
            {
                if (!testGame.Description.IsNullOrEmpty() && !string.Equals(testGame.Description, newInfo.Description, StringComparison.Ordinal))
                {
                    diffFields.Add(GameField.Description);
                }
            }

            checkItemChanged(testGame.AgeRating, newInfo.AgeRating, GameField.AgeRating);
            checkItemChanged(testGame.Region, newInfo.Region, GameField.Region);
            checkItemChanged(testGame.Series, newInfo.Series, GameField.Series);
            checkItemChanged(testGame.Platform, newInfo.Platform, GameField.Platform);

            checkListChanged(testGame.Developers, newInfo.Developers, GameField.Developers);
            checkListChanged(testGame.Publishers, newInfo.Publishers, GameField.Publishers);
            checkListChanged(testGame.Genres, newInfo.Genres, GameField.Genres);
            checkListChanged(testGame.Tags, newInfo.Tags, GameField.Tags);
            checkListChanged(testGame.Features, newInfo.Features, GameField.Features);

            if (newInfo.ReleaseDate != null)
            {
                if (testGame.ReleaseDate != null && testGame.ReleaseDate != newInfo.ReleaseDate)
                {
                    diffFields.Add(GameField.ReleaseDate);
                }
            }

            if (newInfo.Links.HasItems())
            {
                if (testGame.Links.HasItems() && !testGame.Links.IsListEqualExact(newInfo.Links))
                {
                    diffFields.Add(GameField.Links);
                }
            }

            if (newInfo.CriticScore != null)
            {
                if (testGame.CriticScore != null && testGame.CriticScore != newInfo.CriticScore)
                {
                    diffFields.Add(GameField.CriticScore);
                }
            }

            if (newInfo.CommunityScore != null)
            {
                if (testGame.CommunityScore != null && testGame.CommunityScore != newInfo.CommunityScore)
                {
                    diffFields.Add(GameField.CommunityScore);
                }
            }

            if (metadata.Icon != null && !testGame.Icon.IsNullOrEmpty())
            {
                var newIcon = ProcessMetadataFile(metadata.Icon, tempIconFileName);
                if (newIcon != null)
                {
                    var currentPath = ImageSourceManager.GetImagePath(EditingGame.Icon);
                    if (currentPath.IsNullOrEmpty() ||
                        !File.Exists(currentPath) ||
                        !FileSystem.AreFileContentsEqual(newIcon, currentPath))
                    {
                        metadata.Icon = new MetadataFile(newIcon);
                        diffFields.Add(GameField.Icon);
                    }
                    else
                    {
                        metadata.Icon = null;
                    }
                }
                else
                {
                    metadata.Icon = null;
                }
            }

            if (metadata.CoverImage != null && !testGame.CoverImage.IsNullOrEmpty())
            {
                var newCover = ProcessMetadataFile(metadata.CoverImage, tempCoverFileName);
                if (newCover != null)
                {
                    var currentPath = ImageSourceManager.GetImagePath(EditingGame.CoverImage);
                    if (currentPath.IsNullOrEmpty() ||
                        !File.Exists(currentPath) ||
                        !FileSystem.AreFileContentsEqual(newCover, currentPath))
                    {
                        metadata.CoverImage = new MetadataFile(newCover);
                        diffFields.Add(GameField.CoverImage);
                    }
                    else
                    {
                        metadata.CoverImage = null;
                    }
                }
                else
                {
                    metadata.CoverImage = null;
                }
            }

            if (metadata.BackgroundImage != null && !testGame.BackgroundImage.IsNullOrEmpty())
            {
                var newBack = ProcessMetadataFile(metadata.BackgroundImage, tempBackgroundFileName);
                if (newBack != null)
                {
                    var currentPath = ImageSourceManager.GetImagePath(EditingGame.BackgroundImage);
                    if (currentPath.IsNullOrEmpty() ||
                        !File.Exists(currentPath) ||
                        !FileSystem.AreFileContentsEqual(newBack, currentPath))
                    {
                        metadata.BackgroundImage = new MetadataFile(newBack);
                        diffFields.Add(GameField.BackgroundImage);
                    }
                    else
                    {
                        metadata.BackgroundImage = null;
                    }
                }
                else
                {
                    metadata.BackgroundImage = null;
                }
            }

            return(diffFields);
        }
示例#18
0
        private async void LoadNewSource(object newSource, object oldSource)
        {
            var         blurAmount  = BlurAmount;
            var         blurEnabled = IsBlurEnabled;
            var         highQuality = HighQualityBlur;
            BitmapImage image       = null;

            if (newSource?.Equals(currentSource) == true)
            {
                return;
            }

            currentSource = newSource;
            if (newSource != null)
            {
                image = await Task.Factory.StartNew(() =>
                {
                    if (newSource is string str)
                    {
                        return(ImageSourceManager.GetImage(str, false));
                    }
                    else if (newSource is BitmapLoadProperties props)
                    {
                        return(ImageSourceManager.GetImage(props.Source, false, props));
                    }
                    else
                    {
                        return(null);
                    }
                });
            }

            if (blurEnabled)
            {
                if (ImageHolder.Effect == null)
                {
                    ImageHolder.Effect = new BlurEffect()
                    {
                        KernelType    = KernelType.Gaussian,
                        Radius        = blurAmount,
                        RenderingBias = highQuality ? RenderingBias.Quality : RenderingBias.Performance
                    };
                }
            }
            else
            {
                if (ImageHolder.Effect != null)
                {
                    ImageHolder.Effect = null;
                }
            }

            if (AnimationEnabled)
            {
                if (image == null)
                {
                    if (currentImage == CurrentImage.None)
                    {
                        return;
                    }

                    if (currentImage == CurrentImage.Image1)
                    {
                        Image1FadeOut.Begin();
                        BorderDarkenFadeOut.Begin();
                    }
                    else if (currentImage == CurrentImage.Image2)
                    {
                        Image2FadeOut.Begin();
                        BorderDarkenFadeOut.Begin();
                    }

                    currentImage = CurrentImage.None;
                }
                else
                {
                    if (currentImage == CurrentImage.None)
                    {
                        Image1FadeOut.Stop();
                        Image1.Source = image;
                        Image1FadeIn.Begin();
                        BorderDarken.Opacity = 1;
                        BorderDarkenFadeOut.Stop();
                        currentImage = CurrentImage.Image1;
                    }
                    else if (currentImage == CurrentImage.Image1)
                    {
                        Image2FadeOut.Stop();
                        Image2.Source = image;
                        Image2FadeIn.Begin();
                        Image1FadeOut.Begin();
                        BorderDarken.Opacity = 1;
                        BorderDarkenFadeOut.Stop();
                        currentImage = CurrentImage.Image2;
                    }
                    else if (currentImage == CurrentImage.Image2)
                    {
                        Image1FadeOut.Stop();
                        Image1.Source = image;
                        Image1FadeIn.Begin();
                        Image2FadeOut.Begin();
                        BorderDarken.Opacity = 1;
                        BorderDarkenFadeOut.Stop();
                        currentImage = CurrentImage.Image1;
                    }
                }
            }
            else
            {
                if (currentImage == CurrentImage.Image1)
                {
                    Image1.Source = image;
                }
                else if (currentImage == CurrentImage.Image2)
                {
                    Image2.Source = image;
                }
                else
                {
                    Image1.Source = image;
                    currentImage  = CurrentImage.Image1;
                }
            }
        }
        public override GameBackgroundImages Get(Guid Id, bool OnlyCache = false, bool Force = false)
        {
            GameBackgroundImages gameBackgroundImages = GetOnlyCache(Id);

            if (gameBackgroundImages == null)
            {
                Game game = PlayniteApi.Database.Games.Get(Id);
                if (game != null)
                {
                    gameBackgroundImages = GetDefault(game);
                    Add(gameBackgroundImages);
                }
                else
                {
                    return(gameBackgroundImages);
                }
            }

            // Check default background
            if (gameBackgroundImages.Items.Find(x => x.IsDefault && !x.IsCover) != null)
            {
                int Index = gameBackgroundImages.Items.FindIndex(x => x.IsDefault && !x.IsCover);
                if (Index != -1)
                {
                    gameBackgroundImages.Items.RemoveAt(Index);
                }
            }
            if (!gameBackgroundImages.BackgroundImage.IsNullOrEmpty() && gameBackgroundImages.Items.Find(x => x.IsDefault && !x.IsCover) == null)
            {
                string PathImage = ImageSourceManager.GetImagePath(gameBackgroundImages.BackgroundImage);
                if (PathImage.IsNullOrEmpty() && !File.Exists(PathImage))
                {
                    PathImage = PlayniteApi.Database.GetFullFilePath(gameBackgroundImages.BackgroundImage);
                }

                gameBackgroundImages.Items.Insert(0, new ItemImage
                {
                    Name      = PathImage,
                    IsCover   = false,
                    IsDefault = true
                });
            }

            // Check default cover
            if (gameBackgroundImages.Items.Find(x => x.IsDefault && x.IsCover) != null)
            {
                int Index = gameBackgroundImages.Items.FindIndex(x => x.IsDefault && x.IsCover);
                if (Index != -1)
                {
                    gameBackgroundImages.Items.RemoveAt(Index);
                }
            }
            if (!gameBackgroundImages.CoverImage.IsNullOrEmpty() && gameBackgroundImages.Items.Find(x => x.IsDefault && x.IsCover) == null)
            {
                string PathImage = ImageSourceManager.GetImagePath(gameBackgroundImages.CoverImage);
                if (PathImage.IsNullOrEmpty() && !File.Exists(PathImage))
                {
                    PathImage = PlayniteApi.Database.GetFullFilePath(gameBackgroundImages.CoverImage);
                }

                gameBackgroundImages.Items.Insert(0, new ItemImage
                {
                    Name      = PathImage,
                    IsCover   = true,
                    IsDefault = true
                });
            }

            return(gameBackgroundImages);
        }