2011-10-15 2 views
9

경로에서 ArcSegment의 중간 점을 가져 와서 WPF로 레이블을 지정하는 가장 좋은 해결책은 무엇입니까?WPF에서 ArcSegment의 중간 점을 얻는 방법

enter image description here

+0

좋은 질문입니다. 반경과 중간 점의 조합에 따라 계산해야한다고 가정합니다. –

+0

아크가 어떤 식 으로든 뷰 모델에 데이터 바인딩되면, 뷰 모델에 레이블의 올바른 위치를 가진 속성을 추가하거나 동일한 역할을하는 변환기를 구현할 수 있습니다. 반면에 데이터 바인딩을 사용하지 않는 경우에는 호의 매개 변수를 계산하는 동일한 위치에서 레이블의 위치를 ​​간단히 계산할 수 있습니다. ** Ritch **가 지적했듯이 끝점, 반경 및 각도를 기준으로 위치를 계산할 수 있습니다 ... –

+0

모든 코드 샘플? – ARZ

답변

7

이 작동합니다 :

 //the given arc (or any other segments) 
     var arc = new ArcSegment(
      point: new Point(200, 100), 
      size: new Size(100, 50), 
      rotationAngle: 90, 
      isLargeArc: true, 
      sweepDirection: SweepDirection.Counterclockwise, 
      isStroked: true); 

     //compose one or more segments into a collection 
     var pathcoll = new PathSegmentCollection(); 
     pathcoll.Add(arc); 

     //create a figure based on the set of segments 
     var figure = new PathFigure(); 
     figure.Segments = pathcoll; 

     //compose a collection of figures 
     var figcoll = new PathFigureCollection(); 
     figcoll.Add(figure); 

     //create a path-geometry using the figures collection 
     var geom = new PathGeometry(figcoll); 

     double fraction = 0.5; //the relative point of the curve 
     Point pt;    //the absolute point of the curve 
     Point tg;    //the tangent point of the curve 
     geom.GetPointAtFractionLength(
      fraction, 
      out pt, 
      out tg); 

는 도움이되기를 바랍니다.

환호

+1

'GetPointAtFractionLength'. 정확히 내가 필요한 것입니다! 감사. – ARZ

+0

몇 시간 후에 검색하면 여기에 우리가 있습니다! 감사! – Craig

+0

GetPointAtFractionLength는 많은 문제를 해결해주었습니다. 위대한 발견! – Jon

관련 문제