/// <summary>
 /// Starts the asynchronous operation.
 /// </summary>
 /// <param name="asyncOperationToStart">Async operation context.</param>
 public void StartAsyncOperation(IPrintSchemaAsyncOperation asyncOperationToStart)
 {
     this.asyncOperationContext = asyncOperationToStart;
     Visibility = Visibility.Visible;
     asyncOperationToStart.Completed += asyncOperation_Completed;
     asyncOperationToStart.Start();
 }
        /// <summary>
        /// Commits the input print ticket asynchronously. The completed event handler is expected to close the window.
        /// </summary>
        /// <param name="validatedTicket"></param>
        private void CommitPrintTicketAsync(IPrintSchemaTicket validatedTicket)
        {
            IPrintSchemaAsyncOperation commitAsyncOperation = printerExtensionEventArgs.Ticket.CommitAsync(validatedTicket);

            commitAsyncOperation.Completed += PrintTicketCommitCompleted;
            commitAsyncOperation.Start();
        }
 /// <summary>
 /// Starts the asynchronous operation.
 /// </summary>
 /// <param name="asyncOperationToStart">Async operation context.</param>
 public void StartAsyncOperation(IPrintSchemaAsyncOperation asyncOperationToStart)
 {
     this.asyncOperationContext = asyncOperationToStart;
     Visibility = Visibility.Visible;
     asyncOperationToStart.Completed += asyncOperation_Completed;
     asyncOperationToStart.Start();
 }
        /// <summary>
        ///  Button click event handler.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button clickedButton = (Button)sender;

            switch (clickedButton.Name)
            {
            case "CancelButton":
                CancelRequestAndCloseWindow();
                break;

            case "OkButton":
                //
                // Validate the print ticket asynchronously. The event handler is invoked when the validation is completed.
                //

                IPrintSchemaAsyncOperation asyncOperation = displayedPrintTicket.ValidateAsync();

                //
                // Pop up a modal dialog that prevents the user from changing selections when validation is in progress.
                // Since this dialog lives as long as the parent window, it is not mandatory to unregister the delegate for the
                // 'Completed' event.
                //

                ValidationModalDialog.Completed += PrintTicketValidateCompleted;     // This operation is idempotent.
                ValidationModalDialog.StartAsyncOperation(asyncOperation);
                break;

            case "VerifyButton":
                //
                // Force WPF Data binding to refresh the UI. This operation retrieves
                // a fresh print capabilities for the print ticket based on the user selections.
                //

                PropertyChanged(this, new PropertyChangedEventArgs("PrintSchemaHelperSource"));
                break;
            }
        }