private void SetHorizontalOffset(double physicalOffset, bool updateUI, bool updateScrollViewer) { var adjustedOffset = ListViewModel.DoubleArithmetics.Ceiling(physicalOffset); bool needUpdate = !LayoutDoubleUtil.AreClose(this.lastScrollOffset.X, physicalOffset) || physicalOffset < 0; var previousOffset = this.lastScrollOffset.X; this.lastScrollOffset.X = adjustedOffset; if (needUpdate) { if (this.childrenPanel != null && (updateUI || this.strategy.RequiresUpdate(this.panelAvailableSize, previousOffset, adjustedOffset))) { this.contentMeasureRequested = false; this.childrenPanel.measureRequested = true; this.childrenPanel.InvalidateMeasure(); } if (updateScrollViewer) { this.scrollViewer.ChangeView(adjustedOffset, null, null, true); // Ensure that scrollviewer has updated its position. if (updateUI) { this.scrollViewer.UpdateLayout(); } } } }
// Move the splitter by the given Delta's in the horizontal and vertical directions private void MoveSplitter(double horizontalChange, double verticalChange) { double delta; var dpi = this.GetDpi(); if (_resizeData.Panel.Orientation == Orientation.Horizontal) { delta = horizontalChange; if (UseLayoutRounding) { delta = LayoutDoubleUtil.RoundLayoutValue(delta, dpi.DpiScaleX); } } else { delta = verticalChange; if (UseLayoutRounding) { delta = LayoutDoubleUtil.RoundLayoutValue(delta, dpi.DpiScaleY); } } var definition1 = _resizeData.Definition1; var definition2 = _resizeData.Definition2; if (definition1 != null && definition2 != null) { double actualLength1 = definition1.ActualSize; double actualLength2 = definition2.ActualSize; // When splitting, Check to see if the total pixels spanned by the definitions // is the same as before starting resize. If not cancel the drag if (_resizeData.SplitBehavior == SplitBehavior.ResizeBoth && !LayoutDoubleUtil.AreClose(actualLength1 + actualLength2, _resizeData.OriginalDefinition1ActualLength + _resizeData.OriginalDefinition2ActualLength)) { CancelResize(); return; } double min, max; GetDeltaConstraints(out min, out max); // Flip when the splitter's flow direction isn't the same as the grid's if (FlowDirection != _resizeData.Panel.FlowDirection) { delta = -delta; } delta = Math.Min(Math.Max(delta, min), max); double definition1LengthNew = actualLength1 + delta; double definition2LengthNew = actualLength1 + actualLength2 - definition1LengthNew; SetLengths(definition1LengthNew, definition2LengthNew); } }
// Move the splitter by the given Delta's in the horizontal and vertical directions private void MoveSplitter(double horizontalChange, double verticalChange) { Debug.Assert(_resizeData != null, "_resizeData should not be null when calling MoveSplitter"); double delta; DpiScale dpi = GetDpi(); // Calculate the offset to adjust the splitter. If layout rounding is enabled, we // need to round to an integer physical pixel value to avoid round-ups of children that // expand the bounds of the Grid. In practice this only happens in high dpi because // horizontal/vertical offsets here are never fractional (they correspond to mouse movement // across logical pixels). Rounding error only creeps in when converting to a physical // display with something other than the logical 96 dpi. if (_resizeData.ResizeDirection == GridResizeDirection.Columns) { delta = horizontalChange; if (this.UseLayoutRounding) { delta = UIElement.RoundLayoutValue(delta, dpi.DpiScaleX); } } else { delta = verticalChange; if (this.UseLayoutRounding) { delta = UIElement.RoundLayoutValue(delta, dpi.DpiScaleY); } } DefinitionBase definition1 = _resizeData.Definition1; DefinitionBase definition2 = _resizeData.Definition2; if (definition1 != null && definition2 != null) { double actualLength1 = GetActualLength(definition1); double actualLength2 = GetActualLength(definition2); // When splitting, Check to see if the total pixels spanned by the definitions // is the same asbefore starting resize. If not cancel the drag if (_resizeData.SplitBehavior == SplitBehavior.Split && !LayoutDoubleUtil.AreClose(actualLength1 + actualLength2, _resizeData.OriginalDefinition1ActualLength + _resizeData.OriginalDefinition2ActualLength)) { CancelResize(); return; } double min, max; GetDeltaConstraints(out min, out max); // Flip when the splitter's flow direction isn't the same as the grid's if (FlowDirection != _resizeData.Grid.FlowDirection) { delta = -delta; } // Constrain Delta to Min/MaxWidth of columns delta = Math.Min(Math.Max(delta, min), max); // With floating point operations there may be loss of precision to some degree. Eg. Adding a very // small value to a very large one might result in the small value being ignored. In the following // steps there are two floating point operations viz. actualLength1+delta and actualLength2-delta. // It is possible that the addition resulted in loss of precision and the delta value was ignored, whereas // the subtraction actual absorbed the delta value. This now means that // (definition1LengthNew + definition2LengthNewis) 2 factors of precision away from // (actualLength1 + actualLength2). This can cause a problem in the subsequent drag iteration where // this will be interpreted as the cancellation of the resize operation. To avoid this imprecision we use // make definition2LengthNew be a function of definition1LengthNew so that the precision or the loss // thereof can be counterbalanced. See DevDiv bug#140228 for a manifestation of this problem. double definition1LengthNew = actualLength1 + delta; //double definition2LengthNew = actualLength2 - delta; double definition2LengthNew = actualLength1 + actualLength2 - definition1LengthNew; SetLengths(definition1LengthNew, definition2LengthNew); } }
// Token: 0x06004DDF RID: 19935 RVA: 0x0015F644 File Offset: 0x0015D844 private void MoveSplitter(double horizontalChange, double verticalChange) { DpiScale dpi = base.GetDpi(); double num; if (this._resizeData.ResizeDirection == GridResizeDirection.Columns) { num = horizontalChange; if (base.UseLayoutRounding) { num = UIElement.RoundLayoutValue(num, dpi.DpiScaleX); } } else { num = verticalChange; if (base.UseLayoutRounding) { num = UIElement.RoundLayoutValue(num, dpi.DpiScaleY); } } DefinitionBase definition = this._resizeData.Definition1; DefinitionBase definition2 = this._resizeData.Definition2; if (definition != null && definition2 != null) { double actualLength = this.GetActualLength(definition); double actualLength2 = this.GetActualLength(definition2); if (this._resizeData.SplitBehavior == GridSplitter.SplitBehavior.Split && !LayoutDoubleUtil.AreClose(actualLength + actualLength2, this._resizeData.OriginalDefinition1ActualLength + this._resizeData.OriginalDefinition2ActualLength)) { this.CancelResize(); return; } double val; double val2; this.GetDeltaConstraints(out val, out val2); if (base.FlowDirection != this._resizeData.Grid.FlowDirection) { num = -num; } num = Math.Min(Math.Max(num, val), val2); double num2 = actualLength + num; double definition2Pixels = actualLength + actualLength2 - num2; this.SetLengths(num2, definition2Pixels); } }