void OnGUI()
    {
        if( GUILayout.Button( "Print Task" ) )
        {
            var t = new PrintTask();
            t.completionHandler = ( task ) => { Debug.Log( "DONE with first" ); };

            var t2 = new PrintTask();
            t2.completionHandler = ( task ) => { Debug.Log( "DONE with second" ); };

            t.nextTask = t2;

            P31TaskManager.instance.addTask( t );
        }

        if( GUILayout.Button( "Action Task" ) )
        {
            _counter = 0;
            P31ActionTask.createAndStartTask( demoActionTask );
        }

        if( GUILayout.Button( "Background Task" ) )
        {
            var t = new PrintInBackgroundTask();
            t.completionHandler = ( task ) =>
            {
                Debug.Log( "[PrintInBackground] thread is bg? " + System.Threading.Thread.CurrentThread.IsBackground );
            };
            P31TaskManager.instance.addBackgroundTask( t );
        }
    }
        /// <summary>Construct Server Printing sample control</summary>
        public ServerPrinting()
        {
            InitializeComponent();

            _printTask = new PrintTask(
                new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"));

            MyMapView.Loaded += MyMapView_Loaded;
        }
        /// <summary>Construct Server Printing sample control</summary>
        public ServerPrinting()
        {
            InitializeComponent();

            _printTask = new PrintTask(
                new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"));

            MyMapView.Loaded += MyMapView_Loaded;
        }
Exemplo n.º 4
0
        void manager_PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args)
        {
            PrintTask task = null;

            task = args.Request.CreatePrintTask("Day #20 - Simple Print Job", sourceRequested =>
            {
                sourceRequested.SetSource(source);
            });
        }
Exemplo n.º 5
0
            public static object GetTargets()
            {
                var one = new PrintTask(Output) { Description = "one" };
                var two = new PrintTask(Output) { Description = "two" };

                return new {
                    One = one,
                    Two = two,
                };
            }
 private async void PrintTaskCompleted(PrintTask sender, PrintTaskCompletedEventArgs args)
 {
     if (args.Completion == PrintTaskCompletion.Failed)
     {
         await Window.Current.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
         {
             ShowErrorMessage("Printing error", "Printing failed");
         });
     }
 }
Exemplo n.º 7
0
 public static bool RecoveryAvailable(PrinterConfig printer, PrintTask lastPrint)
 {
     return(lastPrint != null &&
            !lastPrint.PrintComplete &&              // Top Print History Item is not complete
            !string.IsNullOrEmpty(lastPrint.PrintingGCodeFileName) &&              // PrintingGCodeFileName is set
            File.Exists(lastPrint.PrintingGCodeFileName) &&              // PrintingGCodeFileName is still on disk
            lastPrint.PercentDone > 0 &&              // we are actually part way into the print
            printer.Settings.GetValue <bool>(SettingsKey.recover_is_enabled) &&
            !printer.Settings.GetValue <bool>(SettingsKey.has_hardware_leveling));
 }
        public ExportWebMap()
        {
            InitializeComponent();

            printTask = new PrintTask("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task");
            printTask.DisableClientCaching = true;
            printTask.ExecuteCompleted += printTask_PrintCompleted;
            printTask.GetServiceInfoCompleted += printTask_GetServiceInfoCompleted;
            printTask.GetServiceInfoAsync();
        }
        public ExportWebMap()
        {
            InitializeComponent();

            printTask = new PrintTask("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task");
            printTask.DisableClientCaching     = true;
            printTask.ExecuteCompleted        += printTask_PrintCompleted;
            printTask.GetServiceInfoCompleted += printTask_GetServiceInfoCompleted;
            printTask.GetServiceInfoAsync();
        }
Exemplo n.º 10
0
        public MainWindow()
        {
            InitializeComponent();

            // Client's service
            _printTask = new PrintTask(
                new Uri("https://supt07440.esri.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"));
            MyMapView.Loaded += MyMapView_Loaded;

            IdentityManager.Current.ChallengeHandler = new ChallengeHandler(Challenge);
        }
Exemplo n.º 11
0
        private async void OnCompleted(PrintTask printTask, PrintTaskCompletedEventArgs e)
        {
            printTask.Completed -= OnCompleted;
            _images              = null;

            await DispatcherHelper.RunAsync(() =>
            {
                _manager.PrintTaskRequested -= OnPrintTaskRequested;
                _document?.Dispose();
            });
        }
