views:

33

answers:

1

Hi.

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...

+1  A: 

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) 
Mark Cidade
tried with path, path: other exception: "Object is currently in use elsewhere..."
serhio
I use double buffering if it matters...
serhio
using `(Nothing, path)` helps, but I need to fill in the rectangle...
serhio
Try creating a new GraphicsPath object then. I updated my answer to reflect this.
Mark Cidade