Beispiel #1
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            if (double.IsNaN(ActualWidth) || double.IsNaN(ActualHeight))
            {
                return;
            }

            if (!isRenderingNeeded && oldActualWidth == ActualWidth && oldActualHeight == ActualHeight)
            {
                return;
            }

            //Size has changed. Recreate all Visuals
            oldActualWidth    = ActualWidth;
            oldActualHeight   = ActualHeight;
            isRenderingNeeded = false;

            Visuals.Clear();
            Visuals.Add(crerateBackGroundVisual());
            foreach (Renderer renderer in renderers)
            {
                //////var xGridLineRenderer = renderer as XGridLineRenderer;
                //////if (xGridLineRenderer!=null) {
                //////  if (double.IsNaN(xGridLineRenderer.MinDisplayValueY) || double.IsNaN(xGridLineRenderer.MaxDisplayValueY)){
                //////    xGridLineRenderer.SetDisplayValueRangeY(xGridLineRenderer.YLegendScroller.MinDisplayValue, xGridLineRenderer.YLegendScroller.MaxDisplayValue);
                //////  }
                //////}
                Visuals.Add(renderer.CreateVisual(ActualWidth, ActualHeight));
            }
            TraceWpf.Line("PlotArea.OnRender: " + renderers.Count + " Renderer Visuals recreated");
        }
Beispiel #2
0
        /// <inheritdoc/>
        protected override Size MeasureCore(Size constraint)
        {
            // Remove all visual children
            Visuals.Clear();

            // Measure the visible lines, starting at the first visible line from the scroll position
            double ypos = 0.0, xwidth = 0.0;
            var    partial_offset = (double?)null;
            var    ofs            = TextView.ScrollOffset;

            for (var doc_line = TextView.FirstVisibleLine(ofs.Y); doc_line != null; doc_line = doc_line.NextLine)
            {
                // Get/Create the visual line
                var vis_line = TextView.VisualLine(doc_line);
                vis_line.EnsureTextLines(constraint);
                vis_line.YPos = ofs.Y + ypos;

                // Record the partial offset of the first line
                partial_offset ??= vis_line.YPos - ofs.Y;                // todo

                // Record the width of the line
                xwidth = Math.Max(xwidth, vis_line.LineWidth);

                // Increment the y position by the line height
                ypos += vis_line.LineHeight;

                // Add the line as a visual child of the view
                Visuals.Add(vis_line.Graphics);
            }
            InvalidateArrange();

            // Record the partial line offset
            PartialLineOffset = partial_offset ?? 0.0;

            // Grow the document area a bit
            const bool AllowScrollBelowDocument = false;             //todo: option

            xwidth += AdditionalHorizontalScrollAmount;
            ypos   += AllowScrollBelowDocument && !double.IsInfinity(constraint.Height) ? Math.Min(0, constraint.Height - TextView.DefaultLineHeight) : 0.0;

            // Return the desired size
            return(new Size(
                       Math.Min(constraint.Width, xwidth),
                       Math.Min(constraint.Height, ypos)));
        }