Exemplo n.º 12
0
        public MainWindow()
        {
            InitializeComponent();

            // Client's service
            _printTask = new PrintTask(
                new Uri("https://supt07440.esri.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"));
            MyMapView.Loaded += MyMapView_Loaded;

            IdentityManager.Current.ChallengeHandler = new ChallengeHandler(Challenge);
        }
Exemplo n.º 13
0
        private void HandlePrintTaskCompleted(PrintTask task, PrintTaskCompletedEventArgs args)
        {
            Debug.WriteLine("PrintTask Completed - {0}, Status = {1}.", task.Properties.Title, args.Completion);
            //args.Completion == PrintTaskCompletion.Submitted PrintTaskCompletion.Failed PrintTaskCompletion.Canceled  PrintTaskCompletion.Abandoned

            // Unsubscribe from the lifecycle events to prevent the task from being leaked
            task.Previewing  -= HandlePrintTaskPreviewing;
            task.Submitting  -= HandlePrintTaskSubmitting;
            task.Progressing -= HandlePrintTaskProgressing;
            task.Completed   -= HandlePrintTaskCompleted;
        }
Exemplo n.º 14
0
        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();
        }
Exemplo n.º 15
0
        void OnPrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args)
        {
            var deferral = args.Request.GetDeferral();

            PrintTask printTask = args.Request.CreatePrintTask(
                "My Print Job",
                OnPrintTaskSourceRequestedHandler);

            printTask.Completed += OnPrintTaskCompleted;

            deferral.Complete();
        }
Exemplo n.º 16
0
        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();
        }
        protected virtual void PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs e)
        {
            PrintTask printTask = e.Request.CreatePrintTask("BlueYonder", sourceRequested => sourceRequested.SetSource(_printDocumentSource));
            PrintTaskOptionDetails printDetailedOptions = PrintTaskOptionDetails.GetFromPrintTaskOptions(printTask.Options);

            printDetailedOptions.DisplayedOptions.Clear();
            printDetailedOptions.DisplayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Copies);
            printDetailedOptions.DisplayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Orientation);
            printDetailedOptions.DisplayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.ColorMode);

            printDetailedOptions.OptionChanged += printDetailedOptions_OptionChanged;
        }
        private void PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args)
        {
            PrintTask printTask = null;

            printTask = args.Request.CreatePrintTask("Print", x =>
            {
                printTask.Options.MediaSize    = PrintMediaSize.IsoA4;
                printTask.Options.PrintQuality = PrintQuality.High;
                printTask.Options.ColorMode    = PrintColorMode.Monochrome;
                x.SetSource(printDocSource);
            });
        }
Exemplo n.º 19
0
		private static void SetStarState(ThemeConfig theme, List<GuiWidget> siblings, PrintTask printTask)
		{
			var checkedButton = -1;
			if (printTask.QualityWasSet)
			{
				checkedButton = printTask.PrintQuality;
			}

			for (int j = 0; j < siblings.Count; j++)
			{
				var open = siblings[j].Descendants().Where(d => d.Name == "open").FirstOrDefault();
				var closed = siblings[j].Descendants().Where(d => d.Name == "closed").FirstOrDefault();

				if (j == 0)
				{
					if (checkedButton == 0)
					{
						siblings[j].BackgroundColor = theme.AccentMimimalOverlay;
					}
					else
					{
						siblings[j].BackgroundColor = Color.Transparent;
					}
				}
				else if (j <= checkedButton)
				{
					siblings[j].BackgroundColor = theme.AccentMimimalOverlay;
				}
				else
				{
					siblings[j].BackgroundColor = Color.Transparent;
				}

				if (j <= checkedButton)
				{
					if (open != null)
					{
						open.Visible = false;
						closed.Visible = true;
					}
				}
				else
				{
					if (open != null)
					{
						open.Visible = true;
						closed.Visible = false;
					}
				}
			}
		}
