.netgdi+system.drawingnotimplementedexception

NotImplementedException from .NET's CustomLineCap constructor


I want to draw a custom line cap - a equilateral triangle with the radius r. Apparently I can't:

  Dim triangleSide As Single = CSng(3 * r / Math.Sqrt(3))
  Dim triangleHeight As Single = CSng(3 * r / 2)
  path = New GraphicsPath()
  Dim points() As PointF = New PointF() { _ 
      New PointF(-triangleSide / 2, 0), _ 
      New PointF(triangleSide / 2, 0), _
      New PointF(0, triangleHeight) }
  path.AddLines(points)

  ' Not Implemented Exception, Was is Das? '
  _HlpCap = New CustomLineCap(path, Nothing) 

Do I something wrong or it's just a framework bug?

EDIT:

After Mark Cidade remark, I tried using (Nothing, path) and it helped, but I need to fill in the triangle, not only to stroke it out...


Solution

  • The exception comes from the GDI+ library returning a NotImplemented status from its GdipCreateCustomLineCap() function. Try passing a stroke path instead of Nothing:

      Dim path2 As GraphicsPath = New GraphicsPath()
      path2.AddLines(points);
      _HlpCap = New CustomLineCap(path, path2)