コード例 #1
0
        // Token: 0x060071DF RID: 29151 RVA: 0x00208EF0 File Offset: 0x002070F0
        private RowCacheChange TrimPageRange(int startPage)
        {
            int     num = this.GetRowIndexForPageNumber(startPage);
            RowInfo row = this.GetRow(num);

            if (row.FirstPage < startPage)
            {
                RowInfo rowInfo = new RowInfo();
                rowInfo.VerticalOffset = row.VerticalOffset;
                rowInfo.FirstPage      = row.FirstPage;
                for (int i = row.FirstPage; i < startPage; i++)
                {
                    Size scaledPageSize = this.GetScaledPageSize(i);
                    rowInfo.AddPage(scaledPageSize);
                }
                this.UpdateRow(num, rowInfo);
                num++;
            }
            int count = this._rowCache.Count - num;

            if (num < this._rowCache.Count)
            {
                this._rowCache.RemoveRange(num, count);
            }
            this._extentHeight = row.VerticalOffset;
            return(new RowCacheChange(num, count));
        }
コード例 #2
0
        // Token: 0x060071DD RID: 29149 RVA: 0x00208CA0 File Offset: 0x00206EA0
        private RowCacheChange UpdatePageRange(int startPage, int count)
        {
            if (!this._isLayoutCompleted)
            {
                throw new InvalidOperationException(SR.Get("RowCacheCannotModifyNonExistentLayout"));
            }
            int rowIndexForPageNumber = this.GetRowIndexForPageNumber(startPage);
            int num  = rowIndexForPageNumber;
            int num2 = startPage;

            while (num2 < startPage + count && num < this._rowCache.Count)
            {
                RowInfo rowInfo  = this._rowCache[num];
                RowInfo rowInfo2 = new RowInfo();
                rowInfo2.VerticalOffset = rowInfo.VerticalOffset;
                rowInfo2.FirstPage      = rowInfo.FirstPage;
                for (int i = rowInfo.FirstPage; i < rowInfo.FirstPage + rowInfo.PageCount; i++)
                {
                    Size scaledPageSize = this.GetScaledPageSize(i);
                    rowInfo2.AddPage(scaledPageSize);
                }
                this.UpdateRow(num, rowInfo2);
                num2 = rowInfo2.FirstPage + rowInfo2.PageCount;
                num++;
            }
            return(new RowCacheChange(rowIndexForPageNumber, num - rowIndexForPageNumber));
        }
コード例 #3
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);
        }
コード例 #4
0
        // Token: 0x060071D8 RID: 29144 RVA: 0x002088C4 File Offset: 0x00206AC4
        private RowInfo CreateDynamicRow(int startPage, double rowWidth, bool createForward)
        {
            if (startPage >= this.PageCache.PageCount)
            {
                throw new ArgumentOutOfRangeException("startPage");
            }
            RowInfo rowInfo        = new RowInfo();
            Size    scaledPageSize = this.GetScaledPageSize(startPage);

            rowInfo.AddPage(scaledPageSize);
            do
            {
                if (createForward)
                {
                    scaledPageSize = this.GetScaledPageSize(startPage + rowInfo.PageCount);
                    if (startPage + rowInfo.PageCount >= this.PageCache.PageCount)
                    {
                        break;
                    }
                    if (rowInfo.RowSize.Width + scaledPageSize.Width > rowWidth)
                    {
                        break;
                    }
                }
                else
                {
                    scaledPageSize = this.GetScaledPageSize(startPage - rowInfo.PageCount);
                    if (startPage - rowInfo.PageCount < 0 || rowInfo.RowSize.Width + scaledPageSize.Width > rowWidth)
                    {
                        break;
                    }
                }
                rowInfo.AddPage(scaledPageSize);
            }while (rowInfo.PageCount != DocumentViewerConstants.MaximumMaxPagesAcross);
            if (!createForward)
            {
                rowInfo.FirstPage = startPage - (rowInfo.PageCount - 1);
            }
            else
            {
                rowInfo.FirstPage = startPage;
            }
            return(rowInfo);
        }
