From 2a7d04ce45ff45e411517f6c882d63947a294839 Mon Sep 17 00:00:00 2001 From: Markus Ewald Date: Thu, 27 Mar 2008 18:34:17 +0000 Subject: [PATCH] Updated ProgressReporterForm to reflect the latest changes to the Tracking framework; renamed WeightedProgression.cs to WeightedWaitable.cs in order to match the previous name changed of the class contained therein; improved documentation of the Camera class git-svn-id: file:///srv/devel/repo-conversion/nuwi@19 d2e56fa2-650e-0410-a79f-9358c0239efd --- .../ProgressReporter/ProgressReporterForm.cs | 22 +++++++++++-------- Source/TrackingBar/ToolStripTrackingBar.cs | 6 ++--- Source/TrackingBar/TrackingBar.cs | 18 +++++++-------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/Source/ProgressReporter/ProgressReporterForm.cs b/Source/ProgressReporter/ProgressReporterForm.cs index 826160f..00c2732 100644 --- a/Source/ProgressReporter/ProgressReporterForm.cs +++ b/Source/ProgressReporter/ProgressReporterForm.cs @@ -37,8 +37,8 @@ namespace Nuclex.Windows.Forms { InitializeComponent(); this.asyncEndedDelegate = new EventHandler(asyncEnded); - this.asyncProgressUpdatedDelegate = new EventHandler( - asyncProgressUpdated + this.asyncProgressChangedDelegate = new EventHandler( + asyncProgressChanged ); } @@ -48,7 +48,7 @@ namespace Nuclex.Windows.Forms { /// /// Progression for whose duration to show the progress reporter /// - public static void Track(Progression progression) { + public static void Track(Waitable progression) { Track(null, progression); } @@ -61,7 +61,7 @@ namespace Nuclex.Windows.Forms { /// /// Progression for whose duration to show the progress reporter /// - public static void Track(string windowTitle, Progression progression) { + public static void Track(string windowTitle, Waitable progression) { // Small optimization to avoid the lengthy control creation when // the progression has already ended @@ -94,7 +94,7 @@ namespace Nuclex.Windows.Forms { /// /// Progression for whose duration to show the progress reporter /// - private void track(string windowTitle, Progression progression) { + private void track(string windowTitle, Waitable progression) { // Set the window title if the user wants to use a custom one if(windowTitle != null) @@ -106,7 +106,9 @@ namespace Nuclex.Windows.Forms { // Subscribe the form to the progression it is supposed to monitor progression.AsyncEnded += this.asyncEndedDelegate; - progression.AsyncProgressUpdated += this.asyncProgressUpdatedDelegate; + IProgressReporter progressReporter = progression as IProgressReporter; + if(progressReporter != null) + progressReporter.AsyncProgressChanged += this.asyncProgressChangedDelegate; // The progression might have ended before this line was reached, if that's // the case, we don't show the dialog at all. @@ -114,7 +116,9 @@ namespace Nuclex.Windows.Forms { ShowDialog(); // We're done, unsubscribe from the progression's events again - progression.AsyncProgressUpdated -= this.asyncProgressUpdatedDelegate; + progressReporter = progression as IProgressReporter; + if(progressReporter != null) + progressReporter.AsyncProgressChanged -= this.asyncProgressChangedDelegate; progression.AsyncEnded -= this.asyncEndedDelegate; } @@ -144,7 +148,7 @@ namespace Nuclex.Windows.Forms { /// /// Contains the new progress achieved by the progression /// - private void asyncProgressUpdated(object sender, ProgressUpdateEventArgs arguments) { + private void asyncProgressChanged(object sender, ProgressReportEventArgs arguments) { // See if this is the first progress update we're receiving. If yes, we need to // switch the progress bar from marquee into its normal mode! @@ -205,7 +209,7 @@ namespace Nuclex.Windows.Forms { /// Delegate for the asyncEnded() method private EventHandler asyncEndedDelegate; /// Delegate for the asyncProgressUpdated() method - private EventHandler asyncProgressUpdatedDelegate; + private EventHandler asyncProgressChangedDelegate; /// Whether the form can be closed and should be closed /// /// 0: Nothing happened yet diff --git a/Source/TrackingBar/ToolStripTrackingBar.cs b/Source/TrackingBar/ToolStripTrackingBar.cs index c66aaae..9ad602c 100644 --- a/Source/TrackingBar/ToolStripTrackingBar.cs +++ b/Source/TrackingBar/ToolStripTrackingBar.cs @@ -28,20 +28,20 @@ namespace Nuclex.Windows.Forms { /// Tracks the specified progression in the tracking bar /// Progression to be tracked - public void Track(Progression progression) { + public void Track(Waitable progression) { TrackingBarControl.Track(progression); } /// Tracks the specified progression in the tracking bar /// Progression to be tracked /// Weight of this progression in the total progress - public void Track(Progression progression, float weight) { + public void Track(Waitable progression, float weight) { TrackingBarControl.Track(progression, weight); } /// Stops tracking the specified progression /// Progression to stop tracking - public void Untrack(Progression progression) { + public void Untrack(Waitable progression) { TrackingBarControl.Untrack(progression); } diff --git a/Source/TrackingBar/TrackingBar.cs b/Source/TrackingBar/TrackingBar.cs index 53eeaaa..cb59e00 100644 --- a/Source/TrackingBar/TrackingBar.cs +++ b/Source/TrackingBar/TrackingBar.cs @@ -48,32 +48,32 @@ namespace Nuclex.Windows.Forms { this.asyncIdleStateChangedDelegate = new EventHandler( asyncIdleStateChanged ); - this.asyncProgressUpdateDelegate = new EventHandler( + this.asyncProgressUpdateDelegate = new EventHandler( asyncProgressUpdated ); // Create the tracker and attach ourselfes to its events - this.tracker = new ProgressionTracker(); + this.tracker = new ProgressTracker(); this.tracker.AsyncIdleStateChanged += this.asyncIdleStateChangedDelegate; - this.tracker.AsyncProgressUpdated += this.asyncProgressUpdateDelegate; + this.tracker.AsyncProgressChanged += this.asyncProgressUpdateDelegate; } /// Tracks the specified progression in the tracking bar /// Progression to be tracked - public void Track(Progression progression) { + public void Track(Waitable progression) { this.tracker.Track(progression); } /// Tracks the specified progression in the tracking bar /// Progression to be tracked /// Weight of this progression in the total progress - public void Track(Progression progression, float weight) { + public void Track(Waitable progression, float weight) { this.tracker.Track(progression, weight); } /// Stops tracking the specified progression /// Progression to stop tracking - public void Untrack(Progression progression) { + public void Untrack(Waitable progression) { this.tracker.Untrack(progression); } @@ -83,7 +83,7 @@ namespace Nuclex.Windows.Forms { /// Progression whose progress has changed /// Contains the progress achieved by the progression private void asyncProgressUpdated( - object sender, ProgressUpdateEventArgs arguments + object sender, ProgressReportEventArgs arguments ) { AsyncSetValue(arguments.Progress); } @@ -120,13 +120,13 @@ namespace Nuclex.Windows.Forms { /// Whether the progress bar is in the idle state private volatile bool isIdle; /// Tracker used to sum and update the total progress - private ProgressionTracker tracker; + private ProgressTracker tracker; /// Delegate for the idle state update method private MethodInvoker updateIdleStateDelegate; /// Delegate for the OnAsyncProgressionEnded method private EventHandler asyncIdleStateChangedDelegate; /// Delegate for the OnAsyncProgressionProgressUpdated method - private EventHandler asyncProgressUpdateDelegate; + private EventHandler asyncProgressUpdateDelegate; }