Пример #1
0
        //-------------------------------------------------------------------
        //
        //  Protected Methods
        //
        //-------------------------------------------------------------------

        #region Protected Methods

        /// <summary>
        /// Override for subclasses that wish to add logic when this event is fired.
        /// </summary>
        /// <param name="e">Event arguments for the GetPageCompleted event.</param>
        protected virtual void OnGetPageCompleted(GetPageCompletedEventArgs e)
        {
            if (this.GetPageCompleted != null)
            {
                this.GetPageCompleted(this, e);
            }
        }
Пример #2
0
        // Callback from inner IDP.GetPageAsync
        private void _OnGetPageCompleted(object sender, GetPageCompletedEventArgs args)
        {
            DocumentsTrace.FixedDocumentSequence.IDF.Trace(string.Format("_OnGetPageCompleted"));

            // this job is complete
            GetPageAsyncRequest completedRequest = (GetPageAsyncRequest)args.UserState;

            _pendingPages.Remove(completedRequest.Page);

            // wrap the returned result into FixedDocumentSequenceDocumentPage
            DocumentPage sdp        = DocumentPage.Missing;
            int          pageNumber = completedRequest.Page.PageNumber;

            if (!args.Cancelled && (args.Error == null) && (args.DocumentPage != DocumentPage.Missing))
            {
                sdp = new FixedDocumentSequenceDocumentPage(this, (DynamicDocumentPaginator)sender, args.DocumentPage);
                _SynthesizeGlobalPageNumber((DynamicDocumentPaginator)sender, args.PageNumber, out pageNumber);
            }

            if (!args.Cancelled)
            {
                // Notify all outstanding request for this particular page
                ArrayList notificationList = new ArrayList();
                IEnumerator <KeyValuePair <Object, GetPageAsyncRequest> > ienum = _asyncOps.GetEnumerator();
                try
                {
                    while (ienum.MoveNext())
                    {
                        GetPageAsyncRequest asyncRequest = ienum.Current.Value;

                        // Process any outstanding request for this PageContent
                        if (completedRequest.Page.Equals(asyncRequest.Page))
                        {
                            notificationList.Add(ienum.Current.Key);
                            // this could throw depending on event handlers that are added
                            _NotifyGetPageAsyncCompleted(sdp, pageNumber, args.Error, asyncRequest.Cancelled, asyncRequest.UserState);
                        }
                    }
                }
                finally
                {
                    // Remove completed requests from current async ops list
                    foreach (Object userState in notificationList)
                    {
                        _asyncOps.Remove(userState);
                    }
                }
            }
        }
Пример #3
0
        // Token: 0x06002B93 RID: 11155 RVA: 0x000C6EF0 File Offset: 0x000C50F0
        private void _OnGetPageCompleted(object sender, GetPageCompletedEventArgs args)
        {
            FixedDocumentSequence.GetPageAsyncRequest getPageAsyncRequest = (FixedDocumentSequence.GetPageAsyncRequest)args.UserState;
            this._pendingPages.Remove(getPageAsyncRequest.Page);
            DocumentPage page       = DocumentPage.Missing;
            int          pageNumber = getPageAsyncRequest.Page.PageNumber;

            if (!args.Cancelled && args.Error == null && args.DocumentPage != DocumentPage.Missing)
            {
                page = new FixedDocumentSequenceDocumentPage(this, (DynamicDocumentPaginator)sender, args.DocumentPage);
                this._SynthesizeGlobalPageNumber((DynamicDocumentPaginator)sender, args.PageNumber, out pageNumber);
            }
            if (!args.Cancelled)
            {
                ArrayList arrayList = new ArrayList();
                IEnumerator <KeyValuePair <object, FixedDocumentSequence.GetPageAsyncRequest> > enumerator = this._asyncOps.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        KeyValuePair <object, FixedDocumentSequence.GetPageAsyncRequest> keyValuePair = enumerator.Current;
                        FixedDocumentSequence.GetPageAsyncRequest value = keyValuePair.Value;
                        if (getPageAsyncRequest.Page.Equals(value.Page))
                        {
                            ArrayList arrayList2 = arrayList;
                            keyValuePair = enumerator.Current;
                            arrayList2.Add(keyValuePair.Key);
                            this._NotifyGetPageAsyncCompleted(page, pageNumber, args.Error, value.Cancelled, value.UserState);
                        }
                    }
                }
                finally
                {
                    foreach (object key in arrayList)
                    {
                        this._asyncOps.Remove(key);
                    }
                }
            }
        }