Exemplo n.º 20
0
        /// <summary>
        /// 处理打印请求
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnPrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs e)
        {
            sender.PrintTaskRequested -= OnPrintTaskRequested;
            PrintTask printTask = null;

            printTask = e.Request.CreatePrintTask(_jobName, (src) =>
            {
                // 初始化打印预览时的方向和纸张大小
                printTask.Options.Orientation = (_info.Orientation == PrintPageOrientation.Portrait) ? PrintOrientation.Portrait : PrintOrientation.Landscape;
                PrintMediaSize size           = _info.PaperSize.MediaSize;
                if (size != PrintMediaSize.PrinterCustom)
                {
                    printTask.Options.MediaSize = size;
                }

                // 报表中包含图片,先将Excel导出,再导入。否则,图片打印不出来
                if (_hasPictures)
                {
                    _excel.ShowDecoration = false;
                    _cachedStream         = new MemoryStream();
                    _excel.SaveXmlBackground(_cachedStream);
                    _cachedStream.Seek(0L, SeekOrigin.Begin);
                    _excel.OpenXmlOnBackground(_cachedStream);
                }

                Memento memento = new Memento();
                Init(memento);
                StretchContent();
                src.SetSource(_printDoc.DocumentSource);

                // 打印任务完成时释放资源
                printTask.Completed += (s, args) =>
                {
                    if (_hasPictures)
                    {
                        // 恢复分页线
                        if (_showDeco)
                        {
                            _excel.ShowDecoration = true;
                            _cachedStream.Seek(0L, SeekOrigin.Begin);
                            _excel.OpenXmlOnBackground(_cachedStream);
                        }

                        _cachedStream.Close();
                        _cachedStream = null;
                    }
                    Resume(memento);
                };
            });
        }
 private async void PrintTaskCompleted(PrintTask sender, PrintTaskCompletedEventArgs args)
 {
     // Notify the user when the print operation fails.
     if (args.Completion == PrintTaskCompletion.Failed)
     {
         ContentDialog noPrintingDialog = new ContentDialog()
         {
             Title             = "ОШИБКА ПЕЧАТИ",
             Content           = "\nПЕЧАТЬ НЕ УДАЛАСЬ.",
             PrimaryButtonText = "OK"
         };
         await noPrintingDialog.ShowAsync();
     }
 }
Exemplo n.º 22
0
        public static void CheckIfNeedToRecoverPrint(PrinterConfig printer)
        {
            string printRecoveryWarningMessage = "WARNING: In order to perform print recovery, your printer must move down to reach its home position.\nIf your print is too large, part of your printer may collide with it when moving down.\nMake sure it is safe to perform this operation before proceeding.".Localize();

            PrintTask lastPrint = PrintHistoryData.Instance.GetHistoryForPrinter(printer.Settings.ID.GetHashCode()).FirstOrDefault();

            if (lastPrint != null)
            {
                if (RecoveryAvailable(printer))
                {
                    bool safeHomingDirection = printer.Settings.GetValue <bool>(SettingsKey.z_homes_to_max);

                    StyledMessageBox.ShowMessageBox(
                        (messageBoxResponse) =>
                    {
                        if (messageBoxResponse)
                        {
                            UiThread.RunOnIdle(async() =>
                            {
                                if (printer.Connection.CommunicationState == CommunicationStates.Connected)
                                {
                                    printer.Connection.CommunicationState = CommunicationStates.PreparingToPrint;

                                    // TODO: Reimplement
                                    //await printer.Connection.StartPrint(lastPrint.PrintingGCodeFileName, lastPrint);

                                    // This needs to be reworked to support the PrintServer owning the PrintTask/Job

                                    System.Diagnostics.Debugger.Break();
                                    //printer.Connection.StartPrint(lastPrint.PrintingGCodeFileName);

                                    ApplicationController.Instance.MonitorPrintTask(printer);
                                }
                            });
                        }
                        else                                 // the recovery has been canceled
                        {
                            lastPrint.PrintingGCodeFileName = null;
                            lastPrint.Commit();
                        }
                    },
                        "It appears your last print failed to complete.\n\nWould your like to attempt to recover from the last know position?".Localize()
                        + (safeHomingDirection ? "" : "\n\n" + printRecoveryWarningMessage),
                        "Recover Last Print".Localize(),
                        StyledMessageBox.MessageType.YES_NO,
                        "Recover Print".Localize(),
                        "Cancel".Localize());
                }
            }
        }
