예제 #1
0
        internal void OnPaint(RectangleF dirtyRect)
        {
            if (viewModel == null)
            {
                return;
            }

            var perfCountersWriter = drawingPerfCounters.GetWriter(
                atMostOncePer: TimeSpan.FromMilliseconds(500));

            using (perfCountersWriter.IncrementTicks(controlPaintTimeCounter)) {
                if (!perfCountersWriter.IsNull)
                {
                    perfCountersWriter.Increment(controlPaintWidthCounter, (long)scrollClientAreaSize.Width);
                    perfCountersWriter.Increment(controlPaintHeightCounter, (long)scrollClientAreaSize.Height);
                }

                graphicsForMeasurment.SetCurrentContext();
                using (var g = new LJD.Graphics()) {
                    g.ConfigureProfiling(this.graphicsCounters, perfCountersWriter);
                    g.EnableTextAntialiasing(false);

                    viewDrawing.PaintControl(g, dirtyRect.ToRectangle(), isFocused, out var _);

                    int maxRight = Math.Max(viewDrawing.MeasureView(), (int)scrollClientAreaSize.Width);
                    if (maxRight > viewWidth || maxRight < 2 * viewWidth / 3)
                    {
                        viewWidth = maxRight;
                        UpdateInnerViewSize();
                    }
                }
            }
            if (!perfCountersWriter.IsNull)
            {
                drawingPerfCounters.Report();
                drawingPerfCounters.ResetAll();
            }
        }