Exemplo n.º 1
0
 /// <summary>
 /// Fire event after a page has been completed
 /// </summary>
 /// <param name="ea">GetPageCompletedEventArgs</param>
 public void FireEventGetPageCompleted(GetPageCompletedEventArgs ea)
 {
     if (GetPageCompleted != null)
     {
         GetPageCompleted(this, ea);
     }
 }
Exemplo n.º 2
0
        private void Client_GetPageCompleted(object sender, GetPageCompletedEventArgs e)
        {
            string xaml = e.Result.XAML;
            var    page = XamlReader.Load(xaml);

            LayoutRoot.Children.Add(page as UIElement);
            this.client.GetDataAsync(1);
        }
 // Token: 0x0600714E RID: 29006 RVA: 0x00206B48 File Offset: 0x00204D48
 private void OnGetPageCompleted(object sender, GetPageCompletedEventArgs args)
 {
     if (!args.Cancelled && args.Error == null && args.DocumentPage != DocumentPage.Missing)
     {
         this._pageDestroyedWatcher.AddPage(args.DocumentPage);
         Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal, new DispatcherOperationCallback(this.GetPageCompletedDelegate), args);
     }
 }
 // Token: 0x06006297 RID: 25239 RVA: 0x001BA800 File Offset: 0x001B8A00
 private void HandleGetPageCompleted(object sender, GetPageCompletedEventArgs e)
 {
     if (!e.Cancelled && e.Error == null && e.DocumentPage != DocumentPage.Missing)
     {
         DocumentPage page = this.ComposePageWithAnnotationVisuals(e.PageNumber, e.DocumentPage);
         e = new GetPageCompletedEventArgs(page, e.PageNumber, e.Error, e.Cancelled, e.UserState);
     }
     this.OnGetPageCompleted(e);
 }
