private void PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs e) { PrintTask printTask = null; printTask = e.Request.CreatePrintTask("C# Printing SDK Sample", sourceRequested => { printTask.Completed += async(s, args) => { if (args.Completion == PrintTaskCompletion.Failed) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { ContentDialog dialog = new ContentDialog { Title = "Printing error", Content = "\nSorry, failed to print.Task error", PrimaryButtonText = "OK" }; //("Something went wrong while trying to print. Please try again."); await dialog.ShowAsync(); }); } }; sourceRequested.SetSource(printDocSource); }); }
/// <summary> /// This is the event handler for PrintManager.PrintTaskRequested. /// </summary> /// <param name="sender">PrintManager</param> /// <param name="e">PrintTaskRequestedEventArgs </param> protected virtual void PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs e) { PrintTask printTask = null; printTask = e.Request.CreatePrintTask("C# Printing SDK Sample", sourceRequested => { // Print Task event handler is invoked when the print job is completed. printTask.Completed += async(s, args) => { // Notify the user when the print operation fails. if (args.Completion == PrintTaskCompletion.Failed) { await scenarioPage.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { ContentDialog error = new ContentDialog { Title = "Error Printing", Content = "Failed to print.", CloseButtonText = "Ok" }; ContentDialogResult result = await error.ShowAsync(); }); } }; sourceRequested.SetSource(printDocumentSource); }); }
void OnPrintManagerPrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args) { PrintTask printTask = args.Request.CreatePrintTask("The Tale of Tom Kitten", OnPrintTaskSourceRequested); // Get PrintTaskOptionDetails for making changes to options PrintTaskOptionDetails optionDetails = PrintTaskOptionDetails.GetFromPrintTaskOptions(printTask.Options); // Create the custom item PrintCustomItemListOptionDetails pageRange = optionDetails.CreateItemListOption("idPrintRange", "Print range"); pageRange.AddItem("idPrintAll", "Print all pages"); pageRange.AddItem("idPrintCustom", "Print custom range"); // Add it to the options optionDetails.DisplayedOptions.Add("idPrintRange"); // Create a page-range edit item also, but this only // comes into play when user selects "Print custom range" optionDetails.CreateTextOption("idCustomRangeEdit", "Custom Range"); // Set a handler for the OptionChanged event optionDetails.OptionChanged += OnOptionDetailsOptionChanged; }
private void PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs e) { PrintTask printTask = null; printTask = e.Request.CreatePrintTask(this.title, sourceRequested => { sourceRequested.SetSource(this.printDocumentSource); }); var printDetailedOptions = PrintTaskOptionDetails.GetFromPrintTaskOptions(printTask.Options); var displayedOptions = printDetailedOptions.DisplayedOptions; var alignOption = printDetailedOptions.CreateItemListOption("LayoutOption", "Layout Option"); alignOption.AddItem("Center", "Center"); alignOption.AddItem("AlignLeftOrTop", "Align to the Left or to the Top"); alignOption.AddItem("AlignRightOrBottom", "Align to the right or to the bottom"); this.printLayout = PrintPanel.LayoutOption.Centered; displayedOptions.Clear(); displayedOptions.Add(StandardPrintTaskOptions.Copies); displayedOptions.Add("LayoutOption"); displayedOptions.Add(StandardPrintTaskOptions.MediaSize); displayedOptions.Add(StandardPrintTaskOptions.Orientation); displayedOptions.Add(StandardPrintTaskOptions.ColorMode); displayedOptions.Add(StandardPrintTaskOptions.PrintQuality); printDetailedOptions.OptionChanged += this.PrintDetailedOptions_OptionChanged; }
private void Printmgr_PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args) { //从参数的Request属性中获取与PrintTaskRequest的任务关联 //创建好打印内容和任务后 在调用Complete方法进行打印 var deferral = args.Request.GetDeferral(); // 创建打印任务 task = args.Request.CreatePrintTask("Print", OnPrintTaskSourceRequrested); task.Completed += PrintTask_Completed; PrintTaskOptionDetails printDetailedOptions = PrintTaskOptionDetails.GetFromPrintTaskOptions(task.Options); IList <string> displayedOptions = printDetailedOptions.DisplayedOptions; //displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Copies); //displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Orientation); //displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.ColorMode); // Create a new list option PrintCustomItemListOptionDetails pageFormat = printDetailedOptions.CreateItemListOption("PageContent", "Pictures"); pageFormat.AddItem("PicturesText", "Pictures and text"); pageFormat.AddItem("PicturesOnly", "Pictures only"); pageFormat.AddItem("TextOnly", "Text only"); // Add the custom option to the option list displayedOptions.Add("PageContent"); printDetailedOptions.OptionChanged += printDetailedOptions_OptionChanged; deferral.Complete(); }
/// <summary> /// This is the event handler for PrintManager.PrintTaskRequested. /// In order to ensure a good user experience, the system requires that the app handle the PrintTaskRequested event within the time specified by PrintTaskRequestedEventArgs.Request.Deadline. /// Therefore, we use this handler to only create the print task. /// The print settings customization can be done when the print document source is requested. /// </summary> /// <param name="sender">PrintManager</param> /// <param name="e">PrintTaskRequestedEventArgs</param> protected override void PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs e) { PrintTask printTask = null; printTask = e.Request.CreatePrintTask("C# Printing SDK Sample", sourceRequestedArgs => { // Print Task event handler is invoked when the print job is completed. printTask.Completed += async(s, args) => { // Notify the user when the print operation fails. if (args.Completion == PrintTaskCompletion.Failed) { await scenarioPage.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { MainPage.Current.NotifyUser("Failed to print.", NotifyType.ErrorMessage); }); } }; sourceRequestedArgs.SetSource(printDocumentSource); }); // Choose not to show the preview by setting the property on PrintTask printTask.IsPreviewEnabled = false; }
private void PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs e) { PrintTask printTask = null; printTask = e.Request.CreatePrintTask("Squadron Builder", sourceRequested => { // Print Task event handler is invoked when the print job is completed. printTask.Completed += async(s, args) => { // Notify the user when the print operation fails. if (args.Completion == PrintTaskCompletion.Failed) { await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { ContentDialog noPrintingDialog = new ContentDialog() { Title = "Printing error", Content = "\nSorry, printing can' t proceed at this time.", PrimaryButtonText = "OK" }; await noPrintingDialog.ShowAsync(); }); } }; sourceRequested.SetSource(printDocumentSource); }); }
void OnPrintManagerPrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args) { args.Request.CreatePrintTask("Print Printable Area", (requestArgs) => { requestArgs.SetSource(printDocumentSource); }); }
void printMan_PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs p_args) { PrintTask l_printTask = null; l_printTask = p_args.Request.CreatePrintTask("EspaceTablette", p_sourceRequested => { //LogHelper.LogActivityComplete("IMPRESSION : Tâche d'impression demandée"); // Invoqué lorsque la tâche d'impression est terminée l_printTask.Completed += async(s, args) => { //LogHelper.LogActivityComplete("IMPRESSION : Tâche d'impression terminée"); if (args.Completion == PrintTaskCompletion.Failed) { // On informe l'utilisateur que l'impression a rencontrée une erreur await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { //LogHelper.LogActivityComplete("IMPRESSION : Erreur d'impression"); MessageDialog l_dialog = new MessageDialog("print error"); //MessageDialogEx l_dialog = new MessageDialogEx(AppResources.GetResources("PrintErrorMessage"), AppResources.GetResources("PrintErrorTitle")); await l_dialog.ShowAsync(); }); } }; p_sourceRequested.SetSource(m_printDocumentSource); }); }
/// <summary> /// This is the event handler for PrintManager.PrintTaskRequested. /// </summary> /// <param name="sender">PrintManager</param> /// <param name="e">PrintTaskRequestedEventArgs </param> private void PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs e) { PrintTask printTask = null; string title = "xkcd"; if (_currentComic != null) { title += " " + _currentComic.Number + " - " + _currentComic; } printTask = e.Request.CreatePrintTask(title, sourceRequested => { // Print Task event handler is invoked when the print job is completed. printTask.Completed += async(s, args) => { // Notify the user when the print operation fails. if (args.Completion == PrintTaskCompletion.Failed) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { var dialog = new MessageDialog("Failed to print."); await dialog.ShowAsync(); }); } }; sourceRequested.SetSource(_printDocumentSource); }); }
async void OnPrintDocumentPrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args) { PrintTaskRequestedDeferral deferral = args.Request.GetDeferral(); // Obtain PrintTask PrintTask printTask = args.Request.CreatePrintTask("Finger Paint", OnPrintTaskSourceRequested); // Probably set orientation to landscape PrintTaskOptionDetails optionDetails = PrintTaskOptionDetails.GetFromPrintTaskOptions(printTask.Options); PrintOrientationOptionDetails orientation = optionDetails.Options[StandardPrintTaskOptions.Orientation] as PrintOrientationOptionDetails; bool bitmapIsLandscape = false; await border.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { BitmapSource bitmapSource = getBitmap(); bitmapIsLandscape = bitmapSource.PixelWidth > bitmapSource.PixelHeight; }); orientation.TrySetValue(bitmapIsLandscape ? PrintOrientation.Landscape : PrintOrientation.Portrait); deferral.Complete(); }
/// <summary> /// This is the event handler for PrintManager.PrintTaskRequested. /// </summary> /// <param name="sender">PrintManager</param> /// <param name="e">PrintTaskRequestedEventArgs </param> protected virtual void PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs e) // Required 1.called { PrintTask printTask = null; printTask = e.Request.CreatePrintTask("Print Form", sourceRequestedArgs => { IList <string> displayedOptions = printTask.Options.DisplayedOptions; // Choose the printer options to be shown. // The order in which the options are appended determines the order in which they appear in the UI displayedOptions.Clear(); displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Copies); displayedOptions.Add(StandardPrintTaskOptions.ColorMode); // Preset the default value of the printer option printTask.Options.MediaSize = PrintMediaSize.NorthAmerica9x11; printTask.Options.ColorMode = PrintColorMode.Monochrome; // Print Task event handler is invoked when the print job is completed. printTask.Completed += async(s, args) => { // Notify the user when the print operation fails. if (args.Completion == PrintTaskCompletion.Failed) { await _scenarioPage.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { _logHelper.Log(LogLevel.Error, "Failed to print."); await Utilities.ShowSingleButtonContentDialogAsync("Failed to print."); }); } }; sourceRequestedArgs.SetSource(_printDocumentSource); }); }
private void Printmgr_PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args) { var deff = args.Request.GetDeferral(); Task = args.Request.CreatePrintTask("Invoice", OnPrintTaskSourceRequested); deff.Complete(); }
/// <summary> /// This is the event handler for PrintManager.PrintTaskRequested. /// </summary> /// <param name="sender">PrintManager</param> /// <param name="e">PrintTaskRequestedEventArgs </param> private void PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs e) { PrintTask printTask = null; printTask = e.Request.CreatePrintTask("Printing C1RichTextBox", sourceRequested => { // Print Task event handler is invoked when the print job is completed. printTask.Completed += async(s, args) => { // Notify the user when the print operation fails. if (args.Completion == PrintTaskCompletion.Failed) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { MessageDialog dialog = new MessageDialog(Strings.PrintException); dialog.ShowAsync(); }); } }; // set print options like paper size and orientation Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { var layout = rtb.ViewManager.PresenterInfo as C1PageLayout; if (layout != null && layout.Width > layout.Height) { printTask.Options.Orientation = PrintOrientation.Landscape; } }); sourceRequested.SetSource(printDocumentSource); }); }
void OnPrintManagerPrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args) { args.Request.CreatePrintTask("Dependency Property Class Hierarchy", (requestArgs) => { requestArgs.SetSource(printDocumentSource); }); }
/// <summary> /// This is the event handler for PrintManager.PrintTaskRequested. /// In order to ensure a good user experience, the system requires that the app handle the PrintTaskRequested event within the time specified by PrintTaskRequestedEventArgs.Request.Deadline. /// Therefore, we use this handler to only create the print task. /// The print settings customization can be done when the print document source is requested. /// </summary> /// <param name="sender">PrintManager</param> /// <param name="e">PrintTaskRequestedEventArgs</param> protected override void PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs e) { PrintTask printTask = null; printTask = e.Request.CreatePrintTask("C# Printing SDK Sample", sourceRequestedArgs => { PrintTaskOptionDetails printDetailedOptions = PrintTaskOptionDetails.GetFromPrintTaskOptions(printTask.Options); IList <string> displayedOptions = printDetailedOptions.DisplayedOptions; // Choose the printer options to be shown. // The order in which the options are appended determines the order in which they appear in the UI displayedOptions.Clear(); displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Copies); displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Orientation); displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.ColorMode); // Create a new list option PrintCustomItemListOptionDetails pageFormat = printDetailedOptions.CreateItemListOption("PageRange", "Page Range"); pageFormat.AddItem("PrintAll", "Print all"); pageFormat.AddItem("PrintSelection", "Print Selection"); pageFormat.AddItem("PrintRange", "Print Range"); // Add the custom option to the option list displayedOptions.Add("PageRange"); // Create new edit option PrintCustomTextOptionDetails pageRangeEdit = printDetailedOptions.CreateTextOption("PageRangeEdit", "Range"); // Register the handler for the option change event printDetailedOptions.OptionChanged += printDetailedOptions_OptionChanged; // Register the handler for the PrintTask.Completed event. // Print Task event handler is invoked when the print job is completed. printTask.Completed += async(s, args) => { pageRangeEditVisible = false; selectionMode = false; pageList.Clear(); // Notify the user when the print operation fails. if (args.Completion == PrintTaskCompletion.Failed) { await scenarioPage.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { LogHelper.Log(LogLevel.Error, "Failed to print."); }); } await scenarioPage.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { // Restore first page to its default layout. // Undo any changes made by a text selection. ShowContent(null); }); }; sourceRequestedArgs.SetSource(printDocumentSource); }); }
protected virtual void PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs e) { Task = e.Request.CreatePrintTask(PrintTitle, async sourceRequested => { PrintTaskOptionDetails printDetailedOptions = PrintTaskOptionDetails.GetFromPrintTaskOptions(Task.Options); printDetailedOptions.DisplayedOptions.Clear(); printDetailedOptions.DisplayedOptions.Add(StandardPrintTaskOptions.Copies); Task.Options.Orientation = PrintOrientation.Portrait; Task.Completed += async(s, args) => { if (args.Completion == PrintTaskCompletion.Failed) { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Debug.WriteLine("Failed to print."); }); } }; await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { sourceRequested.SetSource(PrintDoc?.DocumentSource); }); }); }
/// <summary> /// This is the event handler for PrintManager.PrintTaskRequested. /// </summary> /// <param name="sender">PrintManager</param> /// <param name="e">PrintTaskRequestedEventArgs </param> protected virtual void PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs e) { PrintTask printTask = null; printTask = e.Request.CreatePrintTask(JobName, async sourceRequestedArgs => { var deferral = sourceRequestedArgs.GetDeferral(); PrintTaskOptionDetails printDetailedOptions = PrintTaskOptionDetails.GetFromPrintTaskOptions(printTask.Options); IList <string> displayedOptions = printTask.Options.DisplayedOptions; displayedOptions.Clear(); displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Copies); displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Orientation); displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.PrintQuality); displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.MediaSize); displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Collation); displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Duplex); // Preset the default value of the printer option printTask.Options.MediaSize = PrintMediaSize.NorthAmericaLetter; // Create a new list option PrintCustomItemListOptionDetails margins = printDetailedOptions.CreateItemListOption("Margins", "Margins"); margins.AddItem("WideMargins", "Wide", "Each margin is 20% of the paper size", null); margins.AddItem("ModerateMargins", "Moderate", "Each margin is 10% of the paper size", null); margins.AddItem("NarrowMargins", "Narrow", "Each margin is 5% of the paper size", null); // The default is ModerateMargins ApplicationContentMarginTop = 0.1; ApplicationContentMarginLeft = 0.1; margins.TrySetValue("ModerateMargins"); // App tells the user some more information about what the feature means. margins.Description = "The space between the content of your document and the edge of the paper"; // Add the custom option to the option list displayedOptions.Add("Margins"); printDetailedOptions.OptionChanged += OnPrintDetailOptionChanged; // Print Task event handler is invoked when the print job is completed. printTask.Completed += async(s, args) => { // Notify the user when the print operation fails. if (args.Completion == PrintTaskCompletion.Failed) { await ApplicationPage.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { //MainPage.Current.NotifyUser("Failed to print.", NotifyType.ErrorMessage); Console.WriteLine("Failed to print."); }); } UnregisterForPrinting(); }; sourceRequestedArgs.SetSource(printDocumentSource); deferral.Complete(); }); }
private void Printmgr_PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args) { var deff = args.Request.GetDeferral(); Task = args.Request.CreatePrintTask($"Card Stock { DateTime.Now}", OnPrintTaskSourceRequested); deff.Complete(); }
private void MainPage_PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args) { // プリントのタスクを登録する args.Request.CreatePrintTask("Sample", req => { req.SetSource(this.printDocumentSource); }); }
private void PrintManager_PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args) { Debug.WriteLine("PrintManager_PrintTaskRequested"); PrintTask printTask = null; printTask = args.Request.CreatePrintTask("新闻打印", PrintTaskSourceRequested); printTask.Completed += PrintTask_Completed; }
/// <summary> /// This is the event handler for PrintManager.PrintTaskRequested. /// </summary> /// <param name="sender">PrintManager</param> /// <param name="e">PrintTaskRequestedEventArgs </param> protected virtual void PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs e) { PrintTask printTask = null; printTask = e.Request.CreatePrintTask("C# Printing SDK Sample", sourceRequested => { sourceRequested.SetSource(printDocumentSource); }); }
private void manager_PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args) { PrintTask task = null; task = args.Request.CreatePrintTask("Print Job", sourceRequested => { sourceRequested.SetSource(this.source); }); }
private void PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs e) { PrintTask printTask = e.Request.CreatePrintTask("BlueYonder", sourceRequested => sourceRequested.SetSource(_printDocumentSource)); printTask.Options.DisplayedOptions.Clear(); printTask.Options.DisplayedOptions.Add(StandardPrintTaskOptions.Copies); printTask.Options.DisplayedOptions.Add(StandardPrintTaskOptions.Orientation); printTask.Options.DisplayedOptions.Add(StandardPrintTaskOptions.ColorMode); }
private void PrintManager_PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args) { var heading = LocalizationManager.GetString("Print_Heading"); args.Request.CreatePrintTask(heading, a => { a.SetSource(printDocument); }); }
private void PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs e) { PrintTask printTask = null; printTask = e.Request.CreatePrintTask("Print Test Task", sourceRequested => { sourceRequested.SetSource(this.PrintDocumentSource); }); }
void manager_PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args) { PrintTask task = null; task = args.Request.CreatePrintTask("Day #20 - Simple Print Job", sourceRequested => { sourceRequested.SetSource(source); }); }
private void PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args) { // Create the PrintTask. // Defines the title and delegate for PrintTaskSourceRequested var printTask = args.Request.CreatePrintTask("Print", PrintTaskSourceRequrested); // Handle PrintTask.Completed to catch failed print jobs printTask.Completed += PrintTaskCompleted; }
private void Printmgr_PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args) { var deferral = args.Request.GetDeferral(); task = args.Request.CreatePrintTask("Print", OnPrintTaskSourceRequrested); //task.Completed += PrintTask_Completed; PrintTaskOptionDetails printDetailedOptions = PrintTaskOptionDetails.GetFromPrintTaskOptions(task.Options); printDetailedOptions.OptionChanged += PrintDetailedOptions_OptionChanged; deferral.Complete(); }
private void Printmgr_PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args) { var deferral = args.Request.GetDeferral(); task = args.Request.CreatePrintTask("Print", OnPrintTaskSourceRequrested); task.Options.MediaSize = PrintMediaSize.IsoA4; task.Options.Orientation = PrintOrientation.Landscape; task.Options.MediaType = PrintMediaType.MultiPartForm; task.Completed += PrintTask_Completed; deferral.Complete(); }