// Token: 0x060071D4 RID: 29140 RVA: 0x002085B4 File Offset: 0x002067B4 public void RecalcRows(int pivotPage, int columns) { if (this.PageCache == null) { throw new InvalidOperationException(SR.Get("RowCacheRecalcWithNoPageCache")); } if (pivotPage < 0 || pivotPage > this.PageCache.PageCount) { throw new ArgumentOutOfRangeException("pivotPage"); } if (columns < 1) { throw new ArgumentOutOfRangeException("columns"); } this._layoutColumns = columns; this._layoutPivotPage = pivotPage; this._hasValidLayout = false; if (this.PageCache.PageCount < this._layoutColumns) { if (!this.PageCache.IsPaginationCompleted || this.PageCache.PageCount == 0) { this._isLayoutRequested = true; this._isLayoutCompleted = false; return; } this._layoutColumns = Math.Min(this._layoutColumns, this.PageCache.PageCount); this._layoutColumns = Math.Max(1, this._layoutColumns); this._layoutPivotPage = 0; } this._extentHeight = 0.0; this._extentWidth = 0.0; if (this.PageCache.DynamicPageSizes) { this._pivotRowIndex = this.RecalcRowsForDynamicPageSizes(this._layoutPivotPage, this._layoutColumns); } else { this._pivotRowIndex = this.RecalcRowsForFixedPageSizes(this._layoutPivotPage, this._layoutColumns); } this._isLayoutCompleted = true; this._isLayoutRequested = false; this._hasValidLayout = true; RowLayoutCompletedEventArgs e = new RowLayoutCompletedEventArgs(this._pivotRowIndex); this.RowLayoutCompleted(this, e); RowCacheChangedEventArgs e2 = new RowCacheChangedEventArgs(new List <RowCacheChange>(1) { new RowCacheChange(0, this._rowCache.Count) }); this.RowCacheChanged(this, e2); }
/// <summary> /// Recalculates the row layout given a starting page, and the number of pages to lay out /// on each row. /// In the event that there aren't currently enough pages to accomplish the layout, RowCache /// will wait until the pages are available and then fire off a RowLayoutCompleted event. /// </summary> /// <param name="pivotPage">The page to build the rows around</param> /// <param name="columns">The number of columns in the "pivot row"</param> public void RecalcRows(int pivotPage, int columns) { //Throw execption if we have no PageCache if (PageCache == null) { throw new InvalidOperationException(SR.Get(SRID.RowCacheRecalcWithNoPageCache)); } //Throw exception for illegal values if (pivotPage < 0 || pivotPage > PageCache.PageCount) { throw new ArgumentOutOfRangeException("pivotPage"); } //Can't lay out fewer than 1 column of pages. if (columns < 1) { throw new ArgumentOutOfRangeException("columns"); } //Store off the requested layout parameters. _layoutColumns = columns; _layoutPivotPage = pivotPage; //We've started a new layout, reset the valid layout flag. _hasValidLayout = false; //We can't do anything here if we haven't gotten enough pages to create the first row yet. //But we'll save off the specified columns & pivot page (above) //And as soon as we get some pages (in OnPageCacheChanged) //we'll start laying them out in the requested manner. if (PageCache.PageCount < _layoutColumns) { //If pagination is still happening or if we have no pages in our content //we need to wait until later. if (!PageCache.IsPaginationCompleted || PageCache.PageCount == 0) { //Reset our LayoutComputed flag, as we've been tasked to create a new one //but can't do it yet. _isLayoutRequested = true; _isLayoutCompleted = false; return; } //If pagination has completed, we trim down the column count and continue. else { //We're done paginating, but we don't have enough //pages to do the requested layout. So we'll need to trim down the column count, with a //lower bound of 1 column. _layoutColumns = Math.Min(_layoutColumns, PageCache.PageCount); _layoutColumns = Math.Max(1, _layoutColumns); //The pivot page is always the first page in this instance _layoutPivotPage = 0; } } //Reset the document extents, which will be recalculated by the RecalcRows methods. _extentHeight = 0.0; _extentWidth = 0.0; //Now call the specific RecalcRows... method for our document type. if (PageCache.DynamicPageSizes) { _pivotRowIndex = RecalcRowsForDynamicPageSizes(_layoutPivotPage, _layoutColumns); } else { _pivotRowIndex = RecalcRowsForFixedPageSizes(_layoutPivotPage, _layoutColumns); } _isLayoutCompleted = true; _isLayoutRequested = false; //Set the valid layout flag now that we're done _hasValidLayout = true; //We've computed the layout, so we'll fire off our RowLayoutCompleted event. //We pass along the pivotRow's Index so the listener can keep the pivot row visible. RowLayoutCompletedEventArgs args = new RowLayoutCompletedEventArgs(_pivotRowIndex); RowLayoutCompleted(this, args); //Fire off our RowCacheChanged event indicating that all rows have changed. List<RowCacheChange> changes = new List<RowCacheChange>(1); changes.Add(new RowCacheChange(0, _rowCache.Count)); RowCacheChangedEventArgs args2 = new RowCacheChangedEventArgs(changes); RowCacheChanged(this, args2); }
/// <summary> /// When a new RowLayout has finished being computed we scale the layout such that it /// fits within our window. /// </summary> /// <param name="source"></param> /// <param name="args"></param> private void OnRowLayoutCompleted(object source, RowLayoutCompletedEventArgs args) { if (args == null) { return; } if (args.PivotRowIndex >= _rowCache.RowCount) { throw new ArgumentOutOfRangeException("args"); } //Get the pivot row RowInfo pivotRow = _rowCache.GetRow(args.PivotRowIndex); //If this row is not clean, and we're not applying a //Zoom to the content then we need to rescale the layout when the //pages on this row are retrieved. if (!RowIsClean(pivotRow) && _documentLayout.ViewMode != ViewMode.Zoom) { //Save off this row in case we need to rescale due to //dirty cache entries becoming clean (i.e. page sizes changing //due to the cached size being an inaccurate guess.) //OnRowCacheChanged will check this row to ensure that it gets scaled //properly when all the pages on the row become available. _savedPivotRow = pivotRow; } else { _savedPivotRow = null; } //Now rescale. We do this after checking the cleanliness of the row //so that _savedPivotRow is properly set before we apply our view parameters. //Otherwise the code that relies on it in OnRowCacheChanged (which may be called //as a result of calling ApplyViewParameters) may use the wrong row. ApplyViewParameters(pivotRow); //Now that we've recalculated the row layout, it's time to make the previously-visible //content visible again. //We do not do this the first time the content is assigned, for two reasons, //(similar to the ones described in DocumentViewer.OnDocumentChanged()): // 1) If this is the first assignment, then we're already there by default. // 2) The user may have specified vertical or horizontal offsets in markup or // otherwise (<DocumentViewer VerticalOffset="1000">) and we need to honor // those settings. if (!_firstRowLayout && !_pageJumpAfterLayout) { MakePageVisible(pivotRow.FirstPage); } else if (_pageJumpAfterLayout) { MakePageVisible(_pageJumpAfterLayoutPageNumber); _pageJumpAfterLayout = false; } _firstRowLayout = false; //If our view was of a "Fit" type, we need to ensure that the fit is //correct -- if the status of Vertical/Horizontal Scrollbars has changed //as a result of our view selection then the Viewport size may have changed. //If so, our current fit is probably wrong. We'll attach a ScrollChanged handler //to our ScrollOwner and when the event is invoked (after layout, but before rendering) //we'll check. //This is "Step 2" of the two-pass layout necessary to do fit properly inside of a //ScrollViewer. if (!_scrollChangedEventAttached && ScrollOwner != null && _documentLayout.ViewMode != ViewMode.Zoom && _documentLayout.ViewMode != ViewMode.SetColumns) { _scrollChangedEventAttached = true; ScrollOwner.ScrollChanged += new ScrollChangedEventHandler(OnScrollChanged); } }