Exemplo n.º 23
0
        public static void CheckIfNeedToRecoverPrint(PrinterConfig printer)
        {
            string recoverPrint   = "Recover Print".Localize();
            string cancelRecovery = "Cancel".Localize();
            string printRecoveryWarningMessage = "WARNING: In order to perform print recovery, your printer must move down to reach its home position.\nIf your print is too large, part of your printer may collide with it when moving down.\nMake sure it is safe to perform this operation before proceeding.".Localize();
            string printRecoveryMessage        = "It appears your last print failed to complete.\n\nWould your like to attempt to recover from the last know position?".Localize();
            string recoverPrintTitle           = "Recover Last Print".Localize();

            PrintTask lastPrint = PrintHistoryData.Instance.GetHistoryForPrinter(printer.Settings.ID.GetHashCode()).FirstOrDefault();

            if (lastPrint != null)
            {
                if (!lastPrint.PrintComplete &&              // Top Print History Item is not complete
                    !string.IsNullOrEmpty(lastPrint.PrintingGCodeFileName) &&                     // PrintingGCodeFileName is set
                    File.Exists(lastPrint.PrintingGCodeFileName) &&                     // PrintingGCodeFileName is still on disk
                    lastPrint.PercentDone > 0 &&                     // we are actually part way into the print
                    printer.Settings.GetValue <bool>(SettingsKey.recover_is_enabled) &&
                    !printer.Settings.GetValue <bool>(SettingsKey.has_hardware_leveling))
                {
                    bool safeHomingDirection = printer.Settings.GetValue <bool>(SettingsKey.z_homes_to_max);

                    StyledMessageBox.ShowMessageBox(
                        (messageBoxResponse) =>
                    {
                        if (messageBoxResponse)
                        {
                            UiThread.RunOnIdle(async() =>
                            {
                                if (printer.Connection.CommunicationState == CommunicationStates.Connected)
                                {
                                    printer.Connection.CommunicationState = CommunicationStates.PreparingToPrint;
                                    await printer.Connection.StartPrint(lastPrint.PrintingGCodeFileName, lastPrint);
                                    ApplicationController.Instance.MonitorPrintTask(printer);
                                }
                            });
                        }
                        else                                 // the recovery has been canceled
                        {
                            lastPrint.PrintingGCodeFileName = null;
                            lastPrint.Commit();
                        }
                    },
                        (safeHomingDirection) ? printRecoveryMessage : printRecoveryMessage + "\n\n" + printRecoveryWarningMessage,
                        recoverPrintTitle,
                        StyledMessageBox.MessageType.YES_NO,
                        recoverPrint,
                        cancelRecovery);
                }
            }
        }
Exemplo n.º 24
0
        /// <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(_printTaskName, sourceRequested =>
            {
                ApplyPrintSettings(printTask);

                // 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.
                    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        foreach (var element in _stateBags.Keys)
                        {
                            _stateBags[element].Restore(element);
                        }
                        _stateBags.Clear();

                        DetachCanvas();
                        _canvasContainer.RequestedTheme = ElementTheme.Default;

                        switch (args.Completion)
                        {
                        case PrintTaskCompletion.Failed:
                            {
                                OnPrintFailed?.Invoke();
                                break;
                            }

                        case PrintTaskCompletion.Canceled:
                            {
                                OnPrintCanceled?.Invoke();
                                break;
                            }

                        case PrintTaskCompletion.Submitted:
                            {
                                OnPrintSucceeded?.Invoke();
                                break;
                            }
                        }
                    });
                };

                sourceRequested.SetSource(_printDocumentSource);
            });
        }