Пример #4
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);
 }
Пример #5
0
		private void DocumentPaginator_GetPageCompleted(object sender, GetPageCompletedEventArgs e)
		{
			OnPropertyChanged(() => TotalPageNumber);
		}
        //----------------------------------------------------- 
        //
        //  Private Methods 
        //
        //------------------------------------------------------

        #region Private Methods 

        /// <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 = ComposePageWithAnnotationVisuals(e.PageNumber, e.DocumentPage);
 
                e = new GetPageCompletedEventArgs(documentPage, e.PageNumber, e.Error, e.Cancelled, e.UserState);
            } 
 
            // Fire the event
            OnGetPageCompleted(e); 
        }
Пример #7
0
        //-------------------------------------------------------------------
        //
        //  Internal Methods
        //
        //-------------------------------------------------------------------

        #region Internal Methods

        internal void NotifyGetPageCompleted(GetPageCompletedEventArgs e)
        {
            OnGetPageCompleted(e);
        }
 protected virtual new void OnGetPageCompleted(GetPageCompletedEventArgs e)
 {
 }
        // Callback from inner IDP.GetPageAsync
        private void _OnGetPageCompleted(object sender, GetPageCompletedEventArgs args)
        {
            DocumentsTrace.FixedDocumentSequence.IDF.Trace(string.Format("_OnGetPageCompleted"));

            // this job is complete
            GetPageAsyncRequest completedRequest = (GetPageAsyncRequest)args.UserState;
            _pendingPages.Remove(completedRequest.Page);

            // wrap the returned result into FixedDocumentSequenceDocumentPage
            DocumentPage sdp = DocumentPage.Missing;
            int pageNumber = completedRequest.Page.PageNumber;
            if (!args.Cancelled && (args.Error == null) && (args.DocumentPage != DocumentPage.Missing))
            {
                sdp = new FixedDocumentSequenceDocumentPage(this, (DynamicDocumentPaginator)sender, args.DocumentPage);
                _SynthesizeGlobalPageNumber((DynamicDocumentPaginator)sender, args.PageNumber, out pageNumber);
            }

            if (!args.Cancelled)
            {
                // Notify all outstanding request for this particular page
                ArrayList notificationList = new ArrayList();
                IEnumerator<KeyValuePair<Object, GetPageAsyncRequest>> ienum = _asyncOps.GetEnumerator();
                try
                {
                    while (ienum.MoveNext())
                    {
                        GetPageAsyncRequest asyncRequest = ienum.Current.Value;

                        // Process any outstanding request for this PageContent
                        if (completedRequest.Page.Equals(asyncRequest.Page))
                        {
                            notificationList.Add(ienum.Current.Key);
                            // this could throw depending on event handlers that are added
                            _NotifyGetPageAsyncCompleted(sdp, pageNumber, args.Error, asyncRequest.Cancelled, asyncRequest.UserState);
                        }
                    }
                }
                finally
                {
                    // Remove completed requests from current async ops list
                    foreach (Object userState in notificationList)
                    {
                        _asyncOps.Remove(userState);
                    }
                }
            }
        }
Пример #10
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);
                }
            }
        } 
Пример #11
0
        //-------------------------------------------------------------------
        //
        //  Protected Methods
        //
        //-------------------------------------------------------------------

        #region Protected Methods

        /// <summary>
        /// Override for subclasses that wish to add logic when this event is fired.
        /// </summary>
        /// <param name="e">Event arguments for the GetPageCompleted event.</param>
        protected virtual void OnGetPageCompleted(GetPageCompletedEventArgs e)
        {
            if (this.GetPageCompleted != null)
            {
                this.GetPageCompleted(this, e);
            }
        }
Пример #12
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);
            }
        }
 /// <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
     }
 }
 protected virtual new void OnGetPageCompleted(GetPageCompletedEventArgs e)
 {
 }