2012-08-31 3 views
5

QuadraticBezierSegment 끝 부분에 화살표를 그릴 가장 쉬운 방법은 무엇입니까? 까다로운 부분은 들어오는 선 세그먼트를 기계 가공하기 위해 올바른 회전을 얻는 것입니다.xaml을 사용하여 이차원 베 지어 세그먼트에 화살표 끝자리 그리기

이 문제를 해결하는 방법에 대한 아이디어가 있으십니까? PathSegment을 연장해야합니까?

Bezier segment with an arrow at the end

나는 간단한 베 지어 선 그리기이 있어요.

<Path Stroke="Black" StrokeThickness="1"> 
    <Path.Data> 
    <PathGeometry> 
     <PathGeometry.Figures> 
     <PathFigureCollection> 
      <PathFigure StartPoint="100,430"> 
      <PathFigure.Segments> 
       <PathSegmentCollection> 
       <QuadraticBezierSegment Point1="150,250" Point2="250,300" /> 
       </PathSegmentCollection> 
      </PathFigure.Segments> 
      </PathFigure> 
     </PathFigureCollection> 
     </PathGeometry.Figures> 
    </PathGeometry> 
    </Path.Data> 
</Path> 
+1

은'QuadraticBezierSegment' 정적의'Path'인가? (코드 에서처럼 보이지만 화살표가 세그먼트와 일치하도록 언급 했으므로 잘 모르겠습니다.) – Rachel

+0

그래, 정적이지만 회전이 자동으로 계산 된 경우 편리합니다. – vidstige

답변

8

당신은 화살표 헤드의 형상을 정의 할 수 있습니다 ....하지만 시행 착오가 제대로 베 지어 곡선의 끝을 찾으시는 걸릴 것이다.

대신이 컨트롤을 사용하여 원하는 지오메트리를 정의하고 "선"의 끝에 정확하게 배치 할 수 있습니다.

  • http://blogs.msdn.com/b/mrochon/archive/2011/01/10/custom-line-caps-in-wpf.aspx

    <loc:CappedLine Stroke="Red" StrokeThickness="1" Canvas.Left="40" Canvas.Top="200" RenderTransformOrigin="0.5,0.5" Height="107" Width="195"> 
        <loc:CappedLine.EndCap> 
         <GeometryGroup> 
          <LineGeometry StartPoint="0,0" EndPoint="10,10"/> 
          <LineGeometry StartPoint="0,0" EndPoint="10,-10"/> 
         </GeometryGroup> 
        </loc:CappedLine.EndCap> 
        <loc:CappedLine.LinePath> 
         <PathGeometry Figures="M0,0 C1,1 10.5,75.5 48.5,66.5 86.5,57.5 5,3.5000146 105.5,16.500091 157.5,29.500166 164.5,87.500505 164.5,87.500505" /> 
        </loc:CappedLine.LinePath> 
    </loc:CappedLine> 
    
    <loc:CappedLine Stroke="Red" StrokeThickness="1" Canvas.Left="180" Canvas.Top="200" RenderTransformOrigin="0.5,0.5" Height="107" Width="195"> 
        <loc:CappedLine.EndCap> 
         <GeometryGroup> 
          <LineGeometry StartPoint="0,0" EndPoint="10,10"/> 
          <LineGeometry StartPoint="0,0" EndPoint="10,-10"/> 
         </GeometryGroup> 
        </loc:CappedLine.EndCap> 
        <loc:CappedLine.LinePath> 
         <PathGeometry Figures="M0,0 C1,1 10.5,75.5 48.5,66.5 86.5,57.5 5,3.5000146 105.5,16.500091" /> 
        </loc:CappedLine.LinePath> 
    </loc:CappedLine> 
    

enter image description here