示例#1
0
        /// <summary>
        /// Invoked when the app is launched via an activation contract. In this case we care about ActivationKind.PrintTaskSettings
        /// </summary>
        /// <param name="args">Information about why this was invoked</param>
        protected override void OnActivated(IActivatedEventArgs args)
        {
            if (args.Kind == ActivationKind.PrintTaskSettings)
            {
                Frame rootFrame = new Frame();
                if (null == Window.Current.Content)
                {
                    rootFrame.Navigate(typeof(MainPage));
                    Window.Current.Content = rootFrame;
                }
                Window.Current.Activate();

                MainPage mainPage = (MainPage)rootFrame.Content;

                // Get the PrinterExtensionContext from the activation arguments
                IntPtr ptr = GetPrinterExtensionContextAsIntPtr(args);
                // Create the Print Helper
                PrintHelperClass printHelper = new PrintHelperClass(InitializationType.PrinterExtensionContextType, (ulong)ptr);
                // Can use the Windows Runtime Component above to GetPrinterName() and do BiDi queries etc.
            }

            if (args.Kind == ActivationKind.PrintWorkflowForegroundTask)
            {
                Frame rootFrame = new Frame();
                if (null == Window.Current.Content)
                {
                    rootFrame.Navigate(typeof(WorkflowPage));
                    Window.Current.Content = rootFrame;
                }

                // Ensure the current window is active
                ActivateWindowAndSetDesiredSize();

                // Get the main page
                WorkflowPage workflowPage = (WorkflowPage)rootFrame.Content;

                // Workflow stuff here

                // Make sure the page knows it's handling a foreground task activation
                workflowPage.LaunchType = WorkflowPage.WorkflowPageLaunchType.ForegroundTask;

                // Get the activation arguments
                PrintWorkflowUIActivatedEventArgs printTaskUIEventArgs = args as PrintWorkflowUIActivatedEventArgs;

                // Get the session manager
                PrintWorkflowForegroundSession taskSessionManager = printTaskUIEventArgs.PrintWorkflowSession;

                // Add the callback handlers - these are on the main page
                taskSessionManager.SetupRequested   += workflowPage.OnSetupRequested;
                taskSessionManager.XpsDataAvailable += workflowPage.OnXpsDataAvailable;

                taskSessionManager.Start();
            }
        }
示例#2
0
 protected virtual Task HandleActivation(PrintWorkflowUIActivatedEventArgs args)
 {
     return(Task.CompletedTask);
 }