/// <summary> /// Handles the DeviceReplaced event /// </summary> /// <param name="sender">Sender</param> /// <param name="e">object</param> private void OnDeviceReplaced(object sender, object e) { // Recreate the GaussianMaskSurface _surface = _generator.CreateDrawingSurface(_surfaceLock, Size); // Redraw the mask surface RedrawSurface(); }
/// <summary> /// Handles the DeviceReplaced event /// </summary> /// <param name="sender">Sender</param> /// <param name="e">object</param> private async void OnDeviceReplaced(object sender, object e) { // Recreate the ImageSurface _surface = _generator.CreateDrawingSurface(_surfaceLock, Size); // Reload the SurfaceImage await RedrawSurfaceImageInternalAsync(); }
/// <summary> /// Handles the DeviceReplaced event /// </summary> /// <param name="sender">Sender</param> /// <param name="e">object</param> private void OnDeviceReplaced(object sender, object e) { // Recreate the GeometrySurface _surface = _generator.CreateDrawingSurface(_surfaceLock, Size); // Redraw the GeometrySurface RedrawSurfaceInternal(); }
/// <summary> /// Constructor /// </summary> /// <param name="generator">ICompositionMaskGeneratorInternal object</param> /// <param name="surfaceBitmap">The CanvasBitmap whose alpha values will be used to create the Mask.</param> /// <param name="size">Size of the IImageMaskSurface</param> /// <param name="padding">The padding between the IImageMaskSurface outer bounds and the bounds of the area where /// the mask, created from the loaded image's alpha values, should be rendered.</param> /// <param name="options">The image's resize, alignment options and blur radius in the allocated space.</param> public ImageMaskSurface(ICompositionGeneratorInternal generator, CanvasBitmap surfaceBitmap, Size size, Thickness padding, ImageSurfaceOptions options) { _generator = generator ?? throw new ArgumentNullException(nameof(generator), "CompositionGenerator cannot be null!"); _surfaceLock = new object(); // Create the Surface of the IImageMaskSurface _surface = _generator.CreateDrawingSurface(_surfaceLock, size); Size = _surface?.Size ?? new Size(0, 0); _uri = null; _raiseLoadCompletedEvent = false; if (surfaceBitmap != null) { _canvasBitmap = CanvasBitmap.CreateFromBytes(_generator.Device, surfaceBitmap.GetPixelBytes(), (int)surfaceBitmap.Bounds.Width, (int)surfaceBitmap.Bounds.Height, surfaceBitmap.Format); } // Set the mask padding MaskPadding = padding; // Set the image options Options = options; // Subscribe to DeviceReplaced event _generator.DeviceReplaced += OnDeviceReplaced; }
/// <summary> /// Constructor /// </summary> /// <param name="generator">ICompositionMaskGeneratorInternal object</param> /// <param name="size">Size of the MaskSurface</param> /// <param name="geometry">Geometry of the MaskSurface</param> /// <param name="offset">The offset from the top left corner of the ICompositionSurface where /// the Geometry is rendered.</param> public MaskSurface(ICompositionGeneratorInternal generator, Size size, CanvasGeometry geometry, Vector2 offset) { _generator = generator ?? throw new ArgumentNullException(nameof(generator), "CompositionGenerator cannot be null!"); _surfaceLock = new object(); Geometry = geometry; Offset = offset; // Create Mask Surface _surface = _generator.CreateDrawingSurface(_surfaceLock, size); // Set the size Size = _surface?.Size ?? new Size(0, 0); // Subscribe to DeviceReplaced event _generator.DeviceReplaced += OnDeviceReplaced; }
/// <summary> /// Constructor /// </summary> /// <param name="generator">ICompositionMaskGeneratorInternal object</param> /// <param name="uri">Uri of the image to be loaded onto the IImageSurface.</param> /// <param name="size">Size of the IImageSurface</param> /// <param name="options">The image's resize and alignment options in the allocated space.</param> public ImageSurface(ICompositionGeneratorInternal generator, Uri uri, Size size, ImageSurfaceOptions options) { _generator = generator ?? throw new ArgumentNullException(nameof(generator), "CompositionGenerator cannot be null!"); _surfaceLock = new object(); // Create the Surface of the IImageSurface _surface = _generator.CreateDrawingSurface(_surfaceLock, size); Size = _surface?.Size ?? new Size(0, 0); _uri = uri; _raiseLoadCompletedEvent = _uri != null; _canvasBitmap = null; // Set the image options Options = options; // Subscribe to DeviceReplaced event _generator.DeviceReplaced += OnDeviceReplaced; Status = ImageSurfaceLoadStatus.None; }
/// <summary> /// Constructor /// </summary> /// <param name="generator">ICompositionMaskGeneratorInternal object</param> /// <param name="size">Size of the GeometrySurface</param> /// <param name="geometry">Geometry of the GeometrySurface</param> /// <param name="stroke">Stroke for the geometry</param> /// <param name="fill">Brush to fill the geometry</param> /// <param name="backgroundBrush">Brush to fill the GeometrySurface background surface which is /// not covered by the geometry</param> public GeometrySurface(ICompositionGeneratorInternal generator, Size size, CanvasGeometry geometry, ICanvasStroke stroke, ICanvasBrush fill, ICanvasBrush backgroundBrush) { _generator = generator ?? throw new ArgumentNullException(nameof(generator), "CompositionGenerator cannot be null!"); _surfaceLock = new object(); _geometry = geometry; _stroke = stroke; _fill = fill; _backgroundBrush = backgroundBrush; // Create GeometrySurface _surface = _generator.CreateDrawingSurface(_surfaceLock, size); // Set the size Size = _surface?.Size ?? new Size(0, 0); // Subscribe to DeviceReplaced event _generator.DeviceReplaced += OnDeviceReplaced; }
/// <summary> /// Constructor /// </summary> /// <param name="generator">ICompositionMaskGeneratorInternal object</param> /// <param name="size">Size of the mask</param> /// <param name="geometry">Geometry of the mask</param> /// <param name="color">Fill color of the geometry</param> public CompositionMask(ICompositionGeneratorInternal generator, Size size, CanvasGeometry geometry, Color color) { if (generator == null) { throw new ArgumentNullException(nameof(generator), "CompositionGenerator cannot be null!"); } _generator = generator; _surfaceLock = new object(); _geometry = geometry; // Create Mask Surface _surface = _generator.CreateDrawingSurface(_surfaceLock, size); // Set the size Size = _surface?.Size ?? new Size(0, 0); _brush = new CanvasSolidColorBrush(_generator.Device, color); // Subscribe to DeviceReplaced event _generator.DeviceReplaced += OnDeviceReplaced; }
/// <summary> /// Constructor /// </summary> /// <param name="generator">ICompositionMaskGeneratorInternal object</param> /// <param name="uri">Uri of the image to be loaded onto the SurfaceImage.</param> /// <param name="size">Size of the SurfaceImage</param> /// <param name="options">Describes the image's resize and alignment options in the allocated space.</param> public CompositionSurfaceImage(ICompositionGeneratorInternal generator, Uri uri, Size size, CompositionSurfaceImageOptions options) { if (generator == null) { throw new ArgumentNullException(nameof(generator), "CompositionGenerator cannot be null!"); } _generator = generator; _surfaceLock = new object(); // Create the Surface of the SurfaceImage _surface = _generator.CreateDrawingSurface(_surfaceLock, size); Size = _surface?.Size ?? new Size(0, 0); _uri = uri; _canvasBitmap = null; // Set the image options Options = options; // Subscribe to DeviceReplaced event _generator.DeviceReplaced += OnDeviceReplaced; }
/// <summary> /// Constructor /// </summary> /// <param name="generator">ICompositionMaskGeneratorInternal object</param> /// <param name="size">Size of the MaskSurface</param> /// <param name="geometry">Geometry of the MaskSurface</param> public MaskSurface(ICompositionGeneratorInternal generator, Size size, CanvasGeometry geometry) { if (generator == null) throw new ArgumentNullException(nameof(generator), "CompositionGenerator cannot be null!"); _generator = generator; _surfaceLock = new object(); _geometry = geometry; // Create Mask Surface _surface = _generator.CreateDrawingSurface(_surfaceLock, size); // Set the size Size = _surface?.Size ?? new Size(0, 0); // Subscribe to DeviceReplaced event _generator.DeviceReplaced += OnDeviceReplaced; }
/// <summary> /// Constructor /// </summary> /// <param name="generator">ICompositionMaskGeneratorInternal object</param> /// <param name="uri">Uri of the image to be loaded onto the SurfaceImage.</param> /// <param name="size">Size of the SurfaceImage</param> /// <param name="options">Describes the image's resize and alignment options in the allocated space.</param> public ImageSurface(ICompositionGeneratorInternal generator, Uri uri, Size size, ImageSurfaceOptions options) { if (generator == null) throw new ArgumentNullException(nameof(generator), "CompositionGenerator cannot be null!"); _generator = generator; _surfaceLock = new object(); // Create the Surface of the SurfaceImage _surface = _generator.CreateDrawingSurface(_surfaceLock, size); Size = _surface?.Size ?? new Size(0, 0); _uri = uri; _canvasBitmap = null; // Set the image options Options = options; // Subscribe to DeviceReplaced event _generator.DeviceReplaced += OnDeviceReplaced; }
/// <summary> /// Constructor /// </summary> /// <param name="generator">ICompositionMaskGeneratorInternal object</param> /// <param name="size">Size of the GeometrySurface</param> /// <param name="geometry">Geometry of the GeometrySurface</param> /// <param name="foregroundColor">Fill color of the geometry</param> /// <param name="backgroundColor">Brush to fill the GeometrySurface background surface which is /// not covered by the geometry</param> public GeometrySurface(ICompositionGeneratorInternal generator, Size size, CanvasGeometry geometry, Color foregroundColor, Color backgroundColor) { if (generator == null) throw new ArgumentNullException(nameof(generator), "CompositionGenerator cannot be null!"); _generator = generator; _surfaceLock = new object(); _geometry = geometry; _foregroundBrush = new CanvasSolidColorBrush(_generator.Device, foregroundColor); _backgroundBrush = new CanvasSolidColorBrush(_generator.Device, backgroundColor); // Create GeometrySurface _surface = _generator.CreateDrawingSurface(_surfaceLock, size); // Set the size Size = _surface?.Size ?? new Size(0, 0); // Subscribe to DeviceReplaced event _generator.DeviceReplaced += OnDeviceReplaced; }