// Token: 0x06005859 RID: 22617 RVA: 0x00187528 File Offset: 0x00185728 private void ProcessThumbDragDelta(DragDeltaEventArgs e) { Thumb thumb = e.OriginalSource as Thumb; if (thumb != null) { ToolBar toolBar = thumb.TemplatedParent as ToolBar; if (toolBar != null && toolBar.Parent == this) { if (this._bandsDirty) { this.GenerateBands(); } bool flag = this.Orientation == Orientation.Horizontal; int band = toolBar.Band; Point position = Mouse.PrimaryDevice.GetPosition(this); Point point = this.TransformPointToToolBar(toolBar, position); int bandFromOffset = this.GetBandFromOffset(flag ? position.Y : position.X); double num = flag ? e.HorizontalChange : e.VerticalChange; double num2; if (flag) { num2 = position.X - point.X; } else { num2 = position.Y - point.Y; } double num3 = num2 + num; if (bandFromOffset == band) { List <ToolBar> band2 = this._bands[band].Band; int bandIndex = toolBar.BandIndex; if (DoubleUtil.LessThan(num, 0.0)) { double num4 = this.ToolBarsTotalMinimum(band2, 0, bandIndex - 1); if (DoubleUtil.LessThanOrClose(num4, num3)) { this.ShrinkToolBars(band2, 0, bandIndex - 1, -num); } else if (bandIndex > 0) { ToolBar toolBar2 = band2[bandIndex - 1]; Point point2 = this.TransformPointToToolBar(toolBar2, position); if (DoubleUtil.LessThan(flag ? point2.X : point2.Y, 0.0)) { toolBar2.BandIndex = bandIndex; band2[bandIndex] = toolBar2; toolBar.BandIndex = bandIndex - 1; band2[bandIndex - 1] = toolBar; if (bandIndex + 1 == band2.Count) { toolBar2.ClearValue(flag ? FrameworkElement.WidthProperty : FrameworkElement.HeightProperty); } } else if (flag) { if (DoubleUtil.LessThan(num4, position.X - point.X)) { this.ShrinkToolBars(band2, 0, bandIndex - 1, position.X - point.X - num4); } } else if (DoubleUtil.LessThan(num4, position.Y - point.Y)) { this.ShrinkToolBars(band2, 0, bandIndex - 1, position.Y - point.Y - num4); } } } else { double value = this.ToolBarsTotalMaximum(band2, 0, bandIndex - 1); if (DoubleUtil.GreaterThan(value, num3)) { this.ExpandToolBars(band2, 0, bandIndex - 1, num); } else if (bandIndex < band2.Count - 1) { ToolBar toolBar3 = band2[bandIndex + 1]; Point point3 = this.TransformPointToToolBar(toolBar3, position); if (DoubleUtil.GreaterThanOrClose(flag ? point3.X : point3.Y, 0.0)) { toolBar3.BandIndex = bandIndex; band2[bandIndex] = toolBar3; toolBar.BandIndex = bandIndex + 1; band2[bandIndex + 1] = toolBar; if (bandIndex + 2 == band2.Count) { toolBar.ClearValue(flag ? FrameworkElement.WidthProperty : FrameworkElement.HeightProperty); } } else { this.ExpandToolBars(band2, 0, bandIndex - 1, num); } } else { this.ExpandToolBars(band2, 0, bandIndex - 1, num); } } } else { this._bandsDirty = true; toolBar.Band = bandFromOffset; toolBar.ClearValue(flag ? FrameworkElement.WidthProperty : FrameworkElement.HeightProperty); if (bandFromOffset >= 0 && bandFromOffset < this._bands.Count) { this.MoveToolBar(toolBar, bandFromOffset, num3); } List <ToolBar> band3 = this._bands[band].Band; for (int i = 0; i < band3.Count; i++) { ToolBar toolBar4 = band3[i]; toolBar4.ClearValue(flag ? FrameworkElement.WidthProperty : FrameworkElement.HeightProperty); } } e.Handled = true; } } }
// Token: 0x06005698 RID: 22168 RVA: 0x0017F0C4 File Offset: 0x0017D2C4 internal static Size StackMeasureHelper(IStackMeasure measureElement, IStackMeasureScrollData scrollData, Size constraint) { Size size = default(Size); UIElementCollection internalChildren = measureElement.InternalChildren; Size availableSize = constraint; bool flag = measureElement.Orientation == Orientation.Horizontal; int num = -1; int i; double num2; if (flag) { availableSize.Width = double.PositiveInfinity; if (measureElement.IsScrolling && measureElement.CanVerticallyScroll) { availableSize.Height = double.PositiveInfinity; } i = (measureElement.IsScrolling ? StackPanel.CoerceOffsetToInteger(scrollData.Offset.X, internalChildren.Count) : 0); num2 = constraint.Width; } else { availableSize.Height = double.PositiveInfinity; if (measureElement.IsScrolling && measureElement.CanHorizontallyScroll) { availableSize.Width = double.PositiveInfinity; } i = (measureElement.IsScrolling ? StackPanel.CoerceOffsetToInteger(scrollData.Offset.Y, internalChildren.Count) : 0); num2 = constraint.Height; } int j = 0; int count = internalChildren.Count; while (j < count) { UIElement uielement = internalChildren[j]; if (uielement != null) { uielement.Measure(availableSize); Size desiredSize = uielement.DesiredSize; double num3; if (flag) { size.Width += desiredSize.Width; size.Height = Math.Max(size.Height, desiredSize.Height); num3 = desiredSize.Width; } else { size.Width = Math.Max(size.Width, desiredSize.Width); size.Height += desiredSize.Height; num3 = desiredSize.Height; } if (measureElement.IsScrolling && num == -1 && j >= i) { num2 -= num3; if (DoubleUtil.LessThanOrClose(num2, 0.0)) { num = j; } } } j++; } if (measureElement.IsScrolling) { Size viewport = constraint; Size extent = size; Vector offset = scrollData.Offset; if (num == -1) { num = internalChildren.Count - 1; } while (i > 0) { double num4 = num2; if (flag) { num4 -= internalChildren[i - 1].DesiredSize.Width; } else { num4 -= internalChildren[i - 1].DesiredSize.Height; } if (DoubleUtil.LessThan(num4, 0.0)) { break; } i--; num2 = num4; } int count2 = internalChildren.Count; int num5 = num - i; if (num5 == 0 || DoubleUtil.GreaterThanOrClose(num2, 0.0)) { num5++; } if (flag) { scrollData.SetPhysicalViewport(viewport.Width); viewport.Width = (double)num5; extent.Width = (double)count2; offset.X = (double)i; offset.Y = Math.Max(0.0, Math.Min(offset.Y, extent.Height - viewport.Height)); } else { scrollData.SetPhysicalViewport(viewport.Height); viewport.Height = (double)num5; extent.Height = (double)count2; offset.Y = (double)i; offset.X = Math.Max(0.0, Math.Min(offset.X, extent.Width - viewport.Width)); } size.Width = Math.Min(size.Width, constraint.Width); size.Height = Math.Min(size.Height, constraint.Height); StackPanel.VerifyScrollingData(measureElement, scrollData, viewport, extent, offset); } return(size); }
/// <summary> /// OnLayoutUpdated handler. Validates that all participating definitions /// have updated min size value. Forces another layout update cycle if needed. /// </summary> private void OnLayoutUpdated(object sender, EventArgs e) { double sharedMinSize = 0; // accumulate min size of all participating definitions for (int i = 0, count = _registry.Count; i < count; ++i) { sharedMinSize = Math.Max(sharedMinSize, _registry[i]._minSize); } bool sharedMinSizeChanged = !DoubleUtil.AreClose(_minSize, sharedMinSize); // compare accumulated min size with min sizes of the individual definitions for (int i = 0, count = _registry.Count; i < count; ++i) { DefinitionBase definitionBase = _registry[i]; // we'll set d.UseSharedMinimum to maintain the invariant: // d.UseSharedMinimum iff d._minSize < this.MinSize // i.e. iff d is not a "long-pole" definition. // // Measure/Arrange of d's Grid uses d._minSize for long-pole // definitions, and max(d._minSize, shared size) for // short-pole definitions. This distinction allows us to react // to changes in "long-pole-ness" more efficiently and correctly, // by avoiding remeasures when a long-pole definition changes. bool useSharedMinimum = !DoubleUtil.AreClose(definitionBase._minSize, sharedMinSize); // before doing that, determine whether d's Grid needs to be remeasured. // It's important _not_ to remeasure if the last measure is still // valid, otherwise infinite loops are possible bool measureIsValid; if (!definitionBase.UseSharedMinimum) { // d was a long-pole. measure is valid iff it's still a long-pole, // since previous measure didn't use shared size. measureIsValid = !useSharedMinimum; } else if (useSharedMinimum) { // d was a short-pole, and still is. measure is valid // iff the shared size didn't change measureIsValid = !sharedMinSizeChanged; } else { // d was a short-pole, but is now a long-pole. This can // happen in several ways: // a. d's minSize increased to or past the old shared size // b. other long-pole definitions decreased, leaving // d as the new winner // In the former case, the measure is valid - it used // d's new larger minSize. In the latter case, the // measure is invalid - it used the old shared size, // which is larger than d's (possibly changed) minSize measureIsValid = (definitionBase.LayoutWasUpdated && DoubleUtil.GreaterThanOrClose(definitionBase._minSize, this.MinSize)); } if (!measureIsValid) { Grid parentGrid = (Grid)definitionBase.Parent; parentGrid.InvalidateMeasure(); } else if (!DoubleUtil.AreClose(sharedMinSize, definitionBase.SizeCache)) { // if measure is valid then also need to check arrange. // Note: definitionBase.SizeCache is volatile but at this point // it contains up-to-date final size Grid parentGrid = (Grid)definitionBase.Parent; parentGrid.InvalidateArrange(); } // now we can restore the invariant, and clear the layout flag definitionBase.UseSharedMinimum = useSharedMinimum; definitionBase.LayoutWasUpdated = false; } _minSize = sharedMinSize; _layoutUpdatedHost.LayoutUpdated -= _layoutUpdated; _layoutUpdatedHost = null; _broadcastInvalidation = true; }