2011-10-15 11 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

関連する問題