public override void Render(DrawingContext context) { var geometry = RenderedGeometry; if (geometry != null) { var stroke = Stroke; ImmutablePen?pen = null; if (stroke != null) { var strokeDashArray = StrokeDashArray; ImmutableDashStyle?dashStyle = null; if (strokeDashArray != null && strokeDashArray.Count > 0) { dashStyle = new ImmutableDashStyle(strokeDashArray, StrokeDashOffset); } pen = new ImmutablePen( stroke.ToImmutable(), StrokeThickness, dashStyle, StrokeLineCap, StrokeJoin); } context.DrawGeometry(Fill, pen, geometry); } }
void RenderCore(DrawingContext context, IBrush background, IBrush borderBrush, BoxShadows boxShadows, double borderDashOffset, PenLineCap borderLineCap, PenLineJoin borderLineJoin, AvaloniaList <double> borderDashArray) { if (_useComplexRendering) { var backgroundGeometry = _backgroundGeometryCache; if (backgroundGeometry != null) { context.DrawGeometry(background, null, backgroundGeometry); } var borderGeometry = _borderGeometryCache; if (borderGeometry != null) { context.DrawGeometry(borderBrush, null, borderGeometry); } } else { var borderThickness = _borderThickness.Top; IPen pen = null; ImmutableDashStyle?dashStyle = null; if (borderDashArray != null && borderDashArray.Count > 0) { dashStyle = new ImmutableDashStyle(borderDashArray, borderDashOffset); } if (borderBrush != null && borderThickness > 0) { pen = new ImmutablePen( borderBrush.ToImmutable(), borderThickness, dashStyle, borderLineCap, borderLineJoin); } var rect = new Rect(_size); if (!MathUtilities.IsZero(borderThickness)) { rect = rect.Deflate(borderThickness * 0.5); } var rrect = new RoundedRect(rect, _cornerRadius.TopLeft, _cornerRadius.TopRight, _cornerRadius.BottomRight, _cornerRadius.BottomLeft); context.PlatformImpl.DrawRectangle(background, pen, rrect, boxShadows); } }