protected override Size MeasureOverride(Size availableSize) { var rect = new Rect(); var arc = new Arc(new Point(0, 0), this.MinAngle, this.MaxAngle, this.ReservedSpace / 2 + this.TickLength, this.IsDirectionReversed); rect.Union(arc.GetPoint(arc.Start)); var a = TickHelper.ToAngle(this.Value, this.Minimum, this.Maximum, arc); rect.Union(arc.GetPoint(a)); foreach (var p in arc.GetQuadrants(arc.Start, a)) { rect.Union(p); } return rect.Size; }
internal static Arc Fill(Size availableSize, double start, double end) { if (availableSize.Width == 0 || double.IsNaN(availableSize.Width) || availableSize.Height == 0 || double.IsNaN(availableSize.Height)) { return new Arc(new Point(0, 0), start, end, 0, false); } var p0 = new Point(0, 0); var arc = new Arc(p0, start, end, 1, false); var rect = new Rect(); var ps = arc.GetPoint(start); rect.Union(ps); rect.Union(arc.GetPoint(end)); foreach (var quadrant in arc.GetQuadrants(start, end)) { rect.Union(quadrant); } var wf = availableSize.Width / rect.Width; var hf = availableSize.Height / rect.Height; var r = Math.Min(wf, hf); rect.Scale(r, r); var v = rect.FindTranslationToCenter(availableSize); return new Arc(p0 + v, start, end, r, false); }