Exemplo n.º 5
0
 // Token: 0x06006F97 RID: 28567 RVA: 0x00201454 File Offset: 0x001FF654
 private void OnGetPageCompleted(object sender, GetPageCompletedEventArgs e)
 {
     if (!this._disposed && e != null && !e.Cancelled && e.Error == null && e.PageNumber != 2147483647 && e.PageNumber == this.PageNumber && e.DocumentPage != null && e.DocumentPage != DocumentPage.Missing)
     {
         this._loaded = true;
         if (this.PageLoaded != null)
         {
             this.PageLoaded(this, EventArgs.Empty);
         }
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Handler for the GetPageCompleted event fired by the DocumentPaginator.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void OnGetPageCompleted(object sender, GetPageCompletedEventArgs args)
        {
            if (!args.Cancelled && args.Error == null && args.DocumentPage != DocumentPage.Missing)
            {
                //Add the page to the Watcher so we can determine if the page has been
                //destroyed in our Delegate.
                _pageDestroyedWatcher.AddPage(args.DocumentPage);

                //Since handling the GetPageCompleted event entails a bit of work, we'll
                //have our dispatcher call the GetPageCompletedDelegate at Normal priority.
                Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal,
                                                         new DispatcherOperationCallback(GetPageCompletedDelegate), args);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// We are being notified by the wrapped paginator.  If getting the page
        /// was successful, we use the resulting page to produce a new page that
        /// includes annotatons.  In either case, we fire an event from this instance.
        /// </summary>
        /// <param name="sender">source of the event</param>
        /// <param name="e">the args for this event</param>
        private void HandleGetPageCompleted(object sender, GetPageCompletedEventArgs e)
        {
            // If no errors, not cancelled, and page isn't missing, create a new page
            // with annotations and create a new event args for that page.
            if (!e.Cancelled && e.Error == null && e.DocumentPage != DocumentPage.Missing)
            {
                // Since we can't change the page the args is holding we create a new
                // args object with the page we produce.
                DocumentPage documentPage = ConstructPageWithHeaderAndFooter(e.PageNumber);

                e = new GetPageCompletedEventArgs(documentPage, e.PageNumber, e.Error, e.Cancelled, e.UserState);
            }

            // Fire the event
            OnGetPageCompleted(e);
        }
 // Token: 0x06005D89 RID: 23945 RVA: 0x001A5458 File Offset: 0x001A3658
 private void HandleGetPageCompleted(object sender, GetPageCompletedEventArgs e)
 {
     if (!this._disposed && e != null && !e.Cancelled && e.Error == null && e.PageNumber == this.PageNumber && e.UserState == this)
     {
         if (this._documentPageAsync != null && this._documentPageAsync != DocumentPage.Missing)
         {
             this._documentPageAsync.PageDestroyed -= this.HandleAsyncPageDestroyed;
         }
         this._documentPageAsync = e.DocumentPage;
         if (this._documentPageAsync == null)
         {
             this._documentPageAsync = DocumentPage.Missing;
         }
         if (this._documentPageAsync != DocumentPage.Missing)
         {
             this._documentPageAsync.PageDestroyed += this.HandleAsyncPageDestroyed;
         }
         base.InvalidateMeasure();
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Handles the GetPageCompleted event raised by the DocumentPaginator.
        /// At this point, we'll set the _loaded flag to indicate the page is loaded
        /// and fire the PageLoaded event.
        /// </summary>
        /// <param name="sender">Source of the event.</param>
        /// <param name="e">Details about this event.</param>
        private void OnGetPageCompleted(object sender, GetPageCompletedEventArgs e)
        {
            //If the GetPageCompleted action completed successfully
            //and is our page then we'll set the flag and fire the event.
            if (!_disposed &&
                e != null &&
                !e.Cancelled &&
                e.Error == null &&
                e.PageNumber != int.MaxValue &&
                e.PageNumber == this.PageNumber &&
                e.DocumentPage != null &&
                e.DocumentPage != DocumentPage.Missing)
            {
                _loaded = true;

                if (PageLoaded != null)
                {
                    PageLoaded(this, EventArgs.Empty);
                }
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Handles GetPageCompleted event raised by the DocumentPaginator.
 /// </summary>
 /// <param name="sender">Source of the event.</param>
 /// <param name="e">Details about this event.</param>
 private void HandleGetPageCompleted(object sender, GetPageCompletedEventArgs e)
 {
     if (!_disposed && (e != null) && !e.Cancelled && e.Error == null)
     {
         if (e.PageNumber == this.PageNumber && e.UserState == this)
         {
             if (_documentPageAsync != null && _documentPageAsync != DocumentPage.Missing)
             {
                 _documentPageAsync.PageDestroyed -= new EventHandler(HandleAsyncPageDestroyed);
             }
             _documentPageAsync = e.DocumentPage;
             if (_documentPageAsync == null)
             {
                 _documentPageAsync = DocumentPage.Missing;
             }
             if (_documentPageAsync != DocumentPage.Missing)
             {
                 _documentPageAsync.PageDestroyed += new EventHandler(HandleAsyncPageDestroyed);
             }
             InvalidateMeasure();
         }
         // else; the page is not ours
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// Asynchronously handles the GetPageCompleted event.
        /// This means that a requested page is available, so we
        /// update the page's cache entry, mark it as clean and fire off our
        /// GetPageCompleted event.
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        private object GetPageCompletedDelegate(object parameter)
        {
            GetPageCompletedEventArgs args = parameter as GetPageCompletedEventArgs;

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

            //Check to see if the page has been destroyed, and remove it from the Watcher.
            bool pageDestroyed = _pageDestroyedWatcher.IsDestroyed(args.DocumentPage);

            _pageDestroyedWatcher.RemovePage(args.DocumentPage);

            //The page was destroyed, return early.
            if (pageDestroyed)
            {
                return(null);
            }

            //We only update the entry if the GetPageAsync call was not canceled,
            //points to a valid page (i.e. is not DocumentPage.Missing)
            //and did not result in an Error condition.
            if (!args.Cancelled && args.Error == null && args.DocumentPage != DocumentPage.Missing)
            {
                if (args.DocumentPage.Size == Size.Empty)
                {
                    throw new ArgumentOutOfRangeException("args");
                }

                //Update the cache.
                PageCacheEntry newEntry;
                newEntry.PageSize = args.DocumentPage.Size;
                newEntry.Dirty    = false;

                //Create our list of changes.  We can have at most two.
                List <PageCacheChange> changes = new List <PageCacheChange>(2);
                PageCacheChange        change;

                //If we add pages such that there's going to be a gap
                //in the cache (for example if we get PaginationProgress events
                //for pages 1-3 and then 7-10), we need to fill in the gap with entries.
                if (args.PageNumber > _cache.Count - 1)
                {
                    //Add the new page (this will cause any pages we
                    //skipped over to be filled in)
                    change = AddRange(args.PageNumber, 1);
                    if (change != null)
                    {
                        changes.Add(change);
                    }

                    //Update the just-retrieved-page to reflect the actual page size.
                    change = UpdateEntry(args.PageNumber, newEntry);
                    if (change != null)
                    {
                        changes.Add(change);
                    }
                }
                else
                {
                    //Just update the retrieved page's cache entry.
                    change = UpdateEntry(args.PageNumber, newEntry);
                    if (change != null)
                    {
                        changes.Add(change);
                    }
                }

                //If this page is a different size than the last-retrieved page, then we have a
                //dynamic document.
                if (_isDefaultSizeKnown && newEntry.PageSize != _lastPageSize)
                {
                    _dynamicPageSizes = true;
                }

                _lastPageSize = newEntry.PageSize;

                //If this is the first page in the document that we've actually retrieved from
                //the DocumentPaginator, we'll use this page's size as the default size and
                //update any dirty pages in the cache with this default size.
                //(Technically there should be no non-dirty pages in the document at this point, but
                //if we want to change our heuristic (for example, use the "most common page size")
                //to define the default then we don't want to clobber known pages.)
                if (!_isDefaultSizeKnown)
                {
                    _defaultPageSize    = newEntry.PageSize;
                    _isDefaultSizeKnown = true;

                    SetDefaultPageSize(true);
                }

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

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

            return(null);
        }
Exemplo n.º 12
0
 protected override void OnGetPageCompleted(GetPageCompletedEventArgs e)
 {
     base.OnGetPageCompleted(e);
 }
 // Token: 0x06006FE6 RID: 28646 RVA: 0x00202802 File Offset: 0x00200A02
 internal void NotifyGetPageCompleted(GetPageCompletedEventArgs e)
 {
     this.OnGetPageCompleted(e);
 }
        // Token: 0x0600714F RID: 29007 RVA: 0x00206BA0 File Offset: 0x00204DA0
        private object GetPageCompletedDelegate(object parameter)
        {
            GetPageCompletedEventArgs getPageCompletedEventArgs = parameter as GetPageCompletedEventArgs;

            if (getPageCompletedEventArgs == null)
            {
                throw new ArgumentOutOfRangeException("parameter");
            }
            bool flag = this._pageDestroyedWatcher.IsDestroyed(getPageCompletedEventArgs.DocumentPage);

            this._pageDestroyedWatcher.RemovePage(getPageCompletedEventArgs.DocumentPage);
            if (flag)
            {
                return(null);
            }
            if (!getPageCompletedEventArgs.Cancelled && getPageCompletedEventArgs.Error == null && getPageCompletedEventArgs.DocumentPage != DocumentPage.Missing)
            {
                if (getPageCompletedEventArgs.DocumentPage.Size == Size.Empty)
                {
                    throw new ArgumentOutOfRangeException("args");
                }
                PageCacheEntry pageCacheEntry;
                pageCacheEntry.PageSize = getPageCompletedEventArgs.DocumentPage.Size;
                pageCacheEntry.Dirty    = false;
                List <PageCacheChange> list = new List <PageCacheChange>(2);
                if (getPageCompletedEventArgs.PageNumber > this._cache.Count - 1)
                {
                    PageCacheChange pageCacheChange = this.AddRange(getPageCompletedEventArgs.PageNumber, 1);
                    if (pageCacheChange != null)
                    {
                        list.Add(pageCacheChange);
                    }
                    pageCacheChange = this.UpdateEntry(getPageCompletedEventArgs.PageNumber, pageCacheEntry);
                    if (pageCacheChange != null)
                    {
                        list.Add(pageCacheChange);
                    }
                }
                else
                {
                    PageCacheChange pageCacheChange = this.UpdateEntry(getPageCompletedEventArgs.PageNumber, pageCacheEntry);
                    if (pageCacheChange != null)
                    {
                        list.Add(pageCacheChange);
                    }
                }
                if (this._isDefaultSizeKnown && pageCacheEntry.PageSize != this._lastPageSize)
                {
                    this._dynamicPageSizes = true;
                }
                this._lastPageSize = pageCacheEntry.PageSize;
                if (!this._isDefaultSizeKnown)
                {
                    this._defaultPageSize    = pageCacheEntry.PageSize;
                    this._isDefaultSizeKnown = true;
                    this.SetDefaultPageSize(true);
                }
                this.FirePageCacheChangedEvent(list);
            }
            if (this.GetPageCompleted != null)
            {
                this.GetPageCompleted(this, getPageCompletedEventArgs);
            }
            return(null);
        }