diff --git a/src/Ookii.Dialogs.WinForms/ProgressDialog.cs b/src/Ookii.Dialogs.WinForms/ProgressDialog.cs
index 92a3226..234a0c9 100644
--- a/src/Ookii.Dialogs.WinForms/ProgressDialog.cs
+++ b/src/Ookii.Dialogs.WinForms/ProgressDialog.cs
@@ -36,7 +36,7 @@ namespace Ookii.Dialogs.WinForms
///
///
[DefaultEvent("DoWork"), DefaultProperty("Text"), Description("Represents a dialog that can be used to report progress to the user.")]
- public partial class ProgressDialog : Component
+ public partial class ProgressDialog : Component, IProgress, IProgress
{
private class ProgressChangedData
{
@@ -54,6 +54,7 @@ private class ProgressChangedData
private bool _useCompactPathsForDescription;
private SafeModuleHandle _currentAnimationModuleHandle;
private bool _cancellationPending;
+ private int _percentProgress;
///
/// Event raised when the dialog is displayed.
@@ -530,6 +531,24 @@ public void ShowDialog(IWin32Window owner, object argument)
RunProgressDialog(owner == null ? NativeMethods.GetActiveWindow() : owner.Handle, argument);
}
+ ///
+ /// Updates the dialog's progress bar.
+ ///
+ /// The percentage, from 0 to 100, of the operation that is complete.
+ void IProgress.Report(int value)
+ {
+ ReportProgress(value, null, null, null);
+ }
+
+ ///
+ /// Updates the dialog's progress bar.
+ ///
+ /// The new value of the progress dialog's primary text message, or to leave the value unchanged.
+ void IProgress.Report(string value)
+ {
+ ReportProgress(_percentProgress, value, null, null);
+ }
+
///
/// Updates the dialog's progress bar.
///
@@ -580,6 +599,10 @@ public void ReportProgress(int percentProgress, string text, string description,
throw new ArgumentOutOfRangeException("percentProgress");
if( _dialog == null )
throw new InvalidOperationException(Properties.Resources.ProgressDialogNotRunningError);
+
+ // we need to cache the latest percentProgress so IProgress.Report(text) can report the percent progress correctly.
+ _percentProgress = percentProgress;
+
_backgroundWorker.ReportProgress(percentProgress, new ProgressChangedData() { Text = text, Description = description, UserState = userState });
}