// optimized arrange for common usage private Size ArrangeSingleCell(Size finalSize, IDefinitionBase columnDefinition, IDefinitionBase rowDefinition) { double finalWidth = rowDefinition.Length.IsAbsolute ? rowDefinition.Length.Value : finalSize.Width; double finalHeight = columnDefinition.Length.IsAbsolute ? columnDefinition.Length.Value : finalSize.Height; Rect finalRect = new Rect(finalWidth, finalHeight); foreach (FrameworkElement child in Children) { child.Arrange(finalRect); } columnDefinition.ActualLength = finalWidth; rowDefinition.ActualLength = finalHeight; return(finalSize); }
private static double GetStarredAxisLength(IDefinitionBase starredAxis, double starLength) { return((starredAxis.Length.Value * starLength).Bounds(starredAxis.MinLength, starredAxis.MaxLength)); }
private static void SetStarLengths(IDefinitionBase[] definitionBases, double starLength, ref double[] lengths) { for (int i = 0; i < definitionBases.Length; i++) { if (definitionBases[i].Length.IsStar) { lengths[i] = definitionBases[i].Length.Value * starLength; } } }
private static void SetBoundedValues(IDefinitionBase[] definitionBases, ref double[] lengths) { for (int i = 0; i < lengths.Length; i++) { lengths[i] = lengths[i].Bounds(definitionBases[i].MinLength, definitionBases[i].MaxLength); } }
private static void SetActualLength(IDefinitionBase[] definitionBases, double[] actualLengths) { for (int i = 0; i < definitionBases.Length; i++) { definitionBases[i].ActualLength = actualLengths[i]; } }
private static double GetStarredAxisLength(IDefinitionBase starredAxis, double starLength) { return (starredAxis.Length.Value * starLength).Bounds(starredAxis.MinLength, starredAxis.MaxLength); }
private static double GetMeasureLength(IDefinitionBase[] definitionBases, double availableLength, double start, double span) { double remainingLength = availableLength; double absoluteLength = 0; bool allAbsolute = true; for (int i = 0; i < definitionBases.Length; i++) { if (i >= start && i < start + span) { if (definitionBases[i].Length.IsAbsolute) { absoluteLength += (double)definitionBases[i].Length.Value; } else { allAbsolute = false; } } else if (definitionBases[i].Length.IsAbsolute) { remainingLength -= (double)definitionBases[i].Length.Value; } } return allAbsolute ? absoluteLength : Math.Max(0, remainingLength); }
// optimized arrange for common usage private Size ArrangeSingleCell(Size finalSize, IDefinitionBase columnDefinition, IDefinitionBase rowDefinition) { double finalWidth = rowDefinition.Length.IsAbsolute ? rowDefinition.Length.Value : finalSize.Width; double finalHeight = columnDefinition.Length.IsAbsolute ? columnDefinition.Length.Value : finalSize.Height; Rect finalRect = new Rect(finalWidth, finalHeight); foreach (FrameworkElement child in Children) { child.Arrange(finalRect); } columnDefinition.ActualLength = finalWidth; rowDefinition.ActualLength = finalHeight; return finalSize; }