using System; using System.Collections.Generic; using System.Windows; using System.Windows.Documents; using System.Windows.Media; using System.Windows.Shapes; namespace Tango.Visuals.Components { internal class Arc : Shape { public double StartAngle { get { return (double)GetValue(StartAngleProperty); } set { SetValue(StartAngleProperty, value); } } public static readonly DependencyProperty StartAngleProperty = DependencyProperty.Register("StartAngle", typeof(double), typeof(Arc), new PropertyMetadata(0.0)); public double EndAngle { get { return (double)GetValue(EndAngleProperty); } set { SetValue(EndAngleProperty, value); } } public static readonly DependencyProperty EndAngleProperty = DependencyProperty.Register("EndAngle", typeof(double), typeof(Arc), new PropertyMetadata(90.0)); protected override Geometry DefiningGeometry { get { double maxWidth = RenderSize.Width; double maxHeight = RenderSize.Height; double maxRadius = Math.Min(maxWidth, maxHeight) / 2.0; PolarPoint arcStart = new PolarPoint(maxRadius, StartAngle); PolarPoint arcFinish = new PolarPoint(maxRadius, EndAngle); StreamGeometry geom = new StreamGeometry(); using (StreamGeometryContext ctx = geom.Open()) { ctx.BeginFigure( new Point((maxWidth / 2.0) + arcStart.X, (maxHeight / 2.0) - arcStart.Y), false, false); ctx.ArcTo( new Point((maxWidth / 2.0) + arcFinish.X, (maxHeight / 2.0) - arcFinish.Y), new Size(maxRadius, maxRadius), 0.0, // rotationAngle EndAngle > 180 && StartAngle < 180 && (EndAngle - StartAngle) > 180, // greater than 180 deg? SweepDirection.Counterclockwise, true, // isStroked true); } geom.Transform = new RotateTransform((-90 + EndAngle) + StartAngle, maxWidth / 2, maxHeight / 2); return geom; } } } }