/// <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);
        }
Ejemplo n.º 2
0
 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;
     });
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        /// <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;
            });
        }
Ejemplo n.º 6
0
        /// <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);
            })));
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Sets if the Cancel button is visible.
 /// </summary>
 /// <param name="value"></param>
 public void SetCancelable(bool value)
 {
     WrappedDialog.Invoke(() => WrappedDialog.IsCancelable = value);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Sets the ProgressBar's IsIndeterminate to true. To set it to false, call SetProgress.
 /// </summary>
 public void SetIndeterminate()
 {
     WrappedDialog.Invoke(() => WrappedDialog.SetIndeterminate());
 }
Ejemplo n.º 9
0
 private void PART_NegativeButton_Click(object sender, RoutedEventArgs e)
 {
     WrappedDialog.Invoke(Abort);
     e.Handled = true;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Sets the ProgressBar's IsIndeterminate to true. To set it to false, call SetProgress.
 /// </summary>
 public void SetIndeterminate()
 {
     InvokeAction(() => WrappedDialog.SetIndeterminate());
 }
Ejemplo n.º 11
0
 /// <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);
 }
Ejemplo n.º 12
0
 /// <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);
 }