コード例 #5
0
        // Token: 0x060071DB RID: 29147 RVA: 0x00208A8C File Offset: 0x00206C8C
        private RowCacheChange AddPageRange(int startPage, int count)
        {
            if (!this._isLayoutCompleted)
            {
                throw new InvalidOperationException(SR.Get("RowCacheCannotModifyNonExistentLayout"));
            }
            int i    = startPage;
            int num  = startPage + count;
            int num2 = 0;

            if (startPage > this.LastPageInCache + 1)
            {
                i = this.LastPageInCache + 1;
            }
            RowInfo rowInfo        = this._rowCache[this._rowCache.Count - 1];
            Size    scaledPageSize = this.GetScaledPageSize(i);
            RowInfo row            = this.GetRow(this._pivotRowIndex);
            bool    flag           = false;

            while (i < num && rowInfo.RowSize.Width + scaledPageSize.Width <= row.RowSize.Width)
            {
                rowInfo.AddPage(scaledPageSize);
                i++;
                scaledPageSize = this.GetScaledPageSize(i);
                flag           = true;
            }
            int num3;

            if (flag)
            {
                num3 = this._rowCache.Count - 1;
                this.UpdateRow(num3, rowInfo);
            }
            else
            {
                num3 = this._rowCache.Count;
            }
            while (i < num)
            {
                RowInfo rowInfo2 = new RowInfo();
                rowInfo2.FirstPage = i;
                do
                {
                    scaledPageSize = this.GetScaledPageSize(i);
                    rowInfo2.AddPage(scaledPageSize);
                    i++;
                }while (rowInfo2.RowSize.Width + scaledPageSize.Width <= row.RowSize.Width && i < num);
                this.AddRow(rowInfo2);
                num2++;
            }
            return(new RowCacheChange(num3, num2));
        }
コード例 #6
0
        // Token: 0x060071DA RID: 29146 RVA: 0x00208A1C File Offset: 0x00206C1C
        private RowInfo CreateFixedRow(int startPage, int columns)
        {
            if (startPage >= this.PageCache.PageCount)
            {
                throw new ArgumentOutOfRangeException("startPage");
            }
            if (columns < 1)
            {
                throw new ArgumentOutOfRangeException("columns");
            }
            RowInfo rowInfo = new RowInfo();

            rowInfo.FirstPage = startPage;
            int num = startPage;

            while (num < startPage + columns && num <= this.PageCache.PageCount - 1)
            {
                Size scaledPageSize = this.GetScaledPageSize(num);
                rowInfo.AddPage(scaledPageSize);
                num++;
            }
            return(rowInfo);
        }
コード例 #7
0
ファイル: RowCache.cs プロジェクト: JianwenSun/cc
        /// <summary>
        /// Given a range of pages, adds the pages to the existing row cache,
        /// adding new rows where necessary.
        /// </summary>
        /// <param name="startPage">The first page to add to the layout</param>
        /// <param name="count">The number of pages to add.</param>		
        private RowCacheChange AddPageRange(int startPage, int count)
        {
            if (!_isLayoutCompleted)
            {
                throw new InvalidOperationException(SR.Get(SRID.RowCacheCannotModifyNonExistentLayout));
            }

            int currentPage = startPage;
            int lastPage = startPage + count;

            int startRow = 0;
            int rowCount = 0;

            //First we check to see if startPage is such that we'd end up skipping
            //pages in the document -- that is, if the last page in our layout is currently
            //10 and start is 15, we need to fill in pages 11-14 as well.
            if (startPage > LastPageInCache + 1)
            {
                currentPage = LastPageInCache + 1;
            }            

            //Get the last row in the layout
            RowInfo lastRow = _rowCache[_rowCache.Count - 1];

            //Now we need to check to see if we can add any pages to this row 
            //without exceeding the current layout's pivot row width.

            //Get the size of the page to add
            Size pageSize = GetScaledPageSize(currentPage);

            //Get the pivot row
            RowInfo pivotRow = GetRow(_pivotRowIndex);

            bool lastRowUpdated = false;

            //Add new pages to the last row until we run out of pages or space.
            while (currentPage < lastPage && 
                lastRow.RowSize.Width + pageSize.Width <= pivotRow.RowSize.Width)
            {
                //Add the current page
                lastRow.AddPage(pageSize);
                currentPage++;

                //Get the size of the next page.
                pageSize = GetScaledPageSize(currentPage);

                //Note that we updated this row so we'll update the cache when we're done here.
                lastRowUpdated = true;
            }

            //If we actually made a change to the last row, then we need to update the row cache.
            if (lastRowUpdated)
            {
                startRow = _rowCache.Count - 1;
                //Update the last row
                UpdateRow(startRow, lastRow);
            }
            else
            {
                startRow = _rowCache.Count;
            }

            //Now we add more rows to the layout, if we have any pages left.
            while (currentPage < lastPage)
            {
                //Build a new row.
                RowInfo newRow = new RowInfo();              
                newRow.FirstPage = currentPage;              

                //Add pages until we either run out of pages or need to start a new row.               
                do
                {
                    //Get the size of the next page
                    pageSize = GetScaledPageSize(currentPage);

                    //Add it.
                    newRow.AddPage(pageSize);
                    currentPage++;

                } while (newRow.RowSize.Width + pageSize.Width <= pivotRow.RowSize.Width 
                    && currentPage < lastPage);

                //Add this new row to our cache
                AddRow(newRow);
                rowCount++;
            }

            return new RowCacheChange(startRow, rowCount);
        }
