Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Providing a custom component turned out to be the best solution. I use it like this in my code</p> <pre><code>&lt;Controls:Arc Center="{Binding Path=PreviousMousePositionPixels}" Stroke="White" StrokeDashArray="4 4" SnapsToDevicePixels="True" StartAngle="0" EndAngle="{Binding Path=DeltaAngle}" SmallAngle="True" Radius="40" /&gt; </code></pre> <p><code>SmallAngle</code> when <code>true</code> will render the small angle between the points irrespective of order of <code>StartAngle</code> and <code>EndAngle</code>. When <code>SmallAngle</code> is <code>false</code> the arc is rendered counter clockwise.</p> <p>The implementation is</p> <pre><code>using System; using System.Collections.Generic; using System.Windows; using System.Windows.Media; using System.Windows.Shapes; public sealed class Arc : Shape { public Point Center { get =&gt; (Point)GetValue(CenterProperty); set =&gt; SetValue(CenterProperty, value); } // Using a DependencyProperty as the backing store for Center. This enables animation, styling, binding, etc... public static readonly DependencyProperty CenterProperty = DependencyProperty.Register(nameof(Center), typeof(Point), typeof(Arc), new FrameworkPropertyMetadata(new Point(), FrameworkPropertyMetadataOptions.AffectsRender)); public double StartAngle { get =&gt; (double)GetValue(StartAngleProperty); set =&gt; SetValue(StartAngleProperty, value); } // Using a DependencyProperty as the backing store for StartAngle. This enables animation, styling, binding, etc... public static readonly DependencyProperty StartAngleProperty = DependencyProperty.Register(nameof(StartAngle), typeof(double), typeof(Arc), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender)); public double EndAngle { get =&gt; (double)GetValue(EndAngleProperty); set =&gt; SetValue(EndAngleProperty, value); } // Using a DependencyProperty as the backing store for EndAngle. This enables animation, styling, binding, etc... public static readonly DependencyProperty EndAngleProperty = DependencyProperty.Register(nameof(EndAngle), typeof(double), typeof(Arc), new FrameworkPropertyMetadata(Math.PI / 2.0, FrameworkPropertyMetadataOptions.AffectsRender)); public double Radius { get =&gt; (double)GetValue(RadiusProperty); set =&gt; SetValue(RadiusProperty, value); } // Using a DependencyProperty as the backing store for Radius. This enables animation, styling, binding, etc... public static readonly DependencyProperty RadiusProperty = DependencyProperty.Register(nameof(Radius), typeof(double), typeof(Arc), new FrameworkPropertyMetadata(10.0, FrameworkPropertyMetadataOptions.AffectsRender)); public bool SmallAngle { get =&gt; (bool)GetValue(SmallAngleProperty); set =&gt; SetValue(SmallAngleProperty, value); } // Using a DependencyProperty as the backing store for SmallAngle. This enables animation, styling, binding, etc... public static readonly DependencyProperty SmallAngleProperty = DependencyProperty.Register(nameof(SmallAngle), typeof(bool), typeof(Arc), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender)); static Arc() =&gt; DefaultStyleKeyProperty.OverrideMetadata(typeof(Arc), new FrameworkPropertyMetadata(typeof(Arc))); protected override Geometry DefiningGeometry { get { double a0 = StartAngle &lt; 0 ? StartAngle + 2 * Math.PI : StartAngle; double a1 = EndAngle &lt; 0 ? EndAngle + 2 * Math.PI : EndAngle; if (a1 &lt; a0) a1 += Math.PI * 2; SweepDirection d = SweepDirection.Counterclockwise; bool large; if (SmallAngle) { large = false; d = (a1 - a0) &gt; Math.PI ? SweepDirection.Counterclockwise : SweepDirection.Clockwise; } else large = (Math.Abs(a1 - a0) &lt; Math.PI); Point p0 = Center + new Vector(Math.Cos(a0), Math.Sin(a0)) * Radius; Point p1 = Center + new Vector(Math.Cos(a1), Math.Sin(a1)) * Radius; List&lt;PathSegment&gt; segments = new List&lt;PathSegment&gt; { new ArcSegment(p1, new Size(Radius, Radius), 0.0, large, d, true) }; List&lt;PathFigure&gt; figures = new List&lt;PathFigure&gt; { new PathFigure(p0, segments, true) { IsClosed = false } }; return new PathGeometry(figures, FillRule.EvenOdd, null); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload