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
}
} // namespace Nuclex.Windows.Forms

View File

@ -42,7 +42,7 @@ namespace Nuclex.Windows.Forms {
/// <summary>Initializes a new ContainerListView</summary>
public ContainerListView() {
this.embeddedControlClickedHandler = new EventHandler(embeddedControlClicked);
this.embeddedControlClickedDelegate = new EventHandler(embeddedControlClicked);
this.embeddedControls = new ListViewEmbeddedControlCollection();
@ -67,12 +67,12 @@ namespace Nuclex.Windows.Forms {
/// <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="e">Not used</param>
private void embeddedControlsClearing(object sender, EventArgs e) {
/// <param name="arguments">Not used</param>
private void embeddedControlsClearing(object sender, EventArgs arguments) {
this.BeginUpdate();
try {
foreach(ListViewEmbeddedControl embeddedControl in this.embeddedControls) {
embeddedControl.Control.Click -= this.embeddedControlClickedHandler;
embeddedControl.Control.Click -= this.embeddedControlClickedDelegate;
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>
/// <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(
object sender, ListViewEmbeddedControlCollection.ListViewEmbeddedControlEventArgs e
object sender,
ListViewEmbeddedControlCollection.ListViewEmbeddedControlEventArgs arguments
) {
e.EmbeddedControl.Control.Click += this.embeddedControlClickedHandler;
this.Controls.Add(e.EmbeddedControl.Control);
arguments.EmbeddedControl.Control.Click += this.embeddedControlClickedDelegate;
this.Controls.Add(arguments.EmbeddedControl.Control);
}
/// <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="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(
object sender, ListViewEmbeddedControlCollection.ListViewEmbeddedControlEventArgs e
object sender,
ListViewEmbeddedControlCollection.ListViewEmbeddedControlEventArgs arguments
) {
if(this.Controls.Contains(e.EmbeddedControl.Control)) {
e.EmbeddedControl.Control.Click -= this.embeddedControlClickedHandler;
this.Controls.Remove(e.EmbeddedControl.Control);
if(this.Controls.Contains(arguments.EmbeddedControl.Control)) {
arguments.EmbeddedControl.Control.Click -= this.embeddedControlClickedDelegate;
this.Controls.Remove(arguments.EmbeddedControl.Control);
}
}
/// <summary>Called when an embedded control has been clicked on</summary>
/// <param name="sender">Embedded control that has been clicked</param>
/// <param name="e">Not used</param>
private void embeddedControlClicked(object sender, EventArgs e) {
/// <param name="arguments">Not used</param>
private void embeddedControlClicked(object sender, EventArgs arguments) {
this.BeginUpdate();
try {
@ -174,7 +180,7 @@ namespace Nuclex.Windows.Forms {
}
/// <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>
private ListViewEmbeddedControlCollection embeddedControls;

View File

@ -80,7 +80,7 @@ namespace Nuclex.Windows.Forms {
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.
// 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

View File

@ -43,36 +43,36 @@ namespace Nuclex.Windows.Forms {
}
/// <summary>
/// Shows the progress reporter until the specified progression has ended.
/// Shows the progress reporter until the specified transaction has ended.
/// </summary>
/// <param name="progression">
/// Progression for whose duration to show the progress reporter
/// <param name="transaction">
/// Transaction for whose duration to show the progress reporter
/// </param>
public static void Track(Waitable progression) {
Track(null, progression);
public static void Track(Transaction transaction) {
Track(null, transaction);
}
/// <summary>
/// Shows the progress reporter until the specified progression has ended.
/// Shows the progress reporter until the specified transaction has ended.
/// </summary>
/// <param name="windowTitle">
/// Text to be shown in the progress reporter's title bar
/// </param>
/// <param name="waitable">
/// <param name="transaction">
/// Process for whose duration to show the progress reporter
/// </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
// finishes right after this line, it doesn't change the outcome, it just
// causes the progress dialog to be constructed needlessly.
if(waitable.Ended)
if(transaction.Ended)
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()) {
theForm.track(windowTitle, waitable);
theForm.track(windowTitle, transaction);
}
}
@ -83,57 +83,58 @@ namespace Nuclex.Windows.Forms {
base.OnClosing(e);
// 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);
}
/// <summary>
/// Shows the progress reporter until the specified progression has ended.
/// Shows the progress reporter until the specified transaction has ended.
/// </summary>
/// <param name="windowTitle">
/// Text to be shown in the progress reporter's title bar
/// </param>
/// <param name="waitable">
/// Waitable for whose duration to show the progress reporter
/// <param name="transaction">
/// Transaction for whose duration to show the progress reporter
/// </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
if(windowTitle != null)
Text = windowTitle;
// Only enable the cancel button if the progression can be aborted
this.abortReceiver = (waitable as IAbortable);
// Only enable the cancel button if the transaction can be aborted
this.abortReceiver = (transaction as IAbortable);
this.cancelButton.Enabled = (this.abortReceiver != null);
// Make sure the progress bar control has been created (otherwise, we've got
// a chance that BeginInvoke() would fail if the first progress notification
// arrived before we called ShowDialog()!)
{ IntPtr tempDummy = this.progressBar.Handle; }
// Subscribe the form to the progression it is supposed to monitor.
// Careful: With the new 'Waitable' design, this can cause the asyncEndedDelegate
// Subscribe the form to the transaction it is supposed to monitor.
// Careful: With the new design, this can cause the asyncEndedDelegate()
// callback to be called immediately and synchronously!
waitable.AsyncEnded += this.asyncEndedDelegate;
IProgressReporter progressReporter = waitable as IProgressReporter;
transaction.AsyncEnded += this.asyncEndedDelegate;
IProgressReporter progressReporter = transaction as IProgressReporter;
if(progressReporter != null)
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.
if(!waitable.Ended)
if(!transaction.Ended)
ShowDialog();
// We're done, unsubscribe from the progression's events again
progressReporter = waitable as IProgressReporter;
if(progressReporter != null)
// We're done, unsubscribe from the transaction's events again
progressReporter = transaction as IProgressReporter;
if(progressReporter != null) {
progressReporter.AsyncProgressChanged -= this.asyncProgressChangedDelegate;
waitable.AsyncEnded -= this.asyncEndedDelegate;
}
transaction.AsyncEnded -= this.asyncEndedDelegate;
}
/// <summary>Called when the progression has ended</summary>
/// <param name="sender">Progression that has ended</param>
/// <summary>Called when the transaction has ended</summary>
/// <param name="sender">Transaction that has ended</param>
/// <param name="arguments">Not used</param>
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
// same thread the dialog was created in.
if(InvokeRequired)
if(InvokeRequired) {
Invoke(new MethodInvoker(Close));
else
} else {
Close();
}
}
}
/// <summary>Called when the tracked progression's progress updates</summary>
/// <param name="sender">Progression whose progress has been updated</param>
/// <summary>Called when the tracked transaction's progress updates</summary>
/// <param name="sender">Transaction whose progress has been updated</param>
/// <param name="arguments">
/// Contains the new progress achieved by the progression
/// Contains the new progress achieved by the transaction
/// </param>
private void asyncProgressChanged(object sender, ProgressReportEventArgs arguments) {
@ -178,8 +180,8 @@ namespace Nuclex.Windows.Forms {
/// close request arrives at an inappropriate time.
/// </summary>
/// <param name="sender">Timer that has ticked</param>
/// <param name="e">Not used</param>
private void controlCreationTimerTicked(object sender, EventArgs e) {
/// <param name="arguments">Not used</param>
private void controlCreationTimerTicked(object sender, EventArgs arguments) {
// 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
@ -188,8 +190,9 @@ namespace Nuclex.Windows.Forms {
// 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!
if(Interlocked.Increment(ref this.state) == 2)
if(Interlocked.Increment(ref this.state) == 2) {
Close();
}
}
@ -197,8 +200,8 @@ namespace Nuclex.Windows.Forms {
/// Aborts the background operation when the user clicks the cancel button
/// </summary>
/// <param name="sender">Button that has been clicked</param>
/// <param name="e">Not used</param>
private void cancelClicked(object sender, EventArgs e) {
/// <param name="arguments">Not used</param>
private void cancelClicked(object sender, EventArgs arguments) {
if(this.abortReceiver != null) {
@ -226,10 +229,10 @@ namespace Nuclex.Windows.Forms {
/// 2: Ready to close and close requested, triggers close
/// </remarks>
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>
/// 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>
private int areProgressUpdatesIncoming;
/// <summary>

View File

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

View File

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