Exemplo n.º 25
0
 public static void CheckIfNeedToResumePrint(object sender, EventArgs e)
 {
     foreach (PrintTask lastPrint in PrintHistoryData.Instance.GetHistoryItems(1))
     {
         if (!lastPrint.PrintComplete &&              // Top Print History Item is not complete
             !string.IsNullOrEmpty(lastPrint.PrintingGCodeFileName) &&             // PrintingGCodeFileName is set
             File.Exists(lastPrint.PrintingGCodeFileName) &&             // PrintingGCodeFileName is still on disk
             lastPrint.PercentDone > 0 &&             // we are actually part way into the print
             ActiveSliceSettings.Instance.ActiveValue("has_hardware_leveling") == "0")
         {
             lastPrintTask = lastPrint;
             StyledMessageBox.ShowMessageBox(ResumeFailedPrintProcessDialogResponse, resumeFailedPrintMessage, resumeFailedPrintTitle, StyledMessageBox.MessageType.YES_NO, resumePrint, cancelResume);
         }
     }
 }
        void printManager_PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args)
        {
            PrintTask printTask = null;

            printTask = args.Request.CreatePrintTask("BarCode Demo Print Task", sourceRequested => {
                printTask.Completed += async(s, e) => {
                    if (e.Completion == PrintTaskCompletion.Failed)
                    {
                        await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => {
                            await new MessageDialog("Printing error.").ShowAsync();
                        });
                    }
                };
                sourceRequested.SetSource(SelectedEmploye.PrintDocumentSource);
            });
        }
        void OnPrintManagerPrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args)
        {
            // Create PrintTask
            PrintTask printTask = args.Request.CreatePrintTask("Monthly Planner",
                                                               OnPrintTaskSourceRequested);

            // Set orientation to landscape
            PrintTaskOptionDetails optionDetails =
                PrintTaskOptionDetails.GetFromPrintTaskOptions(printTask.Options);

            PrintOrientationOptionDetails orientation =
                optionDetails.Options[StandardPrintTaskOptions.Orientation] as
                PrintOrientationOptionDetails;

            orientation.TrySetValue(PrintOrientation.Landscape);
        }
Exemplo n.º 28
0
 private async void PrintTaskCompleted(PrintTask sender, PrintTaskCompletedEventArgs args)
 {
     // Notify the user when the print operation fails.
     if (args.Completion == PrintTaskCompletion.Failed)
     {
         await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => {
             ContentDialog noPrintingDialog = new ContentDialog()
             {
                 Title             = "Printing error",
                 Content           = "\nSorry, failed to print.",
                 PrimaryButtonText = "OK"
             };
             await noPrintingDialog.ShowAsync();
         });
     }
 }
Exemplo n.º 29
0
        protected override void OnStart(string[] args)
        {
            this.RequestAdditionalTime(30000);

            InitializeService();

            CancellationToken token = _cancellationTokenSource.Token;

            Task.Run(() => FirstTask.Do(token, 5));
            Task.Run(() => SecondTask.Do(token, 5));
            Task.Run(() => ThirdTask.Do(token, 10));
            Task.Run(() => BoothAvailabilityTask.Do(token, 10));
            Task.Run(() => PrintTask.Do(token, 10));
            Task.Run(() => ArchiveUploaderTask.Do(token, 10));
            Task.Run(() => InstagramSearchTask.Do(token, 60));
        }
Exemplo n.º 30
0
        protected override void OnStart(string[] args)
        {
            InitializeService();

            CancellationToken token = _cancellationTokenSource.Token;

            Task.Run(() => FirstTask.Do(token, 5));
            Task.Run(() => SecondTask.Do(token, 5));
            Task.Run(() => ThirdTask.Do(token, 10));
            Task.Run(() => BoothAvailabilityTask.Do(token, 10));
            Task.Run(() => PrintTask.Do(token, 10));
            Task.Run(() => ArchiveUploaderTask.Do(token, 10));

            while (!token.IsCancellationRequested)
            {
            }
        }
Exemplo n.º 31
0
        /// <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("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;

                // 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, () =>
                        {
                            rootPage.NotifyUser("Failed to print.", NotifyType.ErrorMessage);
                        });
                    }
                };

                sourceRequestedArgs.SetSource(printDocumentSource);
            });
        }
Exemplo n.º 32
0
        public PrintDataMessage GenSingleTrayLabel(string trayId, string dateFormat, string[] keepers)
        {
            PrintDataMessage    pdm = new PrintDataMessage();
            ValidateMsg <Trays> msg = TraysHelper.TrayCanPrint(trayId);

            if (msg.Valid)
            {
                List <TrayPackView> tpv = TrayPackViewHelper.GetTPVByTrayIdsGropSumPartNr(new List <string>()
                {
                    trayId
                });
                string[]         dateFormats = dateFormat.Split(',');
                List <PrintTask> tasks       = new List <PrintTask>();
                foreach (string keeper in keepers)
                {
                    RecordSet rs   = new RecordSet();
                    PrintTask task = new PrintTask()
                    {
                        DataSet = rs
                    };
                    foreach (TrayPackView t in tpv)
                    {
                        RecordData label = new RecordData();
                        label.Add("TrayId", t.trayId);
                        label.Add("Warehouse", t.warehouse);
                        label.Add("Position", t.position);
                        label.Add("customerPNr", t.customerPartNr);
                        label.Add("PartNr", t.partNr);
                        label.Add("Capa", t.capa.ToString());
                        label.Add("Keeper", keeper);
                        label.Add("CreateTime", t.createTime.ToString(dateFormats[0]));
                        label.Add("StoreCreateTime", t.createTime.ToString(dateFormats[1]));
                        rs.Add(label);
                    }
                    tasks.Add(task);
                }
                pdm.PrintTask      = tasks;
                pdm.ReturnedResult = true;
            }
            else
            {
                pdm.ReturnedResult = false;
                pdm.ReturnedMessage.Add(msg.ToString());
            }
            return(pdm);
        }
Exemplo n.º 33
0
        private void PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs e)
        {
            PrintTask printTask = null;

            printTask = e.Request.CreatePrintTask("Notepad", sourceRequested =>
            {
                printTask.Completed += async(s, args) =>
                {
                    if (args.Completion == PrintTaskCompletion.Failed)
                    {
                        Debug.WriteLine("Printing failed");
                        // Notify back to the user
                    }
                };

                sourceRequested.SetSource(printDocumentSource);
            });
        }
        protected override void OnDownloadConfigXMLCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            string xmlConfig = e.Result;

            widgetConfig = (PrintWidgetConfig)PrintWidgetConfig.Deserialize(xmlConfig, typeof(PrintWidgetConfig));

            if (widgetConfig.ExportMapTaskUrl != "")
            {
                printTask = new PrintTask(widgetConfig.ExportMapTaskUrl);
                printTask.GetServiceInfoCompleted += new EventHandler <ServiceInfoEventArgs>(PrintTask_GetServiceInfoCompleted);
                printTask.GetServiceInfoAsync();
            }
            else
            {
                this.HeaderPanel.Children[0].Visibility = System.Windows.Visibility.Collapsed;
                this.PanelExportMap.Visibility          = System.Windows.Visibility.Collapsed;
                this.ToggleWidgetContent(1);
            }
        }
Exemplo n.º 35
0
        /// <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.CustomPageRanges);
                displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.Orientation);
                displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.MediaSize);
                displayedOptions.Add(Windows.Graphics.Printing.StandardPrintTaskOptions.ColorMode);

                printTask.Options.PageRangeOptions.AllowCurrentPage      = true;
                printTask.Options.PageRangeOptions.AllowAllPages         = true;
                printTask.Options.PageRangeOptions.AllowCustomSetOfPages = true;

                // 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) =>
                {
                    // Notify the user when the print operation fails.
                    if (args.Completion == PrintTaskCompletion.Failed)
                    {
                        await scenarioPage.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                        {
                            MainPage.Current.NotifyUser("Failed to print.", NotifyType.ErrorMessage);
                        });
                    }
                };

                sourceRequestedArgs.SetSource(printDocumentSource);
            });
        }
		private async void MyMapView_SpatialReferenceChanged(object sender, EventArgs e)
		{
			try
			{
				_printTask = new PrintTask(new Uri(PrintTaskUrl));
				var info = await _printTask.GetTaskInfoAsync();

				comboLayout.ItemsSource = info.LayoutTemplates;
				if (info.LayoutTemplates != null && info.LayoutTemplates.Count > 0)
					comboLayout.SelectedIndex = 0;

				comboFormat.ItemsSource = info.Formats;
				if (info.Formats != null && info.Formats.Count > 0)
					comboFormat.SelectedIndex = 0;
			}
			catch (Exception ex)
			{
				var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
			}
		}
