Skip to content

Commit

Permalink
Merge pull request #2150 from bigworld12/some-progressbar-dialog-fixes
Browse files Browse the repository at this point in the history
Some progressbar dialog fixes
  • Loading branch information
punker76 committed Oct 2, 2015
2 parents 3c90b1e + b7f2876 commit f3270c3
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions MahApps.Metro/Controls/Dialogs/ProgressDialogController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,27 @@ public class ProgressDialogController
private ProgressDialog WrappedDialog { get; set; }
private Func<Task> CloseCallback { get; set; }

/// <summary>
/// Gets if the wrapped ProgressDialog is open.
/// </summary>
[Obsolete("Use the Closed event instead")]
public bool IsOpen { get; private set; }


/// <summary>
/// This event is raised when the associated <see cref="ProgressDialog"/> was closed.
/// This event is raised when the associated <see cref="ProgressDialog"/> was closed programmatically.
/// </summary>
public event EventHandler Closed;

/// <summary>
/// This event is raised when the associated <see cref="ProgressDialog"/> was cancelled by the user.
/// </summary>
public event EventHandler Canceled;

/// <summary>
/// Gets if the Cancel button has been pressed.
/// </summary>
public bool IsCanceled { get; private set; }

/// <summary>
/// Gets if the wrapped ProgressDialog is open.
/// </summary>
public bool IsOpen { get; private set;}

internal ProgressDialogController(ProgressDialog dialog, Func<Task> closeCallBack)
{
Expand All @@ -44,6 +55,11 @@ private void PART_NegativeButton_Click(object sender, RoutedEventArgs e)
{
Action action = () => {
IsCanceled = true;
var handler = Canceled;
if (handler != null)
{
handler(this, EventArgs.Empty);
}
WrappedDialog.PART_NegativeButton.IsEnabled = false;
};

Expand Down Expand Up @@ -121,10 +137,7 @@ public void SetTitle(string title)
InvokeAction(() => WrappedDialog.Title = title);
}

/// <summary>
/// Gets if the Cancel button has been pressed.
/// </summary>
public bool IsCanceled { get; private set; }


/// <summary>
/// Begins an operation to close the ProgressDialog.
Expand All @@ -135,7 +148,7 @@ public Task CloseAsync()
Action action = () => {
if (!WrappedDialog.IsVisible)
{
throw new InvalidOperationException();
throw new InvalidOperationException("Dialog isn't visible to close");
}
WrappedDialog.Dispatcher.VerifyAccess();
WrappedDialog.PART_NegativeButton.Click -= PART_NegativeButton_Click;
Expand Down

0 comments on commit f3270c3

Please sign in to comment.