コード例 #1
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            d2dDragHandler = new DragHandler(d2dCanvas) { CursorOver = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.SizeAll, 1) };

            d2dBrush = new ImageBrush();
            d2dRectangle.Fill = d2dBrush;

            effectRenderer = new EffectRenderer(d2dRectangle, root);
            
            deviceManager = new DeviceManager();
            
            int pixelWidth = (int)(d2dRectangle.Width * DisplayProperties.LogicalDpi / 96.0);
            int pixelHeight = (int)(d2dRectangle.Height * DisplayProperties.LogicalDpi / 96.0);

            d2dTarget = new SurfaceImageSourceTarget(pixelWidth, pixelHeight);
            d2dBrush.ImageSource = d2dTarget.ImageSource;
            d2dTarget.OnRender += effectRenderer.Render;
            
            deviceManager.OnInitialize += d2dTarget.Initialize;
            deviceManager.OnInitialize += effectRenderer.Initialize;
            deviceManager.Initialize(DisplayProperties.LogicalDpi);

            var window = CoreWindow.GetForCurrentThread();
            if (window.Visible)
                BindRenderingEvents();

            window.VisibilityChanged += (_, args) =>
                                        {
                                            if(args.Visible)
                                                BindRenderingEvents();
                                            else
                                                UnbindRenderingEvents();
                                        };
        }
コード例 #2
0
ファイル: MP-SIS.xaml.cs プロジェクト: ChaosCom/SharpDX
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            d2dDragHandler = new DragHandler(d2dCanvas) { CursorOver = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.SizeAll, 1) };

            d2dBrush = new ImageBrush();
            d2dRectangle.Fill = d2dBrush;

            effectRenderer = new EffectRenderer(d2dRectangle, root);
            
            deviceManager = new DeviceManager();
            
            int pixelWidth = (int)(d2dRectangle.Width * DisplayProperties.LogicalDpi / 96.0);
            int pixelHeight = (int)(d2dRectangle.Height * DisplayProperties.LogicalDpi / 96.0);

            d2dTarget = new SurfaceImageSourceTarget(pixelWidth, pixelHeight);
            d2dBrush.ImageSource = d2dTarget.ImageSource;
            d2dTarget.OnRender += effectRenderer.Render;
            
            deviceManager.OnInitialize += d2dTarget.Initialize;
            deviceManager.OnInitialize += effectRenderer.Initialize;
            deviceManager.Initialize(DisplayProperties.LogicalDpi);


            // Setup rendering callback
            CompositionTarget.Rendering += CompositionTarget_Rendering;
        }