コード例 #8
0
ファイル: RowCache.cs プロジェクト: JianwenSun/cc
        /// <summary>
        /// Creates a "fixed" row -- that is, a row with a specific number of columns on it.
        /// </summary>
        /// <param name="startPage">The first page to live on this row.</param>
        /// <param name="columns">The number of columns on this row.</param>
        /// <returns></returns>
        private RowInfo CreateFixedRow(int startPage, int columns)
        {
            if (startPage >= PageCache.PageCount)
            {
                throw new ArgumentOutOfRangeException("startPage");
            }

            if (columns < 1 )
            {
                throw new ArgumentOutOfRangeException("columns");
            }

            //Given a starting page for this row and the number of columns in the row
            //calculate the width & height and return the resulting RowInfo struct

            //Populate the struct with initial data
            RowInfo newRow = new RowInfo();
            newRow.FirstPage = startPage;            

            //Keep adding pages until we either:
            // - run out of pages to add
            // - add the appropriate number of pages            
            for (int i = startPage; i < startPage + columns; i++)
            {
                //We’re out of pages.
                if (i > PageCache.PageCount - 1)
                    break;

                //Get the size of the page
                Size pageSize = GetScaledPageSize(i);

                //Add this page to the row
                newRow.AddPage(pageSize);                
            }

            return newRow;
        }
コード例 #9
0
ファイル: RowCache.cs プロジェクト: JianwenSun/cc
        /// <summary>
        /// Creates a "dynamic" row -- that is, given a maximum width for the row, it will fit as
        /// many pages on said row as possible.
        /// </summary>
        /// <param name="startPage">The first page to put on this row.</param>
        /// <param name="rowWidth">The requested width of this row.</param>
        /// <param name="createForward">Whether to create this row using the next N pages or the
        /// previous N.</param>
        /// <returns></returns>
        private RowInfo CreateDynamicRow(int startPage, double rowWidth, bool createForward)
        {
            if (startPage >= PageCache.PageCount)
            {
                throw new ArgumentOutOfRangeException("startPage");
            }            

            //Given a starting page for this row, and the specified
            //width for each row, figure out how many pages will fit on this row
            //and return the resulting RowInfo object.

            //Populate the struct with initial data.
            RowInfo newRow = new RowInfo();

            //Each row is guaranteed to have at least one page, even if it’s wider
            //than the allotted size, so we add it here.	        
            Size pageSize = GetScaledPageSize( startPage );
            newRow.AddPage(pageSize);

            //Keep adding pages until we either:
            // - run out of pages to add
            // - run out of space in the row
            for(;;)
            {                                
                if( createForward )
                {
                    //Grab the next page.
                    pageSize = GetScaledPageSize(startPage + newRow.PageCount);

                    //We’re out of pages, or out of space.
                    if (startPage + newRow.PageCount >= PageCache.PageCount ||
                        newRow.RowSize.Width + pageSize.Width > rowWidth )
                    {
                        break;
                    }
                }
                else
                {
                    //Grab the previous page.
                    pageSize = GetScaledPageSize( startPage - newRow.PageCount );                 

                    //We’re out of pages, or out of space.
                    if( startPage - newRow.PageCount < 0 ||
                        newRow.RowSize.Width + pageSize.Width > rowWidth )
                    {
                        break;
                    }
                }
                newRow.AddPage(pageSize);

                //If we've hit the hard upper limit for pages on a row then we're done with this row.
                if (newRow.PageCount == DocumentViewerConstants.MaximumMaxPagesAcross)
                {
                    break;
                }
            }

            if (!createForward)
            {
                newRow.FirstPage = startPage - (newRow.PageCount - 1);
            }
            else
            {
                newRow.FirstPage = startPage;
            }

            return newRow;
        }
