2010-08-03 47 views
2

我想繪製一個自定義線帽 - 一個半徑爲r的等邊三角形。顯然我不能:來自.NET的CustomLineCap構造函數的NotImplementedException

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) 

我有什麼問題或者它只是一個框架錯誤?

編輯:

馬克CIDADE句話後,我嘗試使用(Nothing, path)它幫助,但我需要填寫的三角形,不僅中風出來...

回答

1

唯一的例外來自GDI +庫從GdipCreateCustomLineCap()函數返回NotImplemented狀態。嘗試傳遞行程路徑而不是Nothing

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

顯然,路徑不能穿過x軸。我用這個代碼創建一個箭頭帽:

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); 
相關問題