2014-01-27 56 views
1

我想繪製圖像中的形狀。 arc or halfcircleSector or Quarter circle 我用弧段繪製了半個圓,現在我想繪製四分之一圓或扇形,但是我無法繪製它。如何動態地在windows phone中繪製扇區(Quarter Quarter)?

我用這段代碼來繪製弧,我試圖改變大小,並且角度也不起作用。

我應該怎麼做才能畫出1/4圈/扇形?代碼我用來畫弧是:

PathFigure pthFigure1 = new PathFigure(); 
pthFigure1.StartPoint = new Point(50, 60);// starting cordinates of arcs 
ArcSegment arcSeg1 = new ArcSegment(); 
arcSeg1.Point = new Point(100, 82); // ending cordinates of arcs 
arcSeg1.Size = new Size(10, 10); 

arcSeg1.IsLargeArc = false; 
arcSeg1.SweepDirection = SweepDirection.Clockwise; 
arcSeg1.RotationAngle = 90; 
PathSegmentCollection myPathSegmentCollection1 = new PathSegmentCollection(); 
myPathSegmentCollection1.Add(arcSeg1); 
pthFigure1.Segments = myPathSegmentCollection1; 
PathFigureCollection pthFigureCollection1 = new PathFigureCollection(); 
pthFigureCollection1.Add(pthFigure1); 
PathGeometry pthGeometry1 = new PathGeometry(); 
pthGeometry1.Figures = pthFigureCollection1; 
System.Windows.Shapes.Path arcPath1 = new System.Windows.Shapes.Path(); 
arcPath1.Data = pthGeometry1; 
arcPath1.Fill = new SolidColorBrush(Color.FromArgb(255, 255, 23, 0)); 
this.LayoutRoot.Children.Add(arcPath1); 

回答

4

隨着你的代碼變化最小(/**/表示更改或添加行)。

PathFigure pthFigure1 = new PathFigure(); 
/**/ pthFigure1.StartPoint = new Point(0, 100);// starting cordinates of arcs 
ArcSegment arcSeg1 = new ArcSegment(); 
/**/ arcSeg1.Point = new Point(100, 0); // ending cordinates of arcs 
/**/ arcSeg1.Size = new Size(100, 100); 
arcSeg1.IsLargeArc = false; 
arcSeg1.SweepDirection = SweepDirection.Clockwise; 
/**/ LineSegment lineSeg = new LineSegment(); 
/**/ lineSeg.Point = new Point(100,100); 
PathSegmentCollection myPathSegmentCollection1 = new PathSegmentCollection(); 
myPathSegmentCollection1.Add(arcSeg1); 
/**/ myPathSegmentCollection1.Add(lineSeg); 
pthFigure1.Segments = myPathSegmentCollection1; 
PathFigureCollection pthFigureCollection1 = new PathFigureCollection(); 
pthFigureCollection1.Add(pthFigure1); 
... 

看來你錯過了解釋ArcSegment.RotationAngle的意思。

它的計算方法如下:

enter image description here

相關問題