Example #1
0
 public static void HandlePaintD2DClipped(EventedWindowCore window, Dx11Component resource,
                                          Action <DeviceContext> handler, ref RawRectangleF clip, RawColor4?clearColorBeforeClip = null)
 {
     resource.EnsureInitialized();
     try
     {
         var context = resource.D2D.Context;
         context.BeginDraw();
         if (clearColorBeforeClip.HasValue)
         {
             context.Clear(clearColorBeforeClip.Value);
         }
         context.PushAxisAlignedClip(clip,
                                     AntialiasMode.Aliased);
         handler(context);
         context.PopAxisAlignedClip();
         context.EndDraw();
         resource.D3D.SwapChain.Present(1, 0);
         window.Validate();
     }
     catch (SharpDXException ex)
     {
         if (!resource.PerformResetOnException(ex))
         {
             throw;
         }
     }
 }
Example #2
0
        protected override void OnDxPaint(Dx11Component resource)
        {
            DeviceContext context = resource.D2D.Context;

            Size clientSize = GetClientSize();

            if (frames % framesPerTick == 0)
            {
                for (int i = 0; i < ticksPerFrame; i++)
                {
                    update |= circuitBoard.Update();
                    performanceMonitor.IncrementTicks();
                }

                if (update)
                {
                    circuitBoard.Image.CopyToBitmap(bitmap);
                    update = false;
                }

                frames = 0;
            }

            frames++;

            context.BeginDraw();
            context.Clear(clearColor);

            context.Transform = transformationMatrix;

            context.DrawBitmap(bitmap, CreateImageRect(bitmap.PixelSize, clientSize), 1f,
                               BitmapInterpolationMode.NearestNeighbor);

            context.Transform = identityMatrix;

            if (performanceMonitor.TryCalculate())
            {
                performaceText =
                    $"{performanceMonitor.FramesPerSecond:F0} FPS | {performanceMonitor.TicksPerSecond:F0} TPS";
            }

            context.DrawText(performaceText, textFormat, new RawRectangleF(0f, 0f, clientSize.Width, clientSize.Height),
                             textBrush);
            context.EndDraw();
            performanceMonitor.IncermentFrames();
        }
Example #3
0
 public static void HandlePaint(EventedWindowCore window, Dx11Component resource,
                                Action <Dx11Component> handler)
 {
     resource.EnsureInitialized();
     try
     {
         handler(resource);
         resource.D3D.SwapChain.Present(1, 0);
         window.Validate();
     }
     catch (SharpDXException ex)
     {
         if (!resource.PerformResetOnException(ex))
         {
             throw;
         }
     }
 }
Example #4
0
 public static void HandlePaintD2D(EventedWindowCore window, Dx11Component resource,
                                   Action <DeviceContext> handler)
 {
     resource.EnsureInitialized();
     try
     {
         var context = resource.D2D.Context;
         context.BeginDraw();
         handler(context);
         context.EndDraw();
         resource.D3D.SwapChain.Present(1, 0);
         window.Validate();
     }
     catch (SharpDXException ex)
     {
         if (!resource.PerformResetOnException(ex))
         {
             throw;
         }
     }
 }
Example #5
0
 public static void HandlePaintD2DClipped(EventedWindowCore window, Dx11Component resource,
                                          Action <DeviceContext> handler, RawRectangleF clip, RawColor4?clearColorBeforeClip = null)
 {
     HandlePaintD2DClipped(window, resource, handler, ref clip, clearColorBeforeClip);
 }
Example #6
0
 protected virtual void OnDxPaint(Dx11Component resource)
 {
 }