Followup-Change to the rename from Waitable to Transaction; fixes several comments which were still referring to "Progression", the stone-age name of the concept; fixed a minor grammatical error in the comments

git-svn-id: file:///srv/devel/repo-conversion/nuwi@26 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
Markus Ewald 2008-12-14 18:06:31 +00:00
parent 4c24b82836
commit 112e5993ef
6 changed files with 109 additions and 98 deletions

View File

@ -47,6 +47,7 @@ namespace Nuclex.Windows.Forms {
} }
#endregion #endregion
} }
} // namespace Nuclex.Windows.Forms } // namespace Nuclex.Windows.Forms

View File

@ -42,7 +42,7 @@ namespace Nuclex.Windows.Forms {
/// <summary>Initializes a new ContainerListView</summary> /// <summary>Initializes a new ContainerListView</summary>
public ContainerListView() { public ContainerListView() {
this.embeddedControlClickedHandler = new EventHandler(embeddedControlClicked); this.embeddedControlClickedDelegate = new EventHandler(embeddedControlClicked);
this.embeddedControls = new ListViewEmbeddedControlCollection(); this.embeddedControls = new ListViewEmbeddedControlCollection();
@ -67,12 +67,12 @@ namespace Nuclex.Windows.Forms {
/// <summary>Called when the list of embedded controls has been cleared</summary> /// <summary>Called when the list of embedded controls has been cleared</summary>
/// <param name="sender">Collection that has been cleared of its controls</param> /// <param name="sender">Collection that has been cleared of its controls</param>
/// <param name="e">Not used</param> /// <param name="arguments">Not used</param>
private void embeddedControlsClearing(object sender, EventArgs e) { private void embeddedControlsClearing(object sender, EventArgs arguments) {
this.BeginUpdate(); this.BeginUpdate();
try { try {
foreach(ListViewEmbeddedControl embeddedControl in this.embeddedControls) { foreach(ListViewEmbeddedControl embeddedControl in this.embeddedControls) {
embeddedControl.Control.Click -= this.embeddedControlClickedHandler; embeddedControl.Control.Click -= this.embeddedControlClickedDelegate;
this.Controls.Remove(embeddedControl.Control); this.Controls.Remove(embeddedControl.Control);
} }
} }
@ -83,30 +83,36 @@ namespace Nuclex.Windows.Forms {
/// <summary>Called when a control gets removed from the embedded controls list</summary> /// <summary>Called when a control gets removed from the embedded controls list</summary>
/// <param name="sender">List from which the control has been removed</param> /// <param name="sender">List from which the control has been removed</param>
/// <param name="e">Event arguments providing a reference to the removed control</param> /// <param name="arguments">
/// Event arguments providing a reference to the removed control
/// </param>
private void embeddedControlAdded( private void embeddedControlAdded(
object sender, ListViewEmbeddedControlCollection.ListViewEmbeddedControlEventArgs e object sender,
ListViewEmbeddedControlCollection.ListViewEmbeddedControlEventArgs arguments
) { ) {
e.EmbeddedControl.Control.Click += this.embeddedControlClickedHandler; arguments.EmbeddedControl.Control.Click += this.embeddedControlClickedDelegate;
this.Controls.Add(e.EmbeddedControl.Control); this.Controls.Add(arguments.EmbeddedControl.Control);
} }
/// <summary>Called when a control gets added to the embedded controls list</summary> /// <summary>Called when a control gets added to the embedded controls list</summary>
/// <param name="sender">List to which the control has been added</param> /// <param name="sender">List to which the control has been added</param>
/// <param name="e">Event arguments providing a reference to the added control</param> /// <param name="arguments">
/// Event arguments providing a reference to the added control
/// </param>
private void embeddedControlRemoved( private void embeddedControlRemoved(
object sender, ListViewEmbeddedControlCollection.ListViewEmbeddedControlEventArgs e object sender,
ListViewEmbeddedControlCollection.ListViewEmbeddedControlEventArgs arguments
) { ) {
if(this.Controls.Contains(e.EmbeddedControl.Control)) { if(this.Controls.Contains(arguments.EmbeddedControl.Control)) {
e.EmbeddedControl.Control.Click -= this.embeddedControlClickedHandler; arguments.EmbeddedControl.Control.Click -= this.embeddedControlClickedDelegate;
this.Controls.Remove(e.EmbeddedControl.Control); this.Controls.Remove(arguments.EmbeddedControl.Control);
} }
} }
/// <summary>Called when an embedded control has been clicked on</summary> /// <summary>Called when an embedded control has been clicked on</summary>
/// <param name="sender">Embedded control that has been clicked</param> /// <param name="sender">Embedded control that has been clicked</param>
/// <param name="e">Not used</param> /// <param name="arguments">Not used</param>
private void embeddedControlClicked(object sender, EventArgs e) { private void embeddedControlClicked(object sender, EventArgs arguments) {
this.BeginUpdate(); this.BeginUpdate();
try { try {
@ -174,7 +180,7 @@ namespace Nuclex.Windows.Forms {
} }
/// <summary>Event handler for when embedded controls are clicked on</summary> /// <summary>Event handler for when embedded controls are clicked on</summary>
private EventHandler embeddedControlClickedHandler; private EventHandler embeddedControlClickedDelegate;
/// <summary>Controls being embedded in this ListView</summary> /// <summary>Controls being embedded in this ListView</summary>
private ListViewEmbeddedControlCollection embeddedControls; private ListViewEmbeddedControlCollection embeddedControls;

View File

@ -80,7 +80,7 @@ namespace Nuclex.Windows.Forms {
OnControlRemoved(value); OnControlRemoved(value);
} }
// These three methods don't need to be override since their current implementations // These three methods don't need an override since their current implementations
// in the .NET Framework 2.0 all call the Remove() method on each individual control. // in the .NET Framework 2.0 all call the Remove() method on each individual control.
// The ControlAdded/ControlRemoved events weren't in the original class and there // The ControlAdded/ControlRemoved events weren't in the original class and there
// are other designs you could use to guarantee that removed controls get disposed // are other designs you could use to guarantee that removed controls get disposed

View File

@ -43,36 +43,36 @@ namespace Nuclex.Windows.Forms {
} }
/// <summary> /// <summary>
/// Shows the progress reporter until the specified progression has ended. /// Shows the progress reporter until the specified transaction has ended.
/// </summary> /// </summary>
/// <param name="progression"> /// <param name="transaction">
/// Progression for whose duration to show the progress reporter /// Transaction for whose duration to show the progress reporter
/// </param> /// </param>
public static void Track(Waitable progression) { public static void Track(Transaction transaction) {
Track(null, progression); Track(null, transaction);
} }
/// <summary> /// <summary>
/// Shows the progress reporter until the specified progression has ended. /// Shows the progress reporter until the specified transaction has ended.
/// </summary> /// </summary>
/// <param name="windowTitle"> /// <param name="windowTitle">
/// Text to be shown in the progress reporter's title bar /// Text to be shown in the progress reporter's title bar
/// </param> /// </param>
/// <param name="waitable"> /// <param name="transaction">
/// Process for whose duration to show the progress reporter /// Process for whose duration to show the progress reporter
/// </param> /// </param>
public static void Track(string windowTitle, Waitable waitable) { public static void Track(string windowTitle, Transaction transaction) {
// Small optimization to avoid the lengthy control creation when the waitable // Small optimization to avoid the lengthy control creation when the background
// process has already ended. This is an accepted race condition: If the process // process has already ended. This is an accepted race condition: If the process
// finishes right after this line, it doesn't change the outcome, it just // finishes right after this line, it doesn't change the outcome, it just
// causes the progress dialog to be constructed needlessly. // causes the progress dialog to be constructed needlessly.
if(waitable.Ended) if(transaction.Ended)
return; return;
// Open the form and let it monitor the progression's state // Open the form and let it monitor the transaction's state
using(ProgressReporterForm theForm = new ProgressReporterForm()) { using(ProgressReporterForm theForm = new ProgressReporterForm()) {
theForm.track(windowTitle, waitable); theForm.track(windowTitle, transaction);
} }
} }
@ -83,57 +83,58 @@ namespace Nuclex.Windows.Forms {
base.OnClosing(e); base.OnClosing(e);
// Only allow the form to close when the form is ready to close and the // Only allow the form to close when the form is ready to close and the
// progression being tracked has also finished. // transaction being tracked has also finished.
e.Cancel = (Thread.VolatileRead(ref this.state) < 2); e.Cancel = (Thread.VolatileRead(ref this.state) < 2);
} }
/// <summary> /// <summary>
/// Shows the progress reporter until the specified progression has ended. /// Shows the progress reporter until the specified transaction has ended.
/// </summary> /// </summary>
/// <param name="windowTitle"> /// <param name="windowTitle">
/// Text to be shown in the progress reporter's title bar /// Text to be shown in the progress reporter's title bar
/// </param> /// </param>
/// <param name="waitable"> /// <param name="transaction">
/// Waitable for whose duration to show the progress reporter /// Transaction for whose duration to show the progress reporter
/// </param> /// </param>
private void track(string windowTitle, Waitable waitable) { private void track(string windowTitle, Transaction transaction) {
// Set the window title if the user wants to use a custom one // Set the window title if the user wants to use a custom one
if(windowTitle != null) if(windowTitle != null)
Text = windowTitle; Text = windowTitle;
// Only enable the cancel button if the progression can be aborted // Only enable the cancel button if the transaction can be aborted
this.abortReceiver = (waitable as IAbortable); this.abortReceiver = (transaction as IAbortable);
this.cancelButton.Enabled = (this.abortReceiver != null); this.cancelButton.Enabled = (this.abortReceiver != null);
// Make sure the progress bar control has been created (otherwise, we've got // Make sure the progress bar control has been created (otherwise, we've got
// a chance that BeginInvoke() would fail if the first progress notification // a chance that BeginInvoke() would fail if the first progress notification
// arrived before we called ShowDialog()!) // arrived before we called ShowDialog()!)
{ IntPtr tempDummy = this.progressBar.Handle; } { IntPtr tempDummy = this.progressBar.Handle; }
// Subscribe the form to the progression it is supposed to monitor. // Subscribe the form to the transaction it is supposed to monitor.
// Careful: With the new 'Waitable' design, this can cause the asyncEndedDelegate // Careful: With the new design, this can cause the asyncEndedDelegate()
// callback to be called immediately and synchronously! // callback to be called immediately and synchronously!
waitable.AsyncEnded += this.asyncEndedDelegate; transaction.AsyncEnded += this.asyncEndedDelegate;
IProgressReporter progressReporter = waitable as IProgressReporter; IProgressReporter progressReporter = transaction as IProgressReporter;
if(progressReporter != null) if(progressReporter != null)
progressReporter.AsyncProgressChanged += this.asyncProgressChangedDelegate; progressReporter.AsyncProgressChanged += this.asyncProgressChangedDelegate;
// The progression might have ended before this line was reached, if that's // The transaction might have ended before this line was reached, if that's
// the case, we don't show the dialog at all. // the case, we don't show the dialog at all.
if(!waitable.Ended) if(!transaction.Ended)
ShowDialog(); ShowDialog();
// We're done, unsubscribe from the progression's events again // We're done, unsubscribe from the transaction's events again
progressReporter = waitable as IProgressReporter; progressReporter = transaction as IProgressReporter;
if(progressReporter != null) if(progressReporter != null) {
progressReporter.AsyncProgressChanged -= this.asyncProgressChangedDelegate; progressReporter.AsyncProgressChanged -= this.asyncProgressChangedDelegate;
waitable.AsyncEnded -= this.asyncEndedDelegate; }
transaction.AsyncEnded -= this.asyncEndedDelegate;
} }
/// <summary>Called when the progression has ended</summary> /// <summary>Called when the transaction has ended</summary>
/// <param name="sender">Progression that has ended</param> /// <param name="sender">Transaction that has ended</param>
/// <param name="arguments">Not used</param> /// <param name="arguments">Not used</param>
private void asyncEnded(object sender, EventArgs arguments) { private void asyncEnded(object sender, EventArgs arguments) {
@ -143,19 +144,20 @@ namespace Nuclex.Windows.Forms {
// Close the dialog. Ensure the Close() method is invoked from the // Close the dialog. Ensure the Close() method is invoked from the
// same thread the dialog was created in. // same thread the dialog was created in.
if(InvokeRequired) if(InvokeRequired) {
Invoke(new MethodInvoker(Close)); Invoke(new MethodInvoker(Close));
else } else {
Close(); Close();
}
} }
} }
/// <summary>Called when the tracked progression's progress updates</summary> /// <summary>Called when the tracked transaction's progress updates</summary>
/// <param name="sender">Progression whose progress has been updated</param> /// <param name="sender">Transaction whose progress has been updated</param>
/// <param name="arguments"> /// <param name="arguments">
/// Contains the new progress achieved by the progression /// Contains the new progress achieved by the transaction
/// </param> /// </param>
private void asyncProgressChanged(object sender, ProgressReportEventArgs arguments) { private void asyncProgressChanged(object sender, ProgressReportEventArgs arguments) {
@ -178,8 +180,8 @@ namespace Nuclex.Windows.Forms {
/// close request arrives at an inappropriate time. /// close request arrives at an inappropriate time.
/// </summary> /// </summary>
/// <param name="sender">Timer that has ticked</param> /// <param name="sender">Timer that has ticked</param>
/// <param name="e">Not used</param> /// <param name="arguments">Not used</param>
private void controlCreationTimerTicked(object sender, EventArgs e) { private void controlCreationTimerTicked(object sender, EventArgs arguments) {
// This timer is intended to run only once to find out when the dialog has // This timer is intended to run only once to find out when the dialog has
// been fully constructed and is running its message pump. So we'll disable // been fully constructed and is running its message pump. So we'll disable
@ -188,8 +190,9 @@ namespace Nuclex.Windows.Forms {
// If the new state is 2, then the form was requested to close before it had // If the new state is 2, then the form was requested to close before it had
// been fully constructed, so we should close it now! // been fully constructed, so we should close it now!
if(Interlocked.Increment(ref this.state) == 2) if(Interlocked.Increment(ref this.state) == 2) {
Close(); Close();
}
} }
@ -197,8 +200,8 @@ namespace Nuclex.Windows.Forms {
/// Aborts the background operation when the user clicks the cancel button /// Aborts the background operation when the user clicks the cancel button
/// </summary> /// </summary>
/// <param name="sender">Button that has been clicked</param> /// <param name="sender">Button that has been clicked</param>
/// <param name="e">Not used</param> /// <param name="arguments">Not used</param>
private void cancelClicked(object sender, EventArgs e) { private void cancelClicked(object sender, EventArgs arguments) {
if(this.abortReceiver != null) { if(this.abortReceiver != null) {
@ -226,10 +229,10 @@ namespace Nuclex.Windows.Forms {
/// 2: Ready to close and close requested, triggers close /// 2: Ready to close and close requested, triggers close
/// </remarks> /// </remarks>
private int state; private int state;
/// <summary>Whether we're receiving progress updates from the progression</summary> /// <summary>Whether we're receiving progress updates from the transaction</summary>
/// <remarks> /// <remarks>
/// 0: No progress updates have arrived so far /// 0: No progress updates have arrived so far
/// 1: We have received at least one progress update from the progression /// 1: We have received at least one progress update from the transaction
/// </remarks> /// </remarks>
private int areProgressUpdatesIncoming; private int areProgressUpdatesIncoming;
/// <summary> /// <summary>

View File

@ -26,23 +26,23 @@ namespace Nuclex.Windows.Forms {
get { return base.Control as TrackingBar; } get { return base.Control as TrackingBar; }
} }
/// <summary>Tracks the specified progression in the tracking bar</summary> /// <summary>Tracks the specified transaction in the tracking bar</summary>
/// <param name="progression">Progression to be tracked</param> /// <param name="transaction">Transaction to be tracked</param>
public void Track(Waitable progression) { public void Track(Transaction transaction) {
TrackingBarControl.Track(progression); TrackingBarControl.Track(transaction);
} }
/// <summary>Tracks the specified progression in the tracking bar</summary> /// <summary>Tracks the specified transaction in the tracking bar</summary>
/// <param name="progression">Progression to be tracked</param> /// <param name="transaction">Transaction to be tracked</param>
/// <param name="weight">Weight of this progression in the total progress</param> /// <param name="weight">Weight of this transaction in the total progress</param>
public void Track(Waitable progression, float weight) { public void Track(Transaction transaction, float weight) {
TrackingBarControl.Track(progression, weight); TrackingBarControl.Track(transaction, weight);
} }
/// <summary>Stops tracking the specified progression</summary> /// <summary>Stops tracking the specified transaction</summary>
/// <param name="progression">Progression to stop tracking</param> /// <param name="transaction">Transaction to stop tracking</param>
public void Untrack(Waitable progression) { public void Untrack(Transaction transaction) {
TrackingBarControl.Untrack(progression); TrackingBarControl.Untrack(transaction);
} }
/// <summary>Default size of the hosted control</summary> /// <summary>Default size of the hosted control</summary>
@ -82,8 +82,8 @@ namespace Nuclex.Windows.Forms {
/// visibility changes. /// visibility changes.
/// </summary> /// </summary>
/// <param name="sender">Tracking bar control whose visiblity has changed</param> /// <param name="sender">Tracking bar control whose visiblity has changed</param>
/// <param name="e">Not used</param> /// <param name="arguments">Not used</param>
private void trackingBarVisibleChanged(object sender, EventArgs e) { private void trackingBarVisibleChanged(object sender, EventArgs arguments) {
base.Visible = TrackingBarControl.Visible; base.Visible = TrackingBarControl.Visible;
} }

View File

@ -58,51 +58,52 @@ namespace Nuclex.Windows.Forms {
this.tracker.AsyncProgressChanged += this.asyncProgressUpdateDelegate; this.tracker.AsyncProgressChanged += this.asyncProgressUpdateDelegate;
} }
/// <summary>Tracks the specified progression in the tracking bar</summary> /// <summary>Tracks the specified transaction in the tracking bar</summary>
/// <param name="progression">Progression to be tracked</param> /// <param name="transaction">Transaction to be tracked</param>
public void Track(Waitable progression) { public void Track(Transaction transaction) {
this.tracker.Track(progression); this.tracker.Track(transaction);
} }
/// <summary>Tracks the specified progression in the tracking bar</summary> /// <summary>Tracks the specified transaction in the tracking bar</summary>
/// <param name="progression">Progression to be tracked</param> /// <param name="transaction">Transaction to be tracked</param>
/// <param name="weight">Weight of this progression in the total progress</param> /// <param name="weight">Weight of this transaction in the total progress</param>
public void Track(Waitable progression, float weight) { public void Track(Transaction transaction, float weight) {
this.tracker.Track(progression, weight); this.tracker.Track(transaction, weight);
} }
/// <summary>Stops tracking the specified progression</summary> /// <summary>Stops tracking the specified transaction</summary>
/// <param name="progression">Progression to stop tracking</param> /// <param name="transaction">Transaction to stop tracking</param>
public void Untrack(Waitable progression) { public void Untrack(Transaction transaction) {
this.tracker.Untrack(progression); this.tracker.Untrack(transaction);
} }
/// <summary> /// <summary>
/// Called when the summed progressed of the tracked progressions has changed /// Called when the summed progressed of the tracked transaction has changed
/// </summary> /// </summary>
/// <param name="sender">Progression whose progress has changed</param> /// <param name="sender">Transaction whose progress has changed</param>
/// <param name="arguments">Contains the progress achieved by the progression</param> /// <param name="arguments">Contains the progress achieved by the transaction</param>
private void asyncProgressUpdated( private void asyncProgressUpdated(
object sender, ProgressReportEventArgs arguments object sender, ProgressReportEventArgs arguments
) { ) {
AsyncSetValue(arguments.Progress); AsyncSetValue(arguments.Progress);
} }
/// <summary>Called when the tracker becomes enters of leaves the idle state</summary> /// <summary>Called when the tracker becomes enters of leaves the idle state</summary>
/// <param name="sender">Tracker that has entered or left the idle state</param> /// <param name="sender">Tracker that has entered or left the idle state</param>
/// <param name="arguments">Contains the new idle state</param> /// <param name="arguments">Contains the new idle state</param>
private void asyncIdleStateChanged(object sender, IdleStateEventArgs arguments) { private void asyncIdleStateChanged(object sender, IdleStateEventArgs arguments) {
// Do a fully synchronous update of the idle state. This update must not be // Do a fully synchronous update of the idle state. This update must not be
// lost because otherwise, the progress bar might stay on-screen when in fact, // lost because otherwise, the progress bar might stay on-screen when in fact,
// the background operation has already finished and nothing is happening anymore. // the background operation has already finished and nothing is happening anymore.
this.isIdle = arguments.Idle; this.isIdle = arguments.Idle;
// Update the bar's idle state // Update the bar's idle state
if(InvokeRequired) if(InvokeRequired) {
Invoke(this.updateIdleStateDelegate); Invoke(this.updateIdleStateDelegate);
else } else {
updateIdleState(); updateIdleState();
}
} }
@ -123,9 +124,9 @@ namespace Nuclex.Windows.Forms {
private ProgressTracker tracker; private ProgressTracker tracker;
/// <summary>Delegate for the idle state update method</summary> /// <summary>Delegate for the idle state update method</summary>
private MethodInvoker updateIdleStateDelegate; private MethodInvoker updateIdleStateDelegate;
/// <summary>Delegate for the OnAsyncProgressionEnded method</summary> /// <summary>Delegate for the asyncIdleStateChanged() method</summary>
private EventHandler<IdleStateEventArgs> asyncIdleStateChangedDelegate; private EventHandler<IdleStateEventArgs> asyncIdleStateChangedDelegate;
/// <summary>Delegate for the OnAsyncProgressionProgressUpdated method</summary> /// <summary>Delegate for the asyncProgressUpdate() method</summary>
private EventHandler<ProgressReportEventArgs> asyncProgressUpdateDelegate; private EventHandler<ProgressReportEventArgs> asyncProgressUpdateDelegate;
} }