示例#1
0
 public CompositionMaskHelper(Compositor compositor)
 {
     _compositor        = compositor;
     _canvasDevice      = new CanvasDevice();
     _compositionDevice = CanvasComposition.CreateCompositionGraphicsDevice(_compositor, _canvasDevice);
     _surfaceFactory    = SurfaceFactory.CreateFromCompositor(_compositor);
 }
 private static void EnsureSurfaceFactory()
 {
     if (_surfaceFactoryInstance == null)
     {
         _surfaceFactoryInstance = SurfaceFactory.CreateFromCompositor(_compositor);
     }
 }
        public CompositionImage()
        {
            if (_compositor == null)
            {
                _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
            }

            if (_surfaceFactory == null)
            {
                _surfaceFactory = SurfaceFactory.CreateFromCompositor(_compositor);
            }

            InitializeComponent();
            ImageControl.ImageOpened += ImageControlOnImageOpened;
            DataContextChanged       += (sender, args) => Bindings.Update();
        }
        public VisualControl()
        {
            _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
            Visual      = _compositor.CreateSpriteVisual();

            if (_surfaceFactoryInstance == null)
            {
                _surfaceFactoryInstance = SurfaceFactory.CreateFromCompositor(_compositor);
            }

            ElementCompositionPreview.SetElementChildVisual(this, Visual);
            SizeChanged +=
                (sender, args) =>
            {
                Visual.Size = new Vector2((float)args.NewSize.Width, (float)args.NewSize.Height);
            };

            Unloaded += VisualControl_Unloaded;
        }