예제 #1
0
        void Canvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            mainDeviceResources.InitMessage();

            switch (CurrentOutput)
            {
            case OutputMode.CanvasControl:
                DrawToOutput(mainDeviceResources, args.DrawingSession);
                break;

            case OutputMode.CanvasImageBrush:
                DrawViaImageBrush(args.DrawingSession);
                break;

            case OutputMode.CanvasImageSource:
                DrawToImageSource(args.DrawingSession);
                break;

            case OutputMode.CanvasSwapChain:
                DrawToSwapChain();
                break;
            }

            // Show or hide overlay controls to fit the current mode.
            imageControl.Visibility    = (CurrentOutput == OutputMode.CanvasImageSource)     ? Visibility.Visible : Visibility.Collapsed;
            swapChainPanel.Visibility  = (CurrentOutput == OutputMode.CanvasSwapChain)       ? Visibility.Visible : Visibility.Collapsed;
            animatedControl.Visibility = (CurrentOutput == OutputMode.CanvasAnimatedControl) ? Visibility.Visible : Visibility.Collapsed;
            animatedControl.Paused     = (CurrentOutput != OutputMode.CanvasAnimatedControl);

            // Update the info text.
            textBlock.Text = mainDeviceResources.GetFinalMessage();
        }
예제 #2
0
        void AnimatedCanvas_Draw(ICanvasAnimatedControl sender, CanvasAnimatedDrawEventArgs args)
        {
            animatedDeviceResources.InitMessage();

            DrawToOutput(animatedDeviceResources, args.DrawingSession);

            // Update the info text.
            var message = animatedDeviceResources.GetFinalMessage();

            var task = RunOnUIThread(() => textBlock.Text = message);
        }
예제 #3
0
        void Canvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            mainDeviceResources.InitMessage();

            IAsyncAction pendingDrawTask = null;

            switch (CurrentOutput)
            {
            case OutputMode.CanvasControl:
                DrawToOutput(mainDeviceResources, args.DrawingSession);
                break;

            case OutputMode.CanvasImageBrush:
                DrawViaImageBrush(args.DrawingSession);
                break;

            case OutputMode.CanvasImageSource:
                pendingDrawTask = RunOnUIThread(DrawToImageSource);
                break;

            case OutputMode.CanvasSwapChain:
                DrawToSwapChain();
                break;

            case OutputMode.CanvasVirtualControl:
                pendingDrawTask = RunOnUIThread(DrawToVirtualControl);
                break;

            case OutputMode.CanvasVirtualImageSource:
                pendingDrawTask = RunOnUIThread(DrawToVirtualImageSource);
                break;
            }

            // Show or hide overlay controls to fit the current mode.
            imageControl.Visibility        = (CurrentOutput == OutputMode.CanvasImageSource)        ? Visibility.Visible : Visibility.Collapsed;
            swapChainPanel.Visibility      = (CurrentOutput == OutputMode.CanvasSwapChain)          ? Visibility.Visible : Visibility.Collapsed;
            virtualControl.Visibility      = (CurrentOutput == OutputMode.CanvasVirtualControl)     ? Visibility.Visible : Visibility.Collapsed;
            virtualImageControl.Visibility = (CurrentOutput == OutputMode.CanvasVirtualImageSource) ? Visibility.Visible : Visibility.Collapsed;
            animatedControl.Visibility     = (CurrentOutput == OutputMode.CanvasAnimatedControl)    ? Visibility.Visible : Visibility.Collapsed;
            animatedControl.Paused         = (CurrentOutput != OutputMode.CanvasAnimatedControl);

            // Update the info text.
            DispatchedHandler updateText = () => textBlock.Text = mainDeviceResources.GetFinalMessage();

            if (pendingDrawTask == null)
            {
                updateText();
            }
            else
            {
                pendingDrawTask.AsTask().ContinueWith(task => RunOnUIThread(updateText));
            }
        }
예제 #4
0
        void AnimatedCanvas_Draw(ICanvasAnimatedControl sender, CanvasAnimatedDrawEventArgs args)
        {
            animatedDeviceResources.InitMessage();

            DrawToOutput(animatedDeviceResources, args.DrawingSession);

            // Update the info text.
            var message = animatedDeviceResources.GetFinalMessage();

            var task = textBlock.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                textBlock.Text = message;
            });
        }