Esempio n. 1
0
        //------------------------------------------------------
        //
        //  Private Methods
        //
        //------------------------------------------------------

        #region Private Methods

        /// <summary>
        /// Handler for the OnPaginationProgress event fired by the DocumentPaginator.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void OnPaginationProgress(object sender, PaginationProgressEventArgs args)
        {
            //Since handling the PaginationProgress event entails a bit of work, we'll
            //have our dispatcher call the PaginationProgress event at Normal priority.
            Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal,
                                                     new DispatcherOperationCallback(PaginationProgressDelegate), args);
        }
Esempio n. 2
0
        /// <summary>
        /// Asynchronously handles the PaginationProgress event.
        /// This means that one or more pages have been added to the document, so we
        /// add any new pages to the cache, mark them as dirty, and fire off our PaginationProgress
        /// event.
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        private object PaginationProgressDelegate(object parameter)
        {
            PaginationProgressEventArgs args = parameter as PaginationProgressEventArgs;

            if (args == null)
            {
                throw new InvalidOperationException("parameter");
            }

            //Validate incoming parameters.
            ValidatePaginationArgs(args.Start, args.Count);

            if (_isPaginationCompleted)
            {
                if (args.Start == 0)
                {
                    //Since we've started repaginating from the beginning of the document
                    //after pagination was completed, we can't assume we know
                    //the default page size anymore.
                    _isDefaultSizeKnown = false;
                    _dynamicPageSizes   = false;
                }

                //Reset our IsPaginationCompleted flag since we just got a pagination event.
                _isPaginationCompleted = false;
            }

            //Check for integer overflow.
            if (args.Start + args.Count < 0)
            {
                throw new ArgumentOutOfRangeException("args");
            }

            //Create our list of changes.  We allocate space for 2 changes here
            //as we can have as many as two changes resulting from a Pagination event.
            List <PageCacheChange> changes = new List <PageCacheChange>(2);
            PageCacheChange        change;

            //If we have pages to add or modify, do so now.
            if (args.Count > 0)
            {
                //If pagination has added new pages onto the end of the document, we
                //add new entries to our cache.
                if (args.Start >= _cache.Count)
                {
                    //Completely new pages, so we add new cache entries
                    change = AddRange(args.Start, args.Count);
                    if (change != null)
                    {
                        changes.Add(change);
                    }
                }
                else
                {
                    //Pagination has updated some currently existing pages, so we'll
                    //update our entries.
                    if (args.Start + args.Count < _cache.Count)
                    {
                        //All pre-existing pages, so we just dirty the current cache entries.
                        change = DirtyRange(args.Start, args.Count);
                        if (change != null)
                        {
                            changes.Add(change);
                        }
                    }
                    else
                    {
                        //Some pre-existing pages, some new.
                        change = DirtyRange(args.Start, _cache.Count - args.Start);
                        if (change != null)
                        {
                            changes.Add(change);
                        }

                        change = AddRange(_cache.Count, args.Count - (_cache.Count - args.Start) + 1);
                        if (change != null)
                        {
                            changes.Add(change);
                        }
                    }
                }
            }

            //If the document's PageCount is now less than the size of our cache due to repagination
            //we remove the extra entries.
            int pageCount = _documentPaginator != null ? _documentPaginator.PageCount : 0;

            if (pageCount < _cache.Count)
            {
                change = new PageCacheChange(pageCount, _cache.Count - pageCount, PageCacheChangeType.Remove);
                changes.Add(change);

                //Remove the pages from the cache.
                _cache.RemoveRange(pageCount, _cache.Count - pageCount);
            }

            //Fire off our PageCacheChanged event.
            FirePageCacheChangedEvent(changes);

            //Fire the PaginationProgress event.
            if (PaginationProgress != null)
            {
                PaginationProgress(this, args);
            }

            return(null);
        }
        // Token: 0x06007149 RID: 29001 RVA: 0x00206848 File Offset: 0x00204A48
        private object PaginationProgressDelegate(object parameter)
        {
            PaginationProgressEventArgs paginationProgressEventArgs = parameter as PaginationProgressEventArgs;

            if (paginationProgressEventArgs == null)
            {
                throw new InvalidOperationException("parameter");
            }
            this.ValidatePaginationArgs(paginationProgressEventArgs.Start, paginationProgressEventArgs.Count);
            if (this._isPaginationCompleted)
            {
                if (paginationProgressEventArgs.Start == 0)
                {
                    this._isDefaultSizeKnown = false;
                    this._dynamicPageSizes   = false;
                }
                this._isPaginationCompleted = false;
            }
            if (paginationProgressEventArgs.Start + paginationProgressEventArgs.Count < 0)
            {
                throw new ArgumentOutOfRangeException("args");
            }
            List <PageCacheChange> list = new List <PageCacheChange>(2);

            if (paginationProgressEventArgs.Count > 0)
            {
                if (paginationProgressEventArgs.Start >= this._cache.Count)
                {
                    PageCacheChange pageCacheChange = this.AddRange(paginationProgressEventArgs.Start, paginationProgressEventArgs.Count);
                    if (pageCacheChange != null)
                    {
                        list.Add(pageCacheChange);
                    }
                }
                else if (paginationProgressEventArgs.Start + paginationProgressEventArgs.Count < this._cache.Count)
                {
                    PageCacheChange pageCacheChange = this.DirtyRange(paginationProgressEventArgs.Start, paginationProgressEventArgs.Count);
                    if (pageCacheChange != null)
                    {
                        list.Add(pageCacheChange);
                    }
                }
                else
                {
                    PageCacheChange pageCacheChange = this.DirtyRange(paginationProgressEventArgs.Start, this._cache.Count - paginationProgressEventArgs.Start);
                    if (pageCacheChange != null)
                    {
                        list.Add(pageCacheChange);
                    }
                    pageCacheChange = this.AddRange(this._cache.Count, paginationProgressEventArgs.Count - (this._cache.Count - paginationProgressEventArgs.Start) + 1);
                    if (pageCacheChange != null)
                    {
                        list.Add(pageCacheChange);
                    }
                }
            }
            int num = (this._documentPaginator != null) ? this._documentPaginator.PageCount : 0;

            if (num < this._cache.Count)
            {
                PageCacheChange pageCacheChange = new PageCacheChange(num, this._cache.Count - num, PageCacheChangeType.Remove);
                list.Add(pageCacheChange);
                this._cache.RemoveRange(num, this._cache.Count - num);
            }
            this.FirePageCacheChangedEvent(list);
            if (this.PaginationProgress != null)
            {
                this.PaginationProgress(this, paginationProgressEventArgs);
            }
            return(null);
        }
 // Token: 0x06006FE8 RID: 28648 RVA: 0x00202814 File Offset: 0x00200A14
 internal void NotifyPaginationProgress(PaginationProgressEventArgs e)
 {
     this.OnPaginationProgress(e);
 }
 // Token: 0x06007148 RID: 29000 RVA: 0x0020682A File Offset: 0x00204A2A
 private void OnPaginationProgress(object sender, PaginationProgressEventArgs args)
 {
     Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal, new DispatcherOperationCallback(this.PaginationProgressDelegate), args);
 }