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(); }