2010-08-03 2 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) 

나는 틀린가 아니면 그냥 프레임 워크 버그인가?

편집이

:

마크시다 발언 후, 나는 (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);