/// <summary>
 /// This method processes the ProgressChanged event of the Store. This is raised by the 
 /// store on method calls that can take a long time to process, for example, SaveBookFiles.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The EventArgs containing the progress progress made so far.</param>
 private void store_ProgressChanged(object sender, ProgressNotificationEventArgs e)
 {
     DoProgressChanged(sender, e);
 }
Example #2
0
 /// <summary>
 /// The Presenter will notify the View of progress during the File Open process.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Presenter_ProgressChanged(object sender, ProgressNotificationEventArgs e)
 {
     // Let the worker process know that there has been some progress. This will result
     // in the ProgressChanged event from being raised.
     _fileOpenBackgroundWorker.ReportProgress(Convert.ToInt32(e.PercentageProgress), e.ProgressMessage);
 }
        /// <summary>
        /// This method is called whenever progress has been made in loading a file (notified by
        /// progress changes made in the datacontext store and the package inspector). 
        /// The ApplicationPresenter can then weight the changes from the two sources and
        /// update the main view for notifying the user of the progress.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The EventArgs containing the progress progress made so far.</param>
        private void DoProgressChanged(object sender, ProgressNotificationEventArgs e)
        {
            double progress;

            if(sender.GetType() == typeof(PackageInspector))
            {
                // For now assume the inspector is doing 10% of the (initial) total work
                progress = e.PercentageProgress * 0.1;
            }
            else
            {
                // Assume that if the store is reporting progress then the Inspector has finished
                // and we are on the final 90%
                progress = 10 + e.PercentageProgress * 0.9;
            }

            // Still a couple of minor issues with calculating exact percentage
            if(progress > 100)
            {
                progress = 100;
            }

            // Pass on overall progress to any subscribers of the presenter's progress
            // (i.e. the View)
            if(ProgressChanged != null)
            {
                string message = "Opening Book... " + progress + "%";
                ProgressChanged(this, new ProgressNotificationEventArgs(progress, message));
            }
        }