2011-10-15 17 views
9

Bir ArcSegment'ın orta noktasını bir yoldan almak ve WPF'de etiketlemek için en iyi çözüm nedir?Nasıl Olur Bir ArcSegment'in orta noktası WPF

enter image description here

+0

İyi soru. Yarıçap ve orta noktaların bazı kombinasyonlarına göre hesaplamanız gerektiğini varsayalım? –

+0

Yay, bir şekilde bir görünüm modeline veriye bağlıysa, etiketin doğru konumunu gösteren bir özelliği görünüm modeline ekleyebilir veya aynı şeyi yapan bir dönüştürücü uygulayabilirsiniz. Öte yandan, veri bağlama kullanmıyorsanız, etiketin pozisyonunu, ark için parametreleri hesapladığınız yerdeki bir yere yazabilirsiniz. ** Ritch ** 'nin belirttiği gibi, son nokta, yarıçap ve açı değerlerine göre pozisyon hesaplayabilirsiniz ... –

+0

herhangi bir kod örneği? – ARZ

cevap

7

Bu çalışması gerekir:

 //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); 

yardımcı olur Umut.

Cheers

+1

'GetPointAtFractionLength'.this tam olarak ihtiyacım olan şey! Teşekkürler. – ARZ

+0

birkaç saat sonra arama yapıyoruz ve işte buradayız! Teşekkürler! – Craig

+0

GetPointAtFractionLength benim için çok fazla sorun çözdü. Büyük bulmak! – Jon

İlgili konular