コード例 #10
0
ファイル: RowCache.cs プロジェクト: JianwenSun/cc
        /// <summary>
        /// Trims any pages (and rows) from the end of the layout, starting with the specified page.
        /// </summary>
        /// <param name="startPage">The first page to remove.</param>
        private RowCacheChange TrimPageRange(int startPage)
        {
            //First, we find the row the last page is on.
            int rowIndex = GetRowIndexForPageNumber(startPage);
            
            //Now we replace this row with a new row that has the deleted pages
            //removed, if there are pages on this row that aren't going to be deleted.
            RowInfo oldRow = GetRow(rowIndex);
            
            if (oldRow.FirstPage < startPage)
            {
                RowInfo updatedRow = new RowInfo();
                updatedRow.VerticalOffset = oldRow.VerticalOffset;
                updatedRow.FirstPage = oldRow.FirstPage;                              

                for (int i = oldRow.FirstPage; i < startPage; i++)
                {
                    //Get the page we're interested in.
                    Size pageSize = GetScaledPageSize(i);
                    //Add it.
                    updatedRow.AddPage(pageSize);                    
                }

                UpdateRow(rowIndex, updatedRow);

                //Increment the rowIndex, since we're going to keep this row.
                rowIndex++;
            }

            int removeCount = _rowCache.Count - rowIndex;

            //Now remove all the rows below this one.
            if(rowIndex < _rowCache.Count )
            {
                _rowCache.RemoveRange( rowIndex, removeCount);
            }

            //Update our extents
            _extentHeight = oldRow.VerticalOffset;

            return new RowCacheChange(rowIndex, removeCount);
        }
コード例 #11
0
ファイル: RowCache.cs プロジェクト: JianwenSun/cc
        /// <summary>
        /// Given a preexisting page range, updates the dimensions of the rows containing said 
        /// pages from the Page Cache.
        /// If any row's height changes as a result, all rows below have their offsets updated.
        /// </summary>		
        /// <param name="startPage">The first page changed</param>
        /// <param name="count">The number of pages changed</param>
        private RowCacheChange UpdatePageRange(int startPage, int count)
        {
            if (!_isLayoutCompleted)
            {
                throw new InvalidOperationException(SR.Get(SRID.RowCacheCannotModifyNonExistentLayout));
            }

            //Get the row that contains the first page
            int startRowIndex = GetRowIndexForPageNumber(startPage);
            int rowIndex = startRowIndex;

            int currentPage = startPage;

            //Recalculate the rows affected by the changed pages.
            while (currentPage < startPage + count && rowIndex < _rowCache.Count)
            {
                //Get the current row
                RowInfo currentRow = _rowCache[rowIndex];
                //Create a new row and copy pertinent data
                //from the old one.
                RowInfo updatedRow = new RowInfo();               
                updatedRow.VerticalOffset = currentRow.VerticalOffset;
                updatedRow.FirstPage = currentRow.FirstPage;

                //Now rebuild this row, thus recalculating the row's size
                //based on the new page sizes.
                for (int i = currentRow.FirstPage; i < currentRow.FirstPage + currentRow.PageCount; i++)
                {                    
                    //Get the updated page size and add it to our updated row
                    Size pageSize = GetScaledPageSize(i);
                    updatedRow.AddPage(pageSize);
                }				
                
                //Update the row layout with this new row.
                UpdateRow(rowIndex, updatedRow);

                //Move to the next group of pages.
                currentPage = updatedRow.FirstPage + updatedRow.PageCount;

                //Move to the next row.
                rowIndex++;
            }

            return new RowCacheChange(startRowIndex, rowIndex - startRowIndex);
        }