Beispiel #1
0
        protected override void SetLoadingState(XslFOViewerControlState loadingState)
        {
            this.SuspendLayout();

            try
            {
                //Due to UI Control Issues we must HIDE and Re-Show the control
                //to ensure that the UI is always updated.  Therefore we simply always
                //Hide and then only if appropriate do we re-show the control.
                if (_ctlAcrobatPdfViewer != null)
                {
                    _ctlAcrobatPdfViewer.Hide();
                }

                //Always reset the following Timers
                lblPreLoaderTimer.Hide();
                animLoaderTimerText.Stop();
                _loadingStopwatch.Stop();
                preLoaderTimer.Stop();

                //Always reset the following UI Visible elements
                panelPreLoader.Hide();
                panelInitInstructions.Hide();

                //Now handle the correct state for Pre-Loader
                if (loadingState == XslFOViewerControlState.Loading && _ctlAcrobatPdfViewer != null)
                {
                    //Loading State is IN PROGRESS
                    panelPreLoader.Show();
                    _loadingStopwatch.Restart();
                    lblPreLoaderTimer.Text = "";
                    preLoaderTimer.Start();
                    //Kick off the Pre-Load Timer Text animation
                    TaskScheduler.FromCurrentSynchronizationContext().DelayExecution(TimeSpan.FromSeconds(3), () =>
                    {
                        lblPreLoaderTimer.ForeColor = animLoaderTimerText.StartColor;
                        lblPreLoaderTimer.Show();
                        animLoaderTimerText.Start(false);
                    });
                }
                else if (loadingState == XslFOViewerControlState.LoadCompleted && _ctlAcrobatPdfViewer != null)
                {
                    //Update the UI since it is re-set after the Load
                    //Due to COM issues we need to ensure that all calls to the underlying Ctl are property Try/Catch wrapped.
                    this._ctlAcrobatPdfViewer.Show();

                    //The control will maliciously grab focus until after it has completely finished loading
                    //the Pdf file.  There is no Event for us to monitor so instead we simply implement a standard
                    //acceptable wait period.
                    //NOTE:  The process is to re-set the controls original Enabled state  after the wait period has elapsed
                    //       so we execute a background thread to perform the wait and then trigger the update back on the UI
                    //       thread.  This ensures that our UI is not interrupted.
                    //NOTE:  Stop and Restart the delay timer so that it will run after a FULL Delay
                    tmrAcrobatLoadDelay.Stop();
                    tmrAcrobatLoadDelay.Start();
                }
                else if (loadingState == XslFOViewerControlState.Unloaded && _ctlAcrobatPdfViewer != null)
                {
                    //By default we have hidden all elements including the PreLoader and Unavailble Instructions
                    //therefore we do nothing here when the status is simply Unloaded.
                }
                else if (loadingState == XslFOViewerControlState.Unavailable || _ctlAcrobatPdfViewer == null)
                {
                    //IF the Acrobat Pdf Viewer is unable to be Initialized or is Unloaded we handle it here!
                    //NOTE:  If NOT Initialized we must show the Initialize Error Instructions.
                    panelInitInstructions.Show();
                }
            }
            catch (Exception exc)
            {
                System.Diagnostics.Debug.WriteLine("Error Trapped Refreshing UI Elements -- {0}".FormatArgs(exc.GetMessages()));
            }
            finally
            {
                Thread.Yield();
                this.ResumeLayout(true);
            }
        }
 protected virtual void SetLoadingState(XslFOViewerControlState loadingState)
 {
     throw new NotImplementedException("Inheriting Control Must Implement this Method!  It is not marked Abstract due to Visual Studio Designer issues.");
 }