Пример #1
0
 void host_SizeChanged(object sender, SizeChangedEventArgs e)
 {
     if (renderTarget != null)
     {
         // Resize the render targrt to the actual host size
         renderTarget.Resize(new SizeU((uint)(host.ActualWidth), (uint)(host.ActualHeight)));
     }
     InvalidateVisual();
 }
Пример #2
0
 void renderControl_SizeChanged(object sender, EventArgs e)
 {
     if (renderTarget != null)
     {
         // Resize the render targrt to the actual host size
         SizeU size = new SizeU((uint)renderControl.ClientSize.Width, (uint)renderControl.ClientSize.Height);
         renderTarget.Resize(size);
     }
 }
Пример #3
0
        void host_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            if (renderTarget != null)
            {
                // Resize the render targrt to the actual host size
                renderTarget.Resize(new SizeU((uint)(host.ActualWidth), (uint)(host.ActualHeight)));

                // Resize the text layout max width and height as well
                textLayout.MaxWidth  = (float)host.ActualWidth;
                textLayout.MaxHeight = (float)host.ActualHeight;
            }

            InvalidateVisual();
        }
Пример #4
0
 protected override void OnResize(EventArgs e)
 {
     lock (renderSyncObject)
     {
         if (RenderTarget != null)
         {
             // Resize the render targrt to the actual host size
             var size = new SizeU((uint)ClientSize.Width, (uint)ClientSize.Height);
             if (hwndRenderTarget != null)
             {
                 hwndRenderTarget.Resize(size); //need to resize hwndRenderTarget to make its size same as the window's size
             }
             if (renderMode == RenderModes.BitmapRenderTargetOnPaint)
             {
                 bitmapRenderTarget.Dispose();
                 bitmapRenderTarget = dcRenderTarget.CreateCompatibleRenderTarget(CompatibleRenderTargetOptions.GdiCompatible, new Microsoft.WindowsAPICodePack.DirectX.Direct2D1.SizeF(ClientSize.Width, ClientSize.Height));
                 bitmap             = null; //the bitmap created in dc render target can't be used in hwnd render target
                 foreach (var shape in drawingShapes)
                 {
                     shape.Bitmap       = Bitmap;
                     shape.RenderTarget = RenderTarget;
                 }
                 RefreshAll();
             }
             else if (renderMode == RenderModes.BitmapRenderTargetRealTime)
             {
                 Debug.Assert(hwndRenderTarget != null);//this should never be null considering the above
                 bitmapRenderTarget.Dispose();
                 bitmapRenderTarget = hwndRenderTarget.CreateCompatibleRenderTarget(CompatibleRenderTargetOptions.GdiCompatible, new Microsoft.WindowsAPICodePack.DirectX.Direct2D1.SizeF(ClientSize.Width, ClientSize.Height));
                 bitmap             = null; //the bitmap created in dc render target can't be used in hwnd render target
                 foreach (var shape in drawingShapes)
                 {
                     shape.Bitmap       = Bitmap;
                     shape.RenderTarget = RenderTarget;
                 }
                 RefreshAll();
             }
         }
     }
     base.OnResize(e);
 }