Esempio n. 1
0
        public async void SetWindow(CoreWindow window)
        {
            this.window = window;

            if (!Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 2))
            {
                var dialog = new MessageDialog("This version of Windows does not support the Composition APIs.");
                await dialog.ShowAsync();

                CoreApplication.Exit();
                return;
            }

            window.PointerPressed += Window_PointerPressed;

            CoreApplication.Suspending += CoreApplication_Suspending;
            DisplayInformation.DisplayContentsInvalidated += DisplayInformation_DisplayContentsInvalidated;

            compositor = new Compositor();

            CreateDevice();

            drawingSurfaceRenderer = new DrawingSurfaceRenderer(compositor, compositionGraphicsDevice);

            swapChainRenderer = new SwapChainRenderer(compositor);
            swapChainRenderer.SetDevice(device, new Size(window.Bounds.Width, window.Bounds.Height));

            drawingSurfaceRenderer.Visual.Offset = new Vector3(-drawingSurfaceRenderer.Size.ToVector2(), 0);
            swapChainRenderer.Visual.Offset      = new Vector3((float)window.Bounds.Width, (float)window.Bounds.Height, 0);

            var rootVisual = compositor.CreateContainerVisual();

            rootVisual.Children.InsertAtTop(swapChainRenderer.Visual);
            rootVisual.Children.InsertAtTop(drawingSurfaceRenderer.Visual);

            compositor.CreateTargetForCurrentView().Root = rootVisual;

            var ignoredTask = UpdateVisualsLoop();
        }
Esempio n. 2
0
        public async void SetWindow(CoreWindow window)
        {
            this.window = window;

            if (!Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 2))
            {
                var dialog = new MessageDialog("This version of Windows does not support the Composition APIs.");
                await dialog.ShowAsync();
                CoreApplication.Exit();
                return;
            }

            window.PointerPressed += Window_PointerPressed;

            CoreApplication.Suspending += CoreApplication_Suspending;
            DisplayInformation.DisplayContentsInvalidated += DisplayInformation_DisplayContentsInvalidated;

            compositor = new Compositor();

            CreateDevice();

            drawingSurfaceRenderer = new DrawingSurfaceRenderer(compositor, compositionGraphicsDevice);

            swapChainRenderer = new SwapChainRenderer(compositor);
            swapChainRenderer.SetDevice(device, new Size(window.Bounds.Width, window.Bounds.Height));

            drawingSurfaceRenderer.Visual.Offset = new Vector3(-drawingSurfaceRenderer.Size.ToVector2(), 0);
            swapChainRenderer.Visual.Offset = new Vector3((float)window.Bounds.Width, (float)window.Bounds.Height, 0);
            
            var rootVisual = compositor.CreateContainerVisual();
            rootVisual.Children.InsertAtTop(swapChainRenderer.Visual);
            rootVisual.Children.InsertAtTop(drawingSurfaceRenderer.Visual);

            compositor.CreateTargetForCurrentView().Root = rootVisual;

            var ignoredTask = UpdateVisualsLoop();
        }