protected void PerformLayoutBorder(RectangleF innerBorderRect, RenderContext context) { // Setup border brush if (BorderBrush != null && BorderThickness > 0) { // TODO: Draw border with thickness BorderThickness - doesn't work yet, the drawn line is only one pixel thick using (GraphicsPath path = CreateBorderRectPath(innerBorderRect)) { using (GraphicsPathIterator gpi = new GraphicsPathIterator(path)) { PositionColoredTextured[][] subPathVerts = new PositionColoredTextured[gpi.SubpathCount][]; using (GraphicsPath subPath = new GraphicsPath()) { for (int i = 0; i < subPathVerts.Length; i++) { bool isClosed; gpi.NextSubpath(subPath, out isClosed); PointF[] pathPoints = subPath.PathPoints; PenLineJoin lineJoin = Math.Abs(CornerRadius) < DELTA_DOUBLE ? BorderLineJoin : PenLineJoin.Bevel; TriangulateHelper.TriangulateStroke_TriangleList(pathPoints, (float)BorderThickness, isClosed, 1, lineJoin, out subPathVerts[i]); } } PositionColoredTextured[] verts; GraphicsPathHelper.Flatten(subPathVerts, out verts); BorderBrush.SetupBrush(this, ref verts, context.ZOrder, true); PrimitiveBuffer.SetPrimitiveBuffer(ref _borderContext, ref verts, PrimitiveType.TriangleList); } } } else { PrimitiveBuffer.DisposePrimitiveBuffer(ref _borderContext); } }
protected override void DoPerformLayout(RenderContext context) { base.DoPerformLayout(context); // Setup brushes if (Fill != null || ((Stroke != null && StrokeThickness > 0))) { using (GraphicsPath path = CalculateTransformedPath(_innerRect)) { if (Fill != null && !_fillDisabled) { using (GraphicsPathIterator gpi = new GraphicsPathIterator(path)) { PositionColoredTextured[][] subPathVerts = new PositionColoredTextured[gpi.SubpathCount][]; using (GraphicsPath subPath = new GraphicsPath()) { for (int i = 0; i < subPathVerts.Length; i++) { bool isClosed; gpi.NextSubpath(subPath, out isClosed); PointF[] pathPoints = subPath.PathPoints; TriangulateHelper.Triangulate(pathPoints, 1, out subPathVerts[i]); if (subPathVerts[i] == null) { ServiceRegistration.Get <ILogger>().Warn("Failed to triangulate Path \"{0}\"!", Name); } } } PositionColoredTextured[] verts; GraphicsPathHelper.Flatten(subPathVerts, out verts); if (verts != null) { Fill.SetupBrush(this, ref verts, context.ZOrder, true); PrimitiveBuffer.SetPrimitiveBuffer(ref _fillContext, ref verts, PrimitiveType.TriangleList); } } } else { PrimitiveBuffer.DisposePrimitiveBuffer(ref _fillContext); } if (Stroke != null && StrokeThickness > 0) { using (GraphicsPathIterator gpi = new GraphicsPathIterator(path)) { PositionColoredTextured[][] subPathVerts = new PositionColoredTextured[gpi.SubpathCount][]; using (GraphicsPath subPath = new GraphicsPath()) { for (int i = 0; i < subPathVerts.Length; i++) { bool isClosed; gpi.NextSubpath(subPath, out isClosed); PointF[] pathPoints = subPath.PathPoints; TriangulateHelper.TriangulateStroke_TriangleList(pathPoints, (float)StrokeThickness, isClosed, 1, StrokeLineJoin, out subPathVerts[i]); } } PositionColoredTextured[] verts; GraphicsPathHelper.Flatten(subPathVerts, out verts); if (verts != null) { Stroke.SetupBrush(this, ref verts, context.ZOrder, true); PrimitiveBuffer.SetPrimitiveBuffer(ref _strokeContext, ref verts, PrimitiveType.TriangleList); } } } else { PrimitiveBuffer.DisposePrimitiveBuffer(ref _strokeContext); } } } }