public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == (Type)null) { throw new ArgumentNullException(nameof(destinationType)); } if (value != null && value is SplitterLength) { SplitterLength length = (SplitterLength)value; if (destinationType == typeof(string)) { return((object)SplitterLengthConverter.ToString(length, culture)); } if (destinationType.IsEquivalentTo(typeof(InstanceDescriptor))) { return((object)new InstanceDescriptor((MemberInfo)typeof(SplitterLength).GetConstructor(new Type[2] { typeof(double), typeof(SplitterUnitType) }), (ICollection) new object[2] { (object)length.Value, (object)length.SplitterUnitType })); } } throw this.GetConvertToException(value, destinationType); }
public static void SetSplitterLength(UIElement element, SplitterLength value) { if (element == null) { throw new ArgumentNullException(nameof(element)); } element.SetValue(SplitterPanel.SplitterLengthProperty, (object)value); }
internal static string ToString(SplitterLength length, CultureInfo cultureInfo) { if (length.SplitterUnitType == SplitterUnitType.Fill) { return("*"); } return(Convert.ToString(length.Value, (IFormatProvider)cultureInfo)); }
private bool ResizeChildrenCore(SplitterMeasureData child1, SplitterMeasureData child2, double pixelAmount) { UIElement element1 = child1.Element; UIElement element2 = child2.Element; SplitterLength attachedLength1 = child1.AttachedLength; SplitterLength attachedLength2 = child2.AttachedLength; double actualSplitterLength1 = SplitterPanel.GetActualSplitterLength(element1); double actualSplitterLength2 = SplitterPanel.GetActualSplitterLength(element2); double num1 = Math.Max(0.0, Math.Min(actualSplitterLength1 + actualSplitterLength2, actualSplitterLength1 + pixelAmount)); double num2 = Math.Max(0.0, Math.Min(actualSplitterLength1 + actualSplitterLength2, actualSplitterLength2 - pixelAmount)); double minimumLength1 = SplitterPanel.GetMinimumLength(element1); double minimumLength2 = SplitterPanel.GetMinimumLength(element2); if (minimumLength1 + minimumLength2 > num1 + num2) { return(false); } if (num1 < minimumLength1) { num2 -= minimumLength1 - num1; num1 = minimumLength1; } if (num2 < minimumLength2) { num1 -= minimumLength2 - num2; num2 = minimumLength2; } if (attachedLength1.IsFill && attachedLength2.IsFill || attachedLength1.IsStretch && attachedLength2.IsStretch) { SplitterMeasureData splitterMeasureData = child1; double num3 = num1; SplitterLength splitterLength = new SplitterLength(num3 / (num3 + num2) * (attachedLength1.Value + attachedLength2.Value), attachedLength1.SplitterUnitType); splitterMeasureData.AttachedLength = splitterLength; child2.AttachedLength = new SplitterLength(num2 / (num1 + num2) * (attachedLength1.Value + attachedLength2.Value), attachedLength1.SplitterUnitType); } else if (attachedLength1.IsFill) { child2.AttachedLength = new SplitterLength(num2, SplitterUnitType.Stretch); } else { child1.AttachedLength = new SplitterLength(num1, SplitterUnitType.Stretch); } return(true); }
public static Size Measure(Size availableSize, Orientation orientation, IEnumerable <SplitterMeasureData> measureData, bool remeasureElements) { double num1 = 0.0; double num2 = 0.0; double num3 = 0.0; double num4 = 0.0; if (orientation == Orientation.Horizontal && availableSize.Width.IsNonreal() || orientation == Orientation.Vertical && availableSize.Height.IsNonreal()) { return(SplitterPanel.MeasureNonreal(availableSize, orientation, measureData, remeasureElements)); } foreach (SplitterMeasureData splitterMeasureData in measureData) { SplitterLength attachedLength = splitterMeasureData.AttachedLength; double minimumLength = SplitterPanel.GetMinimumLength(splitterMeasureData.Element); if (attachedLength.IsStretch) { num1 += attachedLength.Value; num4 += minimumLength; } else { num2 += attachedLength.Value; num3 += minimumLength; } splitterMeasureData.IsMinimumReached = false; splitterMeasureData.IsMaximumReached = false; } double num5 = num4 + num3; double width = availableSize.Width; double height = availableSize.Height; double num6 = orientation == Orientation.Horizontal ? width : height; double num7 = num2 == 0.0 ? 0.0 : Math.Max(0.0, num6 - num1); double num8 = num7 == 0.0 ? num6 : num1; double num9 = num6; if (num5 <= num9) { foreach (SplitterMeasureData splitterMeasureData in measureData) { SplitterLength attachedLength = splitterMeasureData.AttachedLength; double maximumLength = SplitterPanel.GetMaximumLength(splitterMeasureData.Element); if (attachedLength.IsStretch && (num1 == 0.0 ? 0.0 : attachedLength.Value / num1 * num8) > maximumLength) { splitterMeasureData.IsMaximumReached = true; if (num1 == attachedLength.Value) { num1 = maximumLength; splitterMeasureData.AttachedLength = new SplitterLength(maximumLength); } else { num1 -= attachedLength.Value; splitterMeasureData.AttachedLength = new SplitterLength(num1); double num10 = num1; num1 = num10 + num10; } num7 = num2 == 0.0 ? 0.0 : Math.Max(0.0, num6 - num1); num8 = num7 == 0.0 ? num6 : num1; } } if (num7 < num3) { num7 = num3; num8 = num6 - num7; } foreach (SplitterMeasureData splitterMeasureData in measureData) { SplitterLength attachedLength = splitterMeasureData.AttachedLength; double minimumLength = SplitterPanel.GetMinimumLength(splitterMeasureData.Element); if (attachedLength.IsFill) { if ((num2 == 0.0 ? 0.0 : attachedLength.Value / num2 * num7) < minimumLength) { splitterMeasureData.IsMinimumReached = true; num7 -= minimumLength; num2 -= attachedLength.Value; } } else if ((num1 == 0.0 ? 0.0 : attachedLength.Value / num1 * num8) < minimumLength) { splitterMeasureData.IsMinimumReached = true; num8 -= minimumLength; num1 -= attachedLength.Value; } } } Size availableSize1 = new Size(width, height); Rect rect = new Rect(0.0, 0.0, width, height); foreach (SplitterMeasureData splitterMeasureData in measureData) { SplitterLength attachedLength = splitterMeasureData.AttachedLength; double num10 = splitterMeasureData.IsMinimumReached ? SplitterPanel.GetMinimumLength(splitterMeasureData.Element) : (!attachedLength.IsFill ? (num1 == 0.0 ? 0.0 : attachedLength.Value / num1 * num8) : (num2 == 0.0 ? 0.0 : attachedLength.Value / num2 * num7)); if (remeasureElements) { SplitterPanel.SetActualSplitterLength(splitterMeasureData.Element, num10); } if (orientation == Orientation.Horizontal) { availableSize1.Width = num10; splitterMeasureData.MeasuredBounds = new Rect(rect.Left, rect.Top, num10, rect.Height); rect.X += num10; if (remeasureElements) { splitterMeasureData.Element.Measure(availableSize1); } } else { availableSize1.Height = num10; splitterMeasureData.MeasuredBounds = new Rect(rect.Left, rect.Top, rect.Width, num10); rect.Y += num10; if (remeasureElements) { splitterMeasureData.Element.Measure(availableSize1); } } } return(new Size(width, height)); }