// Token: 0x0600585D RID: 22621 RVA: 0x00187A60 File Offset: 0x00185C60 private void ExpandToolBars(List <ToolBar> band, int startIndex, int endIndex, double expandAmount) { if (this.Orientation == Orientation.Horizontal) { for (int i = endIndex; i >= startIndex; i--) { ToolBar toolBar = band[i]; if (DoubleUtil.LessThanOrClose(toolBar.RenderSize.Width + expandAmount, toolBar.MaxLength)) { toolBar.Width = toolBar.RenderSize.Width + expandAmount; return; } toolBar.Width = toolBar.MaxLength; expandAmount -= toolBar.MaxLength - toolBar.RenderSize.Width; } return; } for (int j = endIndex; j >= startIndex; j--) { ToolBar toolBar2 = band[j]; if (DoubleUtil.LessThanOrClose(toolBar2.RenderSize.Height + expandAmount, toolBar2.MaxLength)) { toolBar2.Height = toolBar2.RenderSize.Height + expandAmount; return; } toolBar2.Height = toolBar2.MaxLength; expandAmount -= toolBar2.MaxLength - toolBar2.RenderSize.Height; } }
// Token: 0x06004D4C RID: 19788 RVA: 0x0015BEE0 File Offset: 0x0015A0E0 private void OnColumnHeaderResize(object sender, DragDeltaEventArgs e) { double num = this.ColumnActualWidth + e.HorizontalChange; if (DoubleUtil.LessThanOrClose(num, 0.0)) { num = 0.0; } this.UpdateColumnHeaderWidth(num); e.Handled = true; }
// Resize the header private void OnColumnHeaderResize(object sender, DragDeltaEventArgs e) { double width = ColumnActualWidth + e.HorizontalChange; if (DoubleUtil.LessThanOrClose(width, 0.0)) { width = 0.0; } UpdateColumnHeaderWidth(width); e.Handled = true; }
private void MoveToolBar(ToolBar toolBar, int newBandNumber, double position) { int i; bool fHorizontal = Orientation == Orientation.Horizontal; List <ToolBar> newBand = _bands[newBandNumber].Band; // calculate the new BandIndex where toolBar should insert // calculate Width (layout) of the items before the toolBar if (DoubleUtil.LessThanOrClose(position, 0)) { toolBar.BandIndex = -1; // This will position toolBar at the first place } else { double toolBarOffset = 0d; int newToolBarIndex = -1; for (i = 0; i < newBand.Count; i++) { ToolBar currentToolBar = newBand[i]; if (newToolBarIndex == -1) { toolBarOffset += fHorizontal ? currentToolBar.RenderSize.Width : currentToolBar.RenderSize.Height; // points at the end of currentToolBar if (DoubleUtil.GreaterThan(toolBarOffset, position)) { newToolBarIndex = i + 1; toolBar.BandIndex = newToolBarIndex; // Update the currentToolBar width if (fHorizontal) { currentToolBar.Width = Math.Max(currentToolBar.MinLength, currentToolBar.RenderSize.Width - toolBarOffset + position); } else { currentToolBar.Height = Math.Max(currentToolBar.MinLength, currentToolBar.RenderSize.Height - toolBarOffset + position); } } } else // After we insert the toolBar we need to increase the indexes { currentToolBar.BandIndex = i + 1; } } if (newToolBarIndex == -1) { toolBar.BandIndex = i; } } }
// Token: 0x0600585F RID: 22623 RVA: 0x00187B94 File Offset: 0x00185D94 private void MoveToolBar(ToolBar toolBar, int newBandNumber, double position) { bool flag = this.Orientation == Orientation.Horizontal; List <ToolBar> band = this._bands[newBandNumber].Band; if (DoubleUtil.LessThanOrClose(position, 0.0)) { toolBar.BandIndex = -1; return; } double num = 0.0; int num2 = -1; int i; for (i = 0; i < band.Count; i++) { ToolBar toolBar2 = band[i]; if (num2 == -1) { num += (flag ? toolBar2.RenderSize.Width : toolBar2.RenderSize.Height); if (DoubleUtil.GreaterThan(num, position)) { num2 = i + 1; toolBar.BandIndex = num2; if (flag) { toolBar2.Width = Math.Max(toolBar2.MinLength, toolBar2.RenderSize.Width - num + position); } else { toolBar2.Height = Math.Max(toolBar2.MinLength, toolBar2.RenderSize.Height - num + position); } } } else { toolBar2.BandIndex = i + 1; } } if (num2 == -1) { toolBar.BandIndex = i; } }
private void ExpandToolBars(List <ToolBar> band, int startIndex, int endIndex, double expandAmount) { if (Orientation == Orientation.Horizontal) { for (int i = endIndex; i >= startIndex; i--) { ToolBar toolBar = band[i]; if (DoubleUtil.LessThanOrClose(toolBar.RenderSize.Width + expandAmount, toolBar.MaxLength)) { toolBar.Width = toolBar.RenderSize.Width + expandAmount; break; } else { toolBar.Width = toolBar.MaxLength; expandAmount -= toolBar.MaxLength - toolBar.RenderSize.Width; } } } else { for (int i = endIndex; i >= startIndex; i--) { ToolBar toolBar = band[i]; if (DoubleUtil.LessThanOrClose(toolBar.RenderSize.Height + expandAmount, toolBar.MaxLength)) { toolBar.Height = toolBar.RenderSize.Height + expandAmount; break; } else { toolBar.Height = toolBar.MaxLength; expandAmount -= toolBar.MaxLength - toolBar.RenderSize.Height; } } } }
private bool CheckIsPointBetween(Rect rect, double pointY) { // return rect.Top <= pointY <= rect.Bottom return(DoubleUtil.LessThanOrClose(rect.Top, pointY) && DoubleUtil.LessThanOrClose(pointY, rect.Bottom)); }
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> /// 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); }
// 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); }
// 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; } } }