/// <summary> /// Begins an operation to close the ProgressDialog. /// </summary> /// <returns>A task representing the operation.</returns> public Task CloseAsync() { var tcs = new TaskCompletionSource <object>(); WrappedDialog.IsOpenChanged += (sender, e) => { IsOpen = false; Closed?.Invoke(this, EventArgs.Empty); tcs.TrySetResult(null); }; WrappedDialog.Invoke(() => { if (!WrappedDialog.IsVisible) { throw new InvalidOperationException("Dialog isn't visible to close"); } WrappedDialog.Dispatcher.VerifyAccess(); WrappedDialog.PART_NegativeButton.Click -= PART_NegativeButton_Click; WrappedDialog.Close(); }); return(tcs.Task); }
private void WrappedDialog_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Escape || (e.Key == Key.System && e.SystemKey == Key.F4)) { WrappedDialog.Invoke(Abort); } }
private void PART_NegativeButton_Click(object sender, RoutedEventArgs e) { WrappedDialog.Invoke(() => { IsCanceled = true; Canceled?.Invoke(this, EventArgs.Empty); WrappedDialog.PART_NegativeButton.IsEnabled = false; }); }
private void PART_NegativeButton_Click(object sender, RoutedEventArgs e) { Action action = () => { this.IsCanceled = true; this.Canceled?.Invoke(this, EventArgs.Empty); this.WrappedDialog.PART_NegativeButton.IsEnabled = false; }; WrappedDialog.Invoke(action); }
/// <summary> /// Sets the dialog's progress bar value and sets IsIndeterminate to false. /// </summary> /// <param name="value">The percentage to set as the value.</param> public void SetProgress(double value) { WrappedDialog.Invoke(() => { if (value < WrappedDialog.Minimum || value > WrappedDialog.Maximum) { throw new ArgumentOutOfRangeException(nameof(value)); } WrappedDialog.ProgressValue = value; }); }
/// <summary> /// Begins an operation to close the ProgressDialog. /// </summary> /// <returns>A task representing the operation.</returns> public Task CloseAsync() { Action action = () => { if (!WrappedDialog.IsVisible) { throw new InvalidOperationException("Dialog isn't visible to close"); } WrappedDialog.Dispatcher.VerifyAccess(); WrappedDialog.PART_NegativeButton.Click -= PART_NegativeButton_Click; }; WrappedDialog.Invoke(action); return(this.CloseCallback().ContinueWith(_ => this.WrappedDialog.Invoke(() => { this.IsOpen = false; this.Closed?.Invoke(this, EventArgs.Empty); }))); }
/// <summary> /// Sets if the Cancel button is visible. /// </summary> /// <param name="value"></param> public void SetCancelable(bool value) { WrappedDialog.Invoke(() => WrappedDialog.IsCancelable = value); }
/// <summary> /// Sets the ProgressBar's IsIndeterminate to true. To set it to false, call SetProgress. /// </summary> public void SetIndeterminate() { WrappedDialog.Invoke(() => WrappedDialog.SetIndeterminate()); }
private void PART_NegativeButton_Click(object sender, RoutedEventArgs e) { WrappedDialog.Invoke(Abort); e.Handled = true; }
/// <summary> /// Sets the ProgressBar's IsIndeterminate to true. To set it to false, call SetProgress. /// </summary> public void SetIndeterminate() { InvokeAction(() => WrappedDialog.SetIndeterminate()); }
/// <summary> /// Sets the dialog's title. /// </summary> /// <param name="title">The title to be set.</param> public void SetTitle(string title) { WrappedDialog.Invoke(() => WrappedDialog.Title = title); }
/// <summary> /// Sets the dialog's message content. /// </summary> /// <param name="message">The message to be set.</param> public void SetMessage(string message) { WrappedDialog.Invoke(() => WrappedDialog.Message = message); }