// Token: 0x060048D3 RID: 18643 RVA: 0x0014A864 File Offset: 0x00148A64 public static void OnColumnWidthChanged(IProvideDataGridColumn cell, DependencyPropertyChangedEventArgs e) { UIElement uielement = (UIElement)cell; DataGridColumn column = cell.Column; bool flag = cell is DataGridColumnHeader; if (column != null) { DataGridLength width = column.Width; if (width.IsAuto || (!flag && width.IsSizeToCells) || (flag && width.IsSizeToHeader)) { DataGridLength dataGridLength = (DataGridLength)e.OldValue; double num; if (dataGridLength.UnitType != width.UnitType) { double constraintWidth = column.GetConstraintWidth(flag); if (!DoubleUtil.AreClose(uielement.DesiredSize.Width, constraintWidth)) { uielement.InvalidateMeasure(); uielement.Measure(new Size(constraintWidth, double.PositiveInfinity)); } num = uielement.DesiredSize.Width; } else { num = dataGridLength.DesiredValue; } if (DoubleUtil.IsNaN(width.DesiredValue) || DoubleUtil.LessThan(width.DesiredValue, num)) { column.SetWidthInternal(new DataGridLength(width.Value, width.UnitType, num, width.DisplayValue)); } } } }
// Token: 0x06005494 RID: 21652 RVA: 0x00176A14 File Offset: 0x00174C14 private void UpdateAnimation() { if (this._glow != null) { if (base.IsVisible && this._glow.Width > 0.0 && this._indicator.Width > 0.0) { double num = this._indicator.Width + this._glow.Width; double num2 = -1.0 * this._glow.Width; TimeSpan timeSpan = TimeSpan.FromSeconds((double)((int)(num - num2)) / 200.0); TimeSpan t = TimeSpan.FromSeconds(1.0); TimeSpan value; if (DoubleUtil.GreaterThan(this._glow.Margin.Left, num2) && DoubleUtil.LessThan(this._glow.Margin.Left, num - 1.0)) { value = TimeSpan.FromSeconds(-1.0 * (this._glow.Margin.Left - num2) / 200.0); } else { value = TimeSpan.Zero; } ThicknessAnimationUsingKeyFrames thicknessAnimationUsingKeyFrames = new ThicknessAnimationUsingKeyFrames(); thicknessAnimationUsingKeyFrames.BeginTime = new TimeSpan?(value); thicknessAnimationUsingKeyFrames.Duration = new Duration(timeSpan + t); thicknessAnimationUsingKeyFrames.RepeatBehavior = RepeatBehavior.Forever; thicknessAnimationUsingKeyFrames.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(num2, 0.0, 0.0, 0.0), TimeSpan.FromSeconds(0.0))); thicknessAnimationUsingKeyFrames.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(num, 0.0, 0.0, 0.0), timeSpan)); this._glow.BeginAnimation(FrameworkElement.MarginProperty, thicknessAnimationUsingKeyFrames); return; } this._glow.BeginAnimation(FrameworkElement.MarginProperty, null); } }
/// <summary>Called to remeasure a <see cref="T:System.Windows.Controls.ToolBarTray" />. </summary> /// <param name="constraint">The measurement constraints; a <see cref="T:System.Windows.Controls.ToolBarTray" /> cannot return a size larger than the constraint.</param> /// <returns>The size of the control.</returns> // Token: 0x06005854 RID: 22612 RVA: 0x00187148 File Offset: 0x00185348 protected override Size MeasureOverride(Size constraint) { this.GenerateBands(); Size result = default(Size); bool flag = this.Orientation == Orientation.Horizontal; Size availableSize = new Size(double.PositiveInfinity, double.PositiveInfinity); for (int i = 0; i < this._bands.Count; i++) { double num = flag ? constraint.Width : constraint.Height; List <ToolBar> band = this._bands[i].Band; double num2 = 0.0; double num3 = 0.0; for (int j = 0; j < band.Count; j++) { ToolBar toolBar = band[j]; num -= toolBar.MinLength; if (DoubleUtil.LessThan(num, 0.0)) { num = 0.0; break; } } for (int j = 0; j < band.Count; j++) { ToolBar toolBar2 = band[j]; num += toolBar2.MinLength; if (flag) { availableSize.Width = num; } else { availableSize.Height = num; } toolBar2.Measure(availableSize); num2 = Math.Max(num2, flag ? toolBar2.DesiredSize.Height : toolBar2.DesiredSize.Width); num3 += (flag ? toolBar2.DesiredSize.Width : toolBar2.DesiredSize.Height); num -= (flag ? toolBar2.DesiredSize.Width : toolBar2.DesiredSize.Height); if (DoubleUtil.LessThan(num, 0.0)) { num = 0.0; } } this._bands[i].Thickness = num2; if (flag) { result.Height += num2; result.Width = Math.Max(result.Width, num3); } else { result.Width += num2; result.Height = Math.Max(result.Height, num3); } } return(result); }
// Token: 0x060056A2 RID: 22178 RVA: 0x0017F884 File Offset: 0x0017DA84 private void MakeVisibleLogicalHelper(int childIndex, ref Vector newOffset, ref Rect newRect) { bool flag = this.Orientation == Orientation.Horizontal; double num = 0.0; int num2; int num3; if (flag) { num2 = (int)this._scrollData._computedOffset.X; num3 = (int)this._scrollData._viewport.Width; } else { num2 = (int)this._scrollData._computedOffset.Y; num3 = (int)this._scrollData._viewport.Height; } int num4 = num2; if (childIndex < num2) { num4 = childIndex; } else if (childIndex > num2 + num3 - 1) { Size desiredSize = base.InternalChildren[childIndex].DesiredSize; double num5 = flag ? desiredSize.Width : desiredSize.Height; double num6 = this._scrollData._physicalViewport - num5; int num7 = childIndex; while (num7 > 0 && DoubleUtil.GreaterThanOrClose(num6, 0.0)) { num7--; desiredSize = base.InternalChildren[num7].DesiredSize; num5 = (flag ? desiredSize.Width : desiredSize.Height); num += num5; num6 -= num5; } if (num7 != childIndex && DoubleUtil.LessThan(num6, 0.0)) { num -= num5; num7++; } num4 = num7; } if (flag) { newOffset.X = (double)num4; newRect.X = num; newRect.Width = base.InternalChildren[childIndex].DesiredSize.Width; return; } newOffset.Y = (double)num4; newRect.Y = num; newRect.Height = base.InternalChildren[childIndex].DesiredSize.Height; }
// Token: 0x06004D3A RID: 19770 RVA: 0x0015BC60 File Offset: 0x00159E60 internal void CheckWidthForPreviousHeaderGripper() { bool hide = false; if (this._headerGripper != null) { hide = DoubleUtil.LessThan(base.ActualWidth, this._headerGripper.Width); } if (this._previousHeader != null) { this._previousHeader.HideGripperRightHalf(hide); } this.UpdateGripperCursor(); }
//This creates the repeating animation private void UpdateAnimation() { if (_glow != null) { if (IsVisible && (_glow.Width > 0) && (_indicator.Width > 0)) { //Set up the animation double endPos = _indicator.Width + _glow.Width; double startPos = -1 * _glow.Width; TimeSpan translateTime = TimeSpan.FromSeconds(((int)(endPos - startPos) / 200.0)); // travel at 200px /second TimeSpan pauseTime = TimeSpan.FromSeconds(1.0); // pause 1 second between animations TimeSpan startTime; //Is the animation currenly running (with one pixel fudge factor) if (DoubleUtil.GreaterThan(_glow.Margin.Left, startPos) && (DoubleUtil.LessThan(_glow.Margin.Left, endPos - 1))) { // make it appear that the timer already started. // To do this find out how many pixels the glow has moved and divide by the speed to get time. startTime = TimeSpan.FromSeconds(-1 * (_glow.Margin.Left - startPos) / 200.0); } else { startTime = TimeSpan.Zero; } ThicknessAnimationUsingKeyFrames animation = new ThicknessAnimationUsingKeyFrames(); animation.BeginTime = startTime; animation.Duration = new Duration(translateTime + pauseTime); animation.RepeatBehavior = RepeatBehavior.Forever; //Start with the glow hidden on the left. animation.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(startPos, 0, 0, 0), TimeSpan.FromSeconds(0))); //Move to the glow hidden on the right. animation.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(endPos, 0, 0, 0), translateTime)); //There is a pause after the glow is off screen _glow.BeginAnimation(FrameworkElement.MarginProperty, animation); } else { _glow.BeginAnimation(FrameworkElement.MarginProperty, null); } } }
// Check to see if hide previous header's right half gripper internal void CheckWidthForPreviousHeaderGripper() { bool hideGripperRightHalf = false; if (_headerGripper != null) { // when header's width is less than gripper's width, // hide the right half of the left header's gripper hideGripperRightHalf = DoubleUtil.LessThan(ActualWidth, _headerGripper.Width); } if (_previousHeader != null) { _previousHeader.HideGripperRightHalf(hideGripperRightHalf); } UpdateGripperCursor(); }
// Token: 0x0600545C RID: 21596 RVA: 0x00175A78 File Offset: 0x00173C78 internal static double ComputeScrollOffsetWithMinimalScroll(double topView, double bottomView, double topChild, double bottomChild, ref bool alignTop, ref bool alignBottom) { bool flag = DoubleUtil.LessThan(topChild, topView) && DoubleUtil.LessThan(bottomChild, bottomView); bool flag2 = DoubleUtil.GreaterThan(bottomChild, bottomView) && DoubleUtil.GreaterThan(topChild, topView); bool flag3 = bottomChild - topChild > bottomView - topView; if (((flag && !flag3) || (flag2 && flag3)) | alignTop) { alignTop = true; return(topChild); } if ((flag || flag2) | alignBottom) { alignBottom = true; return(bottomChild - (bottomView - topView)); } return(topView); }
// Token: 0x06005860 RID: 22624 RVA: 0x00187CB4 File Offset: 0x00185EB4 private int GetBandFromOffset(double toolBarOffset) { if (DoubleUtil.LessThan(toolBarOffset, 0.0)) { return(-1); } double num = 0.0; for (int i = 0; i < this._bands.Count; i++) { num += this._bands[i].Thickness; if (DoubleUtil.GreaterThan(num, toolBarOffset)) { return(i); } } return(this._bands.Count); }
internal static double ComputeScrollOffsetWithMinimalScroll( double topView, double bottomView, double topChild, double bottomChild, ref bool alignTop, ref bool alignBottom) { // # CHILD POSITION CHILD SIZE SCROLL REMEDY // 1 Above viewport <= viewport Down Align top edge of child & viewport // 2 Above viewport > viewport Down Align bottom edge of child & viewport // 3 Below viewport <= viewport Up Align bottom edge of child & viewport // 4 Below viewport > viewport Up Align top edge of child & viewport // 5 Entirely within viewport NA No scroll. // 6 Spanning viewport NA No scroll. // // Note: "Above viewport" = childTop above viewportTop, childBottom above viewportBottom // "Below viewport" = childTop below viewportTop, childBottom below viewportBottom // These child thus may overlap with the viewport, but will scroll the same direction/ bool fAbove = DoubleUtil.LessThan(topChild, topView) && DoubleUtil.LessThan(bottomChild, bottomView); bool fBelow = DoubleUtil.GreaterThan(bottomChild, bottomView) && DoubleUtil.GreaterThan(topChild, topView); bool fLarger = (bottomChild - topChild) > (bottomView - topView); // Handle Cases: 1 & 4 above if ((fAbove && !fLarger) || (fBelow && fLarger) || alignTop) { alignTop = true; return(topChild); } // Handle Cases: 2 & 3 above else if (fAbove || fBelow || alignBottom) { alignBottom = true; return(bottomChild - (bottomView - topView)); } // Handle cases: 5 & 6 above. return(topView); }
/// <summary> /// Invalidates a cell's panel if its column's width changes sufficiently. /// </summary> /// <param name="cell">The cell or header.</param> /// <param name="e"></param> public static void OnColumnWidthChanged(IProvideDataGridColumn cell, DependencyPropertyChangedEventArgs e) { Debug.Assert((cell is DataGridCell) || (cell is DataGridColumnHeader), "provideColumn should be one of the cell or header containers."); UIElement element = (UIElement)cell; DataGridColumn column = cell.Column; bool isColumnHeader = (cell is DataGridColumnHeader); if (column != null) { // determine the desired value of width for auto kind columns DataGridLength width = column.Width; if (width.IsAuto || (!isColumnHeader && width.IsSizeToCells) || (isColumnHeader && width.IsSizeToHeader)) { DataGridLength oldWidth = (DataGridLength)e.OldValue; double desiredWidth = 0.0; if (oldWidth.UnitType != width.UnitType) { double constraintWidth = column.GetConstraintWidth(isColumnHeader); if (!DoubleUtil.AreClose(element.DesiredSize.Width, constraintWidth)) { element.InvalidateMeasure(); element.Measure(new Size(constraintWidth, double.PositiveInfinity)); } desiredWidth = element.DesiredSize.Width; } else { desiredWidth = oldWidth.DesiredValue; } if (DoubleUtil.IsNaN(width.DesiredValue) || DoubleUtil.LessThan(width.DesiredValue, desiredWidth)) { column.SetWidthInternal(new DataGridLength(width.Value, width.UnitType, desiredWidth, width.DisplayValue)); } } } }
private int GetBandFromOffset(double toolBarOffset) { if (DoubleUtil.LessThan(toolBarOffset, 0)) { return(-1); } double bandOffset = 0d; for (int i = 0; i < _bands.Count; i++) { bandOffset += _bands[i].Thickness; if (DoubleUtil.GreaterThan(bandOffset, toolBarOffset)) { return(i); } } return(_bands.Count); }
private void ProcessThumbDragDelta(DragDeltaEventArgs e) { // Process thumb event only if Thumb styled parent is a ToolBar under the TollBarTray Thumb thumb = e.OriginalSource as Thumb; if (thumb != null) { ToolBar toolBar = thumb.TemplatedParent as ToolBar; if (toolBar != null && toolBar.Parent == this) { // _bandsDirty would be true at this time only when a Measure gets // skipped between two mouse moves. Ideally that should not happen // but VS has proved that it can. Hence making the code more robust. // Uncomment the line below if the measure skip issue ever gets fixed. // Debug.Assert(!_bandsDirty, "Bands should not be dirty at this point"); if (_bandsDirty) { GenerateBands(); } bool fHorizontal = (Orientation == Orientation.Horizontal); int currentBand = toolBar.Band; Point pointRelativeToToolBarTray = Mouse.PrimaryDevice.GetPosition((IInputElement)this); Point pointRelativeToToolBar = TransformPointToToolBar(toolBar, pointRelativeToToolBarTray); int hittestBand = GetBandFromOffset(fHorizontal ? pointRelativeToToolBarTray.Y : pointRelativeToToolBarTray.X); double newPosition; double thumbChange = fHorizontal ? e.HorizontalChange : e.VerticalChange; double toolBarPosition; if (fHorizontal) { toolBarPosition = pointRelativeToToolBarTray.X - pointRelativeToToolBar.X; } else { toolBarPosition = pointRelativeToToolBarTray.Y - pointRelativeToToolBar.Y; } newPosition = toolBarPosition + thumbChange; // New toolBar position // Move within the band if (hittestBand == currentBand) { List <ToolBar> band = _bands[currentBand].Band; int toolBarIndex = toolBar.BandIndex; // Move ToolBar within the band if (DoubleUtil.LessThan(thumbChange, 0)) // Move left/up { double toolBarsTotalMinimum = ToolBarsTotalMinimum(band, 0, toolBarIndex - 1); // Check if minimized toolbars will fit in the range if (DoubleUtil.LessThanOrClose(toolBarsTotalMinimum, newPosition)) { ShrinkToolBars(band, 0, toolBarIndex - 1, -thumbChange); } else if (toolBarIndex > 0) // Swap toolbars { ToolBar prevToolBar = band[toolBarIndex - 1]; Point pointRelativeToPreviousToolBar = TransformPointToToolBar(prevToolBar, pointRelativeToToolBarTray); // if pointer in on the left side of previous toolbar if (DoubleUtil.LessThan((fHorizontal ? pointRelativeToPreviousToolBar.X : pointRelativeToPreviousToolBar.Y), 0)) { prevToolBar.BandIndex = toolBarIndex; band[toolBarIndex] = prevToolBar; toolBar.BandIndex = toolBarIndex - 1; band[toolBarIndex - 1] = toolBar; if (toolBarIndex + 1 == band.Count) // If toolBar was the last item in the band { prevToolBar.ClearValue(fHorizontal ? WidthProperty : HeightProperty); } } else { // Move to the left/up and shring the other toolbars if (fHorizontal) { if (DoubleUtil.LessThan(toolBarsTotalMinimum, pointRelativeToToolBarTray.X - pointRelativeToToolBar.X)) { ShrinkToolBars(band, 0, toolBarIndex - 1, pointRelativeToToolBarTray.X - pointRelativeToToolBar.X - toolBarsTotalMinimum); } } else { if (DoubleUtil.LessThan(toolBarsTotalMinimum, pointRelativeToToolBarTray.Y - pointRelativeToToolBar.Y)) { ShrinkToolBars(band, 0, toolBarIndex - 1, pointRelativeToToolBarTray.Y - pointRelativeToToolBar.Y - toolBarsTotalMinimum); } } } } } else // Move right/down { double toolBarsTotalMaximum = ToolBarsTotalMaximum(band, 0, toolBarIndex - 1); if (DoubleUtil.GreaterThan(toolBarsTotalMaximum, newPosition)) { ExpandToolBars(band, 0, toolBarIndex - 1, thumbChange); } else { if (toolBarIndex < band.Count - 1) // Swap toolbars { ToolBar nextToolBar = band[toolBarIndex + 1]; Point pointRelativeToNextToolBar = TransformPointToToolBar(nextToolBar, pointRelativeToToolBarTray); // if pointer in on the right side of next toolbar if (DoubleUtil.GreaterThanOrClose((fHorizontal ? pointRelativeToNextToolBar.X : pointRelativeToNextToolBar.Y), 0)) { nextToolBar.BandIndex = toolBarIndex; band[toolBarIndex] = nextToolBar; toolBar.BandIndex = toolBarIndex + 1; band[toolBarIndex + 1] = toolBar; if (toolBarIndex + 2 == band.Count) // If toolBar becomes the last item in the band { toolBar.ClearValue(fHorizontal ? WidthProperty : HeightProperty); } } else { ExpandToolBars(band, 0, toolBarIndex - 1, thumbChange); } } else { ExpandToolBars(band, 0, toolBarIndex - 1, thumbChange); } } } } else // Move ToolBar to another band { _bandsDirty = true; toolBar.Band = hittestBand; toolBar.ClearValue(fHorizontal ? WidthProperty : HeightProperty); // move to another existing band if (hittestBand >= 0 && hittestBand < _bands.Count) { MoveToolBar(toolBar, hittestBand, newPosition); } List <ToolBar> oldBand = _bands[currentBand].Band; // currentBand should restore sizes to Auto for (int i = 0; i < oldBand.Count; i++) { ToolBar currentToolBar = oldBand[i]; currentToolBar.ClearValue(fHorizontal ? WidthProperty : HeightProperty); } } e.Handled = true; } } }
/// <summary> /// Updates DesiredSize of the ToolBarTray. Called by parent UIElement. /// This is the first pass of layout. /// MeasureOverride distributes all ToolBars in bands depend on Band and BandIndex properties. /// All ToolBars with the same Band are places in one band. After that they are sorted by BandIndex. /// </summary> /// <param name="constraint">Constraint size is an "upper limit" that ToolBarTray should not exceed.</param> /// <returns>ToolBarTray' desired size.</returns> protected override Size MeasureOverride(Size constraint) { GenerateBands(); Size toolBarTrayDesiredSize = new Size(); int bandIndex; int toolBarIndex; bool fHorizontal = (Orientation == Orientation.Horizontal); Size childConstraint = new Size(Double.PositiveInfinity, Double.PositiveInfinity); for (bandIndex = 0; bandIndex < _bands.Count; bandIndex++) { // Calculate the available size before we measure the children. // remainingLength is the constraint minus sum of all minimum sizes double remainingLength = fHorizontal ? constraint.Width : constraint.Height; List <ToolBar> band = _bands[bandIndex].Band; double bandThickness = 0d; double bandLength = 0d; for (toolBarIndex = 0; toolBarIndex < band.Count; toolBarIndex++) { ToolBar toolBar = band[toolBarIndex]; remainingLength -= toolBar.MinLength; if (DoubleUtil.LessThan(remainingLength, 0)) { remainingLength = 0; break; } } // Measure all children passing the remainingLength as a constraint for (toolBarIndex = 0; toolBarIndex < band.Count; toolBarIndex++) { ToolBar toolBar = band[toolBarIndex]; remainingLength += toolBar.MinLength; if (fHorizontal) { childConstraint.Width = remainingLength; } else { childConstraint.Height = remainingLength; } toolBar.Measure(childConstraint); bandThickness = Math.Max(bandThickness, fHorizontal ? toolBar.DesiredSize.Height : toolBar.DesiredSize.Width); bandLength += fHorizontal ? toolBar.DesiredSize.Width : toolBar.DesiredSize.Height; remainingLength -= fHorizontal ? toolBar.DesiredSize.Width : toolBar.DesiredSize.Height; if (DoubleUtil.LessThan(remainingLength, 0)) { remainingLength = 0; } } // Store band thickness in the BandInfo property _bands[bandIndex].Thickness = bandThickness; if (fHorizontal) { toolBarTrayDesiredSize.Height += bandThickness; toolBarTrayDesiredSize.Width = Math.Max(toolBarTrayDesiredSize.Width, bandLength); } else { toolBarTrayDesiredSize.Width += bandThickness; toolBarTrayDesiredSize.Height = Math.Max(toolBarTrayDesiredSize.Height, bandLength); } } return(toolBarTrayDesiredSize); }
/// <summary> /// Helper method which implements the stack like measure. /// </summary> internal static Size StackMeasureHelper(IStackMeasure measureElement, IStackMeasureScrollData scrollData, Size constraint) { Size stackDesiredSize = new Size(); UIElementCollection children = measureElement.InternalChildren; Size layoutSlotSize = constraint; bool fHorizontal = (measureElement.Orientation == Orientation.Horizontal); int firstViewport; // First child index in the viewport. int lastViewport = -1; // Last child index in the viewport. -1 indicates we have not yet iterated through the last child. double logicalVisibleSpace, childLogicalSize; // // Initialize child sizing and iterator data // Allow children as much size as they want along the stack. // if (fHorizontal) { layoutSlotSize.Width = Double.PositiveInfinity; if (measureElement.IsScrolling && measureElement.CanVerticallyScroll) { layoutSlotSize.Height = Double.PositiveInfinity; } firstViewport = (measureElement.IsScrolling) ? CoerceOffsetToInteger(scrollData.Offset.X, children.Count) : 0; logicalVisibleSpace = constraint.Width; } else { layoutSlotSize.Height = Double.PositiveInfinity; if (measureElement.IsScrolling && measureElement.CanHorizontallyScroll) { layoutSlotSize.Width = Double.PositiveInfinity; } firstViewport = (measureElement.IsScrolling) ? CoerceOffsetToInteger(scrollData.Offset.Y, children.Count) : 0; logicalVisibleSpace = constraint.Height; } // // Iterate through children. // While we still supported virtualization, this was hidden in a child iterator (see source history). // for (int i = 0, count = children.Count; i < count; ++i) { // Get next child. UIElement child = children[i]; if (child == null) { continue; } // Measure the child. child.Measure(layoutSlotSize); Size childDesiredSize = child.DesiredSize; // Accumulate child size. if (fHorizontal) { stackDesiredSize.Width += childDesiredSize.Width; stackDesiredSize.Height = Math.Max(stackDesiredSize.Height, childDesiredSize.Height); childLogicalSize = childDesiredSize.Width; } else { stackDesiredSize.Width = Math.Max(stackDesiredSize.Width, childDesiredSize.Width); stackDesiredSize.Height += childDesiredSize.Height; childLogicalSize = childDesiredSize.Height; } // Adjust remaining viewport space if we are scrolling and within the viewport region. // While scrolling (not virtualizing), we always measure children before and after the viewport. if (measureElement.IsScrolling && lastViewport == -1 && i >= firstViewport) { logicalVisibleSpace -= childLogicalSize; if (DoubleUtil.LessThanOrClose(logicalVisibleSpace, 0.0)) { lastViewport = i; } } } // // Compute Scrolling stuff. // if (measureElement.IsScrolling) { // Compute viewport and extent. Size viewport = constraint; Size extent = stackDesiredSize; Vector offset = scrollData.Offset; // If we have not yet set the last child in the viewport, set it to the last child. if (lastViewport == -1) { lastViewport = children.Count - 1; } // If we or children have resized, it's possible that we can now display more content. // This is true if we started at a nonzero offeset and still have space remaining. // In this case, we loop back through previous children until we run out of space. while (firstViewport > 0) { double projectedLogicalVisibleSpace = logicalVisibleSpace; if (fHorizontal) { projectedLogicalVisibleSpace -= children[firstViewport - 1].DesiredSize.Width; } else { projectedLogicalVisibleSpace -= children[firstViewport - 1].DesiredSize.Height; } // If we have run out of room, break. if (DoubleUtil.LessThan(projectedLogicalVisibleSpace, 0.0)) { break; } // Adjust viewport firstViewport--; logicalVisibleSpace = projectedLogicalVisibleSpace; } int logicalExtent = children.Count; int logicalViewport = lastViewport - firstViewport; // We are conservative when estimating a viewport, not including the last element in case it is only partially visible. // We want to count it if it is fully visible (>= 0 space remaining) or the only element in the viewport. if (logicalViewport == 0 || DoubleUtil.GreaterThanOrClose(logicalVisibleSpace, 0.0)) { logicalViewport++; } if (fHorizontal) { scrollData.SetPhysicalViewport(viewport.Width); viewport.Width = logicalViewport; extent.Width = logicalExtent; offset.X = firstViewport; offset.Y = Math.Max(0, Math.Min(offset.Y, extent.Height - viewport.Height)); } else { scrollData.SetPhysicalViewport(viewport.Height); viewport.Height = logicalViewport; extent.Height = logicalExtent; offset.Y = firstViewport; offset.X = Math.Max(0, Math.Min(offset.X, extent.Width - viewport.Width)); } // Since we can offset and clip our content, we never need to be larger than the parent suggestion. // If we returned the full size of the content, we would always be so big we didn't need to scroll. :) stackDesiredSize.Width = Math.Min(stackDesiredSize.Width, constraint.Width); stackDesiredSize.Height = Math.Min(stackDesiredSize.Height, constraint.Height); // Verify Scroll Info, invalidate ScrollOwner if necessary. VerifyScrollingData(measureElement, scrollData, viewport, extent, offset); } return(stackDesiredSize); }
private void MakeVisibleLogicalHelper(int childIndex, ref Vector newOffset, ref Rect newRect) { bool fHorizontal = (Orientation == Orientation.Horizontal); int firstChildInView; int newFirstChild; int viewportSize; double childOffsetWithinViewport = 0; if (fHorizontal) { firstChildInView = (int)_scrollData._computedOffset.X; viewportSize = (int)_scrollData._viewport.Width; } else { firstChildInView = (int)_scrollData._computedOffset.Y; viewportSize = (int)_scrollData._viewport.Height; } newFirstChild = firstChildInView; // If the target child is before the current viewport, move the viewport to put the child at the top. if (childIndex < firstChildInView) { newFirstChild = childIndex; } // If the target child is after the current viewport, move the viewport to put the child at the bottom. else if (childIndex > firstChildInView + viewportSize - 1) { Size childDesiredSize = InternalChildren[childIndex].DesiredSize; double nextChildSize = ((fHorizontal) ? childDesiredSize.Width : childDesiredSize.Height); double viewportSpace = _scrollData._physicalViewport - nextChildSize; int i = childIndex; while (i > 0 && DoubleUtil.GreaterThanOrClose(viewportSpace, 0.0)) { i--; childDesiredSize = InternalChildren[i].DesiredSize; nextChildSize = ((fHorizontal) ? childDesiredSize.Width : childDesiredSize.Height); childOffsetWithinViewport += nextChildSize; viewportSpace -= nextChildSize; } if (i != childIndex && DoubleUtil.LessThan(viewportSpace, 0.0)) { childOffsetWithinViewport -= nextChildSize; i++; } newFirstChild = i; } if (fHorizontal) { newOffset.X = newFirstChild; newRect.X = childOffsetWithinViewport; newRect.Width = InternalChildren[childIndex].DesiredSize.Width; } else { newOffset.Y = newFirstChild; newRect.Y = childOffsetWithinViewport; newRect.Height = InternalChildren[childIndex].DesiredSize.Height; } }
// 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); }