Exemplo n.º 37
0
            public static object GetTargets(IParameters parameters)
            {
                var machineName = parameters.Required<string>("machineName");
                var remoteOne = new PrintTask(Output) {Description = machineName};
                var two = new PrintTask(Output) {Description = parameters.Required<string>("two")};

                var remoteBounce = new RemoteBounce();

                RemoteBounceArguments remoteOneArgs = remoteBounce.ArgumentsForTargets(new { RemoteOne = remoteOne });

                Task<IEnumerable<string>> machines = new [] {"machine1", "machine2"};
                var one = machines.SelectTasks(machine => new RemoteExec {
                    BounceArguments = remoteOneArgs.WithParameter(machineName.WithValue(machine)),
                    Machine = machine,
                });

                return remoteBounce.WithRemoteTargets(new {
                    One = one,
                    Two = two,
                });
            }
Exemplo n.º 38
0
            public static object GetTargets(IParameters parameters)
            {
                var remoteOne = new PrintTask(Output) {Description = parameters.Required<string>("hack")};
                var two = new PrintTask(Output) {Description = parameters.Required<string>("two")};

                var remoteBounce = new RemoteBounce();

                RemoteBounceArguments remoteOneArgs = remoteBounce.ArgumentsForTargets(new { RemoteOne = remoteOne });

                var one = new RemoteExec
                          {
                              BounceArguments = remoteOneArgs,
                              Machine = parameters.Required<string>("machine"),
                          };

                return remoteBounce.WithRemoteTargets(new {
                    One = one,
                    Two = two,
                });
            }
Exemplo n.º 39
0
            public static object GetTargets(IParameters parameters)
            {
                var one = new PrintTask(Output) { Description = parameters.Required<string>("one") };
                var two = new PrintTask(Output) { Description = parameters.Required<string>("two") };

                return new {
                    One = one,
                    Two = two,
                };
            }
Exemplo n.º 40
0
        /// <summary>
        /// Executes a printing operation using a specific <see cref="PrintingQueue"/> and action.
        /// </summary>
        /// <param name="queue">The printing queue to use. Must not be null.</param>
        /// <param name="printAction">The printing action. Must not be null.</param>
        /// <param name="state">An optional, initial user state to hand over to the delegate.</param>
        public static void Print(PrintingQueue queue, PrintDelegate printAction, object state)
        {
            Assertions.AssertNotNull(queue, "queue");
            Assertions.AssertNotNull(printAction, "printAction");

            if (!queue.IsValid)
            {
                Logger.Instance.LogFormat(LogType.Warning, typeof(GdiPrinter), Resources.GdiPrinterPrintingQueueIsNotValid, queue.Name);
                return;
            }

            PrintDocument doc = new PrintDocument();
            if (!queue.IsDefaultPrinter)
            {
                doc.PrinterSettings.PrinterName = queue.GetPrinterName();
            }

            int desiredCopyCount = queue.CopyCount;
            int maxSupportedCopyCount = doc.PrinterSettings.MaximumCopies;
            int requiredPrintIterations = 1;

            if (desiredCopyCount <= maxSupportedCopyCount && !queue.UseAlternativeCopyingMethod)
            {
                doc.PrinterSettings.Copies = (short)desiredCopyCount;
            }
            else
            {
                //Check of the user has requested using this way of printing copies!
                if (!queue.UseAlternativeCopyingMethod)
                {
                    // It appears that some printers don't support the CopyCount-feature (notably Microsoft XPS Writer or perhaps PDF-Writers in general?).
                    // In this case we simply repeat printing until we have reached our copy count.
                    Logger.Instance.LogFormat(LogType.Warning, typeof(GdiPrinter), Resources.UsedPrinterDoesNotSupportThatMuchCopies, maxSupportedCopyCount, desiredCopyCount);
                }

                requiredPrintIterations = desiredCopyCount;
            }

            for (int i = 0; i < requiredPrintIterations; i++)
            {
                Logger.Instance.LogFormat(LogType.Trace, typeof(GdiPrinter), Resources.PrintIterationStart, i + 1, requiredPrintIterations);

                PrintTask task = new PrintTask();
                try
                {
                    task.Print(doc, printAction, state);
                }
                catch (Exception ex)
                {
                    Logger.Instance.LogFormat(LogType.Error, typeof(GdiPrinter), Resources.GdiPrinterPrintTaskException);
                    Logger.Instance.LogException(typeof(GdiPrinter), ex);
                }

                Logger.Instance.LogFormat(LogType.Trace, typeof(GdiPrinter), Resources.PrintIterationEnd);
            }
        }