2010-08-03 8 views
2

Je souhaite tracer un contour de ligne personnalisé - un triangle équilatéral de rayon r. Apparemment, je ne peux pas:NotImplementedException du constructeur CustomLineCap de .NET

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) 

Est-ce que quelque chose ne va pas ou que c'est juste un bug d'infrastructure?

EDIT:

Après remarque Mark Cidade, j'ai essayé d'utiliser (Nothing, path) et il a aidé, mais je dois remplir le triangle, non seulement pour le caresser sur ...

Répondre

1

L'exception vient de la Bibliothèque GDI + renvoyant un statut NotImplemented à partir de sa fonction GdipCreateCustomLineCap(). Essayez de passer un chemin de course au lieu de Nothing:

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

Apparemment, le chemin ne peut pas traverser l'axe x. J'ai utilisé ce code pour créer une casquette:

GraphicsPath capPath = new GraphicsPath(); 
    float arrowSize = 2.0f; 
    capPath.AddLines(new PointF[] { 
    new PointF(arrowSize, -(float)Math.Sqrt(3.0) * arrowSize), 
    new PointF(0.0f, -0.01f), 
    new PointF(-arrowSize, -(float)Math.Sqrt(3.0) * arrowSize) 
    }); 

    CustomLineCap arrowCap = new CustomLineCap(capPath, null, LineCap.NoAnchor, (float)Math.Sqrt(3.0) * arrowSize);