Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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