/// <summary> /// Opens from splash screen. /// </summary> /// <param name="page">The page.</param> /// <param name="imageBounds">The image bounds.</param> /// <param name="backgroundColor">Color of the background.</param> /// <param name="imageUri">The URI of the image.</param> public static void OpenFromSplashScreen(this Page page, Rect imageBounds, Color backgroundColor, Uri imageUri) { page.Loaded += Page_Loaded; // Initialize the surface loader SurfaceLoader.Initialize(ElementCompositionPreview.GetElementVisual(page).Compositor); // Show the custome splash screen ShowImage(page, imageBounds, imageUri, backgroundColor); }
public CompositionImage() { this.DefaultStyleKey = typeof(CompositionImage); this.Background = new SolidColorBrush(Colors.Transparent); this._stretchMode = CompositionStretch.Uniform; this.Loading += CompImage_Loading; this.Unloaded += CompImage_Unloaded; this.SizeChanged += CompImage_SizeChanged; _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor; // Intialize the statics as needed if (!_staticsInitialized) { _defaultPlaceholderBrush = _compositor.CreateColorBrush(Colors.DarkGray); TimeSpan duration = TimeSpan.FromMilliseconds(1000); _fadeOutAnimation = _compositor.CreateScalarKeyFrameAnimation(); _fadeOutAnimation.InsertKeyFrame(0, 1); _fadeOutAnimation.InsertKeyFrame(1, 0); _fadeOutAnimation.Duration = duration; _scaleAnimation = _compositor.CreateVector2KeyFrameAnimation(); _scaleAnimation.InsertKeyFrame(0, new Vector2(1.25f, 1.25f)); _scaleAnimation.InsertKeyFrame(1, new Vector2(1, 1)); _scaleAnimation.Duration = duration; _staticsInitialized = true; } // Initialize the surface loader if needed if (!SurfaceLoader.IsInitialized) { SurfaceLoader.Initialize(ElementCompositionPreview.GetElementVisual(this).Compositor); } _placeholderDelay = TimeSpan.FromMilliseconds(50); _surfaceBrush = _compositor.CreateSurfaceBrush(null); }