/// <summary>Scrolls to the specified coordinates and makes that part of a <see cref="T:System.Windows.Media.Visual" /> visible. </summary> /// <param name="visual">The <see cref="T:System.Windows.Media.Visual" /> that becomes visible.</param> /// <param name="rectangle">The <see cref="T:System.Windows.Rect" /> that represents coordinate space within a visual.</param> /// <returns>A <see cref="T:System.Windows.Rect" /> in the coordinate space that is made visible.</returns> // Token: 0x06005686 RID: 22150 RVA: 0x0017ED84 File Offset: 0x0017CF84 public Rect MakeVisible(Visual visual, Rect rectangle) { Vector vector = default(Vector); Rect result = default(Rect); if (rectangle.IsEmpty || visual == null || visual == this || !base.IsAncestorOf(visual)) { return(Rect.Empty); } GeneralTransform generalTransform = visual.TransformToAncestor(this); rectangle = generalTransform.TransformBounds(rectangle); if (!this.IsScrolling) { return(rectangle); } this.MakeVisiblePhysicalHelper(rectangle, ref vector, ref result); int childIndex = this.FindChildIndexThatParentsVisual(visual); this.MakeVisibleLogicalHelper(childIndex, ref vector, ref result); vector.X = ScrollContentPresenter.CoerceOffset(vector.X, this._scrollData._extent.Width, this._scrollData._viewport.Width); vector.Y = ScrollContentPresenter.CoerceOffset(vector.Y, this._scrollData._extent.Height, this._scrollData._viewport.Height); if (!DoubleUtil.AreClose(vector, this._scrollData._offset)) { this._scrollData._offset = vector; base.InvalidateMeasure(); this.OnScrollChange(); } return(result); }
// Token: 0x06005462 RID: 21602 RVA: 0x00175D24 File Offset: 0x00173F24 private bool CoerceOffsets() { Vector vector = new Vector(ScrollContentPresenter.CoerceOffset(this._scrollData._offset.X, this._scrollData._extent.Width, this._scrollData._viewport.Width), ScrollContentPresenter.CoerceOffset(this._scrollData._offset.Y, this._scrollData._extent.Height, this._scrollData._viewport.Height)); bool result = DoubleUtil.AreClose(this._scrollData._computedOffset, vector); this._scrollData._computedOffset = vector; return(result); }
/// <summary> /// StackPanel implementation of <seealso cref="IScrollInfo.MakeVisible" />. /// </summary> // The goal is to change offsets to bring the child into view, and return a rectangle in our space to make visible. // The rectangle we return is in the physical dimension the input target rect transformed into our pace. // In the logical dimension, it is our immediate child's rect. // Note: This code presently assumes we/children are layout clean. See work item 22269 for more detail. public Rect MakeVisible(Visual visual, Rect rectangle) { Vector newOffset = new Vector(); Rect newRect = new Rect(); // We can only work on visuals that are us or children. // An empty rect has no size or position. We can't meaningfully use it. if (rectangle.IsEmpty || visual == null || visual == (Visual)this || !this.IsAncestorOf(visual)) { return(Rect.Empty); } #pragma warning disable 1634, 1691 #pragma warning disable 56506 // Compute the child's rect relative to (0,0) in our coordinate space. // This is a false positive by PreSharp. visual cannot be null because of the 'if' check above GeneralTransform childTransform = visual.TransformToAncestor(this); #pragma warning restore 56506 #pragma warning restore 1634, 1691 rectangle = childTransform.TransformBounds(rectangle); // We can't do any work unless we're scrolling. if (!IsScrolling) { return(rectangle); } // Bring the target rect into view in the physical dimension. MakeVisiblePhysicalHelper(rectangle, ref newOffset, ref newRect); // Bring our child containing the visual into view. int childIndex = FindChildIndexThatParentsVisual(visual); MakeVisibleLogicalHelper(childIndex, ref newOffset, ref newRect); // We have computed the scrolling offsets; validate and scroll to them. newOffset.X = ScrollContentPresenter.CoerceOffset(newOffset.X, _scrollData._extent.Width, _scrollData._viewport.Width); newOffset.Y = ScrollContentPresenter.CoerceOffset(newOffset.Y, _scrollData._extent.Height, _scrollData._viewport.Height); if (!DoubleUtil.AreClose(newOffset, _scrollData._offset)) { _scrollData._offset = newOffset; InvalidateMeasure(); OnScrollChange(); } // Return the rectangle return(newRect); }