Ejemplo n.º 1
0
        // Token: 0x060071D3 RID: 29139 RVA: 0x00208460 File Offset: 0x00206660
        public void RecalcLayoutForScaleOrSpacing()
        {
            if (this.PageCache == null)
            {
                throw new InvalidOperationException(SR.Get("RowCacheRecalcWithNoPageCache"));
            }
            this._extentWidth  = 0.0;
            this._extentHeight = 0.0;
            double num = 0.0;

            for (int i = 0; i < this._rowCache.Count; i++)
            {
                RowInfo rowInfo   = this._rowCache[i];
                int     pageCount = rowInfo.PageCount;
                rowInfo.ClearPages();
                rowInfo.VerticalOffset = num;
                for (int j = rowInfo.FirstPage; j < rowInfo.FirstPage + pageCount; j++)
                {
                    Size scaledPageSize = this.GetScaledPageSize(j);
                    rowInfo.AddPage(scaledPageSize);
                }
                this._extentWidth = Math.Max(rowInfo.RowSize.Width, this._extentWidth);
                num += rowInfo.RowSize.Height;
                this._extentHeight += rowInfo.RowSize.Height;
                this._rowCache[i]   = rowInfo;
            }
            RowCacheChangedEventArgs e = new RowCacheChangedEventArgs(new List <RowCacheChange>(1)
            {
                new RowCacheChange(0, this._rowCache.Count)
            });

            this.RowCacheChanged(this, e);
        }
Ejemplo n.º 2
0
        // 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);
        }
