Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 37 additions & 22 deletions src/LiveChartsCore/DrawMarginFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,38 +114,53 @@ public abstract class DrawMarginFrame<TSizedGeometry, TDrawingContext> : DrawMar
/// <param name="chart">The chart.</param>
public override void Measure(Chart<TDrawingContext> chart)
{
var drawLocation = chart.DrawMarginLocation;
var drawMarginSize = chart.DrawMarginSize;

if (Fill is not null)
{
Fill.ZIndex = -3;

_fillSizedGeometry ??= new TSizedGeometry();

_fillSizedGeometry.X = drawLocation.X;
_fillSizedGeometry.Y = drawLocation.Y;
_fillSizedGeometry.Width = drawMarginSize.Width;
_fillSizedGeometry.Height = drawMarginSize.Height;

Fill.AddGeometryToPaintTask(chart.Canvas, _fillSizedGeometry);
MeasureFill(chart);
chart.Canvas.AddDrawableTask(Fill);
}

if (Stroke is not null)
{
Stroke.ZIndex = -2;
MeasureStroke(chart);
chart.Canvas.AddDrawableTask(Stroke);
}
}

_strokeSizedGeometry ??= new TSizedGeometry();
/// <summary>
/// Measures the <see cref="DrawMarginFrame{TDrawingContext}.Fill"/> of the draw margin for the specified chart.
/// </summary>
/// <param name="chart">The chart.</param>
protected virtual void MeasureFill(Chart<TDrawingContext> chart)
{
Fill!.ZIndex = -3;

_strokeSizedGeometry.X = drawLocation.X;
_strokeSizedGeometry.Y = drawLocation.Y;
_strokeSizedGeometry.Width = drawMarginSize.Width;
_strokeSizedGeometry.Height = drawMarginSize.Height;
_fillSizedGeometry ??= new TSizedGeometry();

Stroke.AddGeometryToPaintTask(chart.Canvas, _strokeSizedGeometry);
chart.Canvas.AddDrawableTask(Stroke);
}
_fillSizedGeometry.X = chart.DrawMarginLocation.X;
_fillSizedGeometry.Y = chart.DrawMarginLocation.Y;
_fillSizedGeometry.Width = chart.DrawMarginSize.Width;
_fillSizedGeometry.Height = chart.DrawMarginSize.Height;

Fill.AddGeometryToPaintTask(chart.Canvas, _fillSizedGeometry);
}

/// <summary>
/// Measures the <see cref="DrawMarginFrame{TDrawingContext}.Stroke"/> of the draw margin for the specified chart.
/// </summary>
/// <param name="chart">The chart.</param>
protected virtual void MeasureStroke(Chart<TDrawingContext> chart)
{
Stroke!.ZIndex = -2;

_strokeSizedGeometry ??= new TSizedGeometry();

_strokeSizedGeometry.X = chart.DrawMarginLocation.X;
_strokeSizedGeometry.Y = chart.DrawMarginLocation.Y;
_strokeSizedGeometry.Width = chart.DrawMarginSize.Width;
_strokeSizedGeometry.Height = chart.DrawMarginSize.Height;

Stroke.AddGeometryToPaintTask(chart.Canvas, _strokeSizedGeometry);
}
}
}