private void Update(int session, Background background, bool dark) { if (BackgroundEquals(_oldBackground, background) && _oldDark == dark) { return; } _oldBackground = background; _oldDark = dark; if (background == null) { UpdateBlurred(false); Background = null; _colorBackground.Opacity = 1; if (SettingsService.Current.Appearance.IsLightTheme()) { _colorBackground.Fill = new TiledBrush { Source = new Uri("ms-appx:///Assets/Images/DefaultBackground.theme-light.png") }; } else { _colorBackground.Fill = new TiledBrush { Source = new Uri("ms-appx:///Assets/Images/DefaultBackground.theme-dark.png") }; } } else if (background.Type is BackgroundTypeFill typeFill) { UpdateBlurred(false); Background = typeFill.ToBrush(); _colorBackground.Opacity = 1; _colorBackground.Fill = null; } else if (background.Type is BackgroundTypePattern typePattern) { UpdateBlurred(false); Background = typePattern.ToBrush(); _colorBackground.Opacity = typePattern.Intensity / 100d; var document = background.Document.DocumentValue; if (document.Local.IsDownloadingCompleted) { if (string.Equals(background.Document.MimeType, "application/x-tgwallpattern", StringComparison.OrdinalIgnoreCase)) { _colorBackground.Fill = new TiledBrush { SvgSource = PlaceholderHelper.GetVectorSurface(null, document, typePattern.GetForeground()) }; } else { _colorBackground.Fill = new ImageBrush { ImageSource = new BitmapImage(new Uri("file:///" + document.Local.Path)), AlignmentX = AlignmentX.Center, AlignmentY = AlignmentY.Center, Stretch = Stretch.UniformToFill }; } } } else if (background.Type is BackgroundTypeWallpaper typeWallpaper) { UpdateBlurred(typeWallpaper.IsBlurred); Background = null; _colorBackground.Opacity = 1; var document = background.Document.DocumentValue; if (document.Local.IsDownloadingCompleted) { _colorBackground.Fill = new ImageBrush { ImageSource = new BitmapImage(new Uri("file:///" + document.Local.Path)), AlignmentX = AlignmentX.Center, AlignmentY = AlignmentY.Center, Stretch = Stretch.UniformToFill }; } } }