Ejemplo n.º 3
0
        /// <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);
            
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Recalculates the current row layout by applying the current Scale
        /// and PageSpacing to the current row layout.  It does not change the
        /// contents of the rows.
        /// </summary>
        public void RecalcLayoutForScaleOrSpacing()
        {
            //Throw execption if we have no PageCache
            if (PageCache == null)
            {
                throw new InvalidOperationException(SR.Get(SRID.RowCacheRecalcWithNoPageCache));
            }

            //Reset the extents
            _extentWidth = 0.0;
            _extentHeight = 0.0;

            //Walk through each row and based on the pages on the row,
            //recalculate the width and height of the row.
            double currentOffset = 0.0;
            for (int i = 0; i < _rowCache.Count; i++)
            {
                //Get this row and save off the page count.
                RowInfo currentRow = _rowCache[i];
                int pageCount = currentRow.PageCount;

                //Clear the pages so we can add the new, rescaled ones.
                currentRow.ClearPages();
                currentRow.VerticalOffset = currentOffset;

                //Add each page to the row.
                for (int j = currentRow.FirstPage; j < currentRow.FirstPage + pageCount; j++)
                {
                    Size pageSize = GetScaledPageSize(j);
                    currentRow.AddPage(pageSize);                    
                }

                //Adjust the extent width if necessary                
                _extentWidth = Math.Max(currentRow.RowSize.Width, _extentWidth);                

                currentOffset += currentRow.RowSize.Height;
                _extentHeight += currentRow.RowSize.Height;
                _rowCache[i] = currentRow;                
            }

            //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 args = new RowCacheChangedEventArgs(changes);
            RowCacheChanged(this, args);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Event Handler for the PageCacheChanged event.  Called whenever an entry in the
        /// PageCache is changed.  When this happens, the RowCache needs to Add, Remove, or
        /// Update row entries corresponding to the pages changed.
        /// </summary>
        /// <param name="sender">The object that sent this event.</param>
        /// <param name="args">The associated arguments.</param>
        private void OnPageCacheChanged(object sender, PageCacheChangedEventArgs args)
        {            
            //If we have a computed layout then we'll add/remove/frob rows to conform
            //to that layout.            
            if (_isLayoutCompleted)
            {
                List<RowCacheChange> changes = new List<RowCacheChange>(args.Changes.Count);
                for (int i = 0; i < args.Changes.Count; i++)
                {                    
                    PageCacheChange pageChange = args.Changes[i];
                    switch (pageChange.Type)
                    {
                        case PageCacheChangeType.Add:
                        case PageCacheChangeType.Update:
                            if (pageChange.Start > LastPageInCache)
                            {
                                //Completely new pages, so we add new cache entries
                                RowCacheChange change = AddPageRange(pageChange.Start, pageChange.Count);
                                if (change != null)
                                {
                                    changes.Add(change);
                                }
                            }
                            else
                            {
                                if (pageChange.Start + pageChange.Count - 1 <= LastPageInCache)
                                {
                                    //All pre-existing pages, so we just update the current cache entries.
                                    RowCacheChange change = UpdatePageRange(pageChange.Start, pageChange.Count);
                                    if (change != null)
                                    {
                                        changes.Add(change);
                                    }
                                }
                                else
                                {
                                    //Some pre-existing pages, some new.                        
                                    RowCacheChange change;
                                    change = UpdatePageRange(pageChange.Start, LastPageInCache - pageChange.Start);
                                    if (change != null)
                                    {
                                        changes.Add(change);
                                    }
                                    change = AddPageRange(LastPageInCache + 1, pageChange.Count - (LastPageInCache - pageChange.Start));
                                    if (change != null)
                                    {
                                        changes.Add(change);
                                    }
                                }
                            }
                            break;

                        case PageCacheChangeType.Remove:
                            //If PageCount is now less than the size of our cache due to repagination
                            //we remove the corresponding entries from our row cache.
                            if (PageCache.PageCount - 1 < LastPageInCache)
                            {
                                //Remove pages starting at the first no-longer-existent page.
                                //(PageCache.PageCount now points to the first dead page)
                                RowCacheChange change = TrimPageRange(PageCache.PageCount);
                                if (change != null)
                                {
                                    changes.Add(change);
                                }
                            }

                            //If because of the above trimming we have fewer pages left 
                            //in the document than the columns that were initially requested
                            //We'll need to recalc our layout from scratch.
                            //First we check to see if we have one or fewer rows left.
                            if (_rowCache.Count <= 1)
                            {
                                //If we have either no rows left or the remaining row has
                                //less than _layoutColumns pages on it, we need to recalc from the first page.
                                if (_rowCache.Count == 0 || _rowCache[0].PageCount < _layoutColumns )
                                {
                                    RecalcRows(0, _layoutColumns);
                                }                                
                            }
                            break;

                        default:
                            throw new ArgumentOutOfRangeException("args");                        
                    }                    
                }
                
                RowCacheChangedEventArgs newArgs = new RowCacheChangedEventArgs(changes);
                RowCacheChanged(this, newArgs);
            }
            else if (_isLayoutRequested)
            {
                //We've had a request to create a layout previously, but didn't have enough pages to do so before.
                //Try it now.
                RecalcRows(_layoutPivotPage, _layoutColumns);
            }            
        }   
Ejemplo n.º 6
0
        /// <summary>
        /// When the RowCache is changed for any reason (due to a new layout, or if pages change, etc...) 
        /// then we need to invalidate our Measure (so we can pick up any changes to visible pages) 
        /// and invalidate our IDocumentScrollInfo parents so they know that something's changed.
        /// </summary> 
        /// <param name="source"></param>
        /// <param name="args"></param>
        private void OnRowCacheChanged(object source, RowCacheChangedEventArgs args)
        { 

            //If: 
            //1) We have a saved pivot row from a previous RowCacheCompleted event, 
            //and
            //2) We've been told to do a "Page-Fit" operation (that is, a non-zoom viewing preference) 
            //and
            //3) The pivot row is now "clean" (that is, we know the actual dimensions of all the pages
            //   on the row and we aren't just guessing)
            //Then we can now officially calculate the scale needed in order to fit the given row in the manner 
            //chosen.
            if (_savedPivotRow != null && 
                RowIsClean(_savedPivotRow)) 
            {
                if (_documentLayout.ViewMode != ViewMode.Zoom && 
                    _documentLayout.ViewMode != ViewMode.SetColumns
                    )
                {
                    if (_savedPivotRow.FirstPage < _rowCache.RowCount) 
                    {
                        RowInfo newRow = _rowCache.GetRowForPageNumber(_savedPivotRow.FirstPage); 
 
                        //If the new row's dimensions differ, then we need to rescale, otherwise we do nothing.
                        if (newRow.RowSize.Width != _savedPivotRow.RowSize.Width || 
                            newRow.RowSize.Height != _savedPivotRow.RowSize.Height)
                        {
                            //Rescale.
                            ApplyViewParameters(newRow); 
                        }
 
                        //Null out the saved Pivot Row -- we've scaled this row properly now 
                        //so we don't need to be concerned with it any longer.
                        _savedPivotRow = null; 
                    }
                }
                else
                { 
                    // The view is already correct; null out the saved Pivot Row.
                    _savedPivotRow = null; 
                } 
            }
 
            //If we're viewing a document with varying page size, we've scrolled since the last layout change
            //and the Width of the document has increased
            //then this means that new, wider pages have just been scrolled into view.
            //If we do nothing here, then the content prior to these new pages will appear to "jump" 
            //to the right (because we center the pages within the width of the document.)
            //This jump is jarring and not a good user experience. 
            //To prevent this, we adjust the HorizontalOffset such that the content that was previously visible 
            //appears at the same position when it is rendered.
            if (_pageCache.DynamicPageSizes && 
                _lastRowChangeVerticalOffset != VerticalOffset &&
                _lastRowChangeExtentWidth < ExtentWidth)
            {
                if (_lastRowChangeExtentWidth != 0.0) 
                {
                    //Tweak the HorizontalOffset so that the content does not appear to move. 
                    SetHorizontalOffsetInternal(HorizontalOffset + (ExtentWidth - _lastRowChangeExtentWidth) / 2.0); 
                }
 
                _lastRowChangeExtentWidth = ExtentWidth;
            }

            _lastRowChangeVerticalOffset = VerticalOffset; 

            //The row cache has been changed. 
            //If we're displaying rows that were affected, 
            //we need to invalidate our measure so they'll be
            //redrawn. 
            for (int i = 0; i < args.Changes.Count; i++)
            {
                RowCacheChange change = args.Changes[i];
 
                if( RowCacheChangeIsVisible( change ))
                { 
                    InvalidateMeasure(); 
                    InvalidateChildMeasure();
                } 
            }

            InvalidateDocumentScrollInfo();
        } 
Ejemplo n.º 7
0
        // Token: 0x060071E1 RID: 29153 RVA: 0x00209034 File Offset: 0x00207234
        private void OnPageCacheChanged(object sender, PageCacheChangedEventArgs args)
        {
            if (this._isLayoutCompleted)
            {
                List <RowCacheChange> list = new List <RowCacheChange>(args.Changes.Count);
                for (int i = 0; i < args.Changes.Count; i++)
                {
                    PageCacheChange pageCacheChange = args.Changes[i];
                    switch (pageCacheChange.Type)
                    {
                    case PageCacheChangeType.Add:
                    case PageCacheChangeType.Update:
                        if (pageCacheChange.Start > this.LastPageInCache)
                        {
                            RowCacheChange rowCacheChange = this.AddPageRange(pageCacheChange.Start, pageCacheChange.Count);
                            if (rowCacheChange != null)
                            {
                                list.Add(rowCacheChange);
                            }
                        }
                        else if (pageCacheChange.Start + pageCacheChange.Count - 1 <= this.LastPageInCache)
                        {
                            RowCacheChange rowCacheChange2 = this.UpdatePageRange(pageCacheChange.Start, pageCacheChange.Count);
                            if (rowCacheChange2 != null)
                            {
                                list.Add(rowCacheChange2);
                            }
                        }
                        else
                        {
                            RowCacheChange rowCacheChange3 = this.UpdatePageRange(pageCacheChange.Start, this.LastPageInCache - pageCacheChange.Start);
                            if (rowCacheChange3 != null)
                            {
                                list.Add(rowCacheChange3);
                            }
                            rowCacheChange3 = this.AddPageRange(this.LastPageInCache + 1, pageCacheChange.Count - (this.LastPageInCache - pageCacheChange.Start));
                            if (rowCacheChange3 != null)
                            {
                                list.Add(rowCacheChange3);
                            }
                        }
                        break;

                    case PageCacheChangeType.Remove:
                        if (this.PageCache.PageCount - 1 < this.LastPageInCache)
                        {
                            RowCacheChange rowCacheChange4 = this.TrimPageRange(this.PageCache.PageCount);
                            if (rowCacheChange4 != null)
                            {
                                list.Add(rowCacheChange4);
                            }
                        }
                        if (this._rowCache.Count <= 1 && (this._rowCache.Count == 0 || this._rowCache[0].PageCount < this._layoutColumns))
                        {
                            this.RecalcRows(0, this._layoutColumns);
                        }
                        break;

                    default:
                        throw new ArgumentOutOfRangeException("args");
                    }
                }
                RowCacheChangedEventArgs e = new RowCacheChangedEventArgs(list);
                this.RowCacheChanged(this, e);
                return;
            }
            if (this._isLayoutRequested)
            {
                this.RecalcRows(this._layoutPivotPage, this._layoutColumns);
            }
        }