public MainPage() { this.InitializeComponent(); // Set DataContext in order to be able to databind to properties of this class DataContext = this; // Fill lists with values this.Patients = PatientInitialiser.Create(); this.Medicaments = MedicamentInitialiser.Create(); // Initialise the list of ordination for a certain date and patient. this.OrdinationsOfPatientAndDate = new ObservableCollection<Ordination>(); // Create dropdown with Patient / Medicametion selection this.InitialiseFieldList(); // Declare that this view can be used as a sharing source DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView(); dataTransferManager.DataRequested += OnDataRequested; // Devices / Printing events this.printDocument = new PrintDocument(); this.printDocument.Paginate += OnPaginate; this.printDocument.GetPreviewPage += OnGetPreviewPage; this.printDocument.AddPages += OnAddPages; PrintManager printManager = PrintManager.GetForCurrentView(); printManager.PrintTaskRequested += OnPrintTaskRequested; }
public PrintHelper() { _PrintDocument = new PrintDocument(); _PrintDocumentSource = _PrintDocument.DocumentSource; _PrintDocument.AddPages += _PrintDocument_AddPages; _PrintDocument.Paginate += _PrintDocument_Paginate; _PrintDocument.GetPreviewPage += _PrintDocument_GetPreviewPage; _Pages = new List<UIElement>(); }
public virtual void RegisterForPrinting() { PrintDoc = new PrintDocument(); PrintDoc.Paginate += CreatePrintPreviewPages; PrintDoc.GetPreviewPage += GetPrintPreviewPage; PrintDoc.AddPages += AddPrintPages; Printmgr = PrintManager.GetForCurrentView(); Printmgr.PrintTaskRequested += PrintTaskRequested; }
protected override void OnNavigatedTo(MtNavigationEventArgs args) { PrintManager.GetForCurrentView().PrintTaskRequested += OnPrintManagerPrintTaskRequested; _printDocument = new PrintDocument(); _printDocument.Paginate += OnPrintDocumentPaginate; _printDocument.GetPreviewPage += OnPrintDocumentGetPreviewPage; _printDocument.AddPages += OnPrintDocumentAddPages; _documentSource = _printDocument.DocumentSource; }
/// <summary> /// This function registers the app for printing with Windows and sets up the necessary event handlers for the print process. /// </summary> public virtual void RegisterForPrinting() { printDocument = new PrintDocument(); printDocumentSource = printDocument.DocumentSource; printDocument.Paginate += CreatePrintPreviewPages; printDocument.GetPreviewPage += GetPrintPreviewPage; printDocument.AddPages += AddPrintPages; PrintManager printMan = PrintManager.GetForCurrentView(); printMan.PrintTaskRequested += PrintTaskRequested; }
protected override void OnNavigatedTo(NavigationEventArgs e) { document = new PrintDocument(); source = document.DocumentSource; document.Paginate += printDocument_Paginate; document.GetPreviewPage += printDocument_GetPreviewPage; document.AddPages += printDocument_AddPages; PrintManager manager = PrintManager.GetForCurrentView(); manager.PrintTaskRequested += manager_PrintTaskRequested; pages = new List<UIElement>(); PrepareContent(); }
async void OnPrintTaskSourceRequestedHandler(PrintTaskSourceRequestedArgs args) { var deferral = args.GetDeferral(); await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { this.document = new PrintDocument(); this.document.Paginate += OnPaginate; this.document.GetPreviewPage += OnGetPreviewPage; this.document.AddPages += OnAddPages; // Tell the caller about it. args.SetSource(this.document.DocumentSource); }); deferral.Complete(); }
// 为打印做好准备工作 private void RegisterForPrinting() { printDocument = new PrintDocument(); // 当系统请求将打印内容显示在预览窗口时 printDocument.Paginate += printDocument_Paginate; // 当系统请求将打印内容中的某一页显示在预览窗口时 printDocument.GetPreviewPage += printDocument_GetPreviewPage; // 当系统请求将打印内容发送到打印机时 printDocument.AddPages += printDocument_AddPages; // 单击 charm 中的“设备”后显示打印设备 PrintManager printManager = PrintManager.GetForCurrentView(); // 当出现打印请求时(在 PrintManager.GetForCurrentView() 之后单击“设备”弹出打印设备列表时,或通过 PrintManager.ShowPrintUIAsync() 弹出打印设备列表时) printManager.PrintTaskRequested += printManager_PrintTaskRequested; // 提供打印内容 PreparedPrintContent(); }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); //printer document = new PrintDocument(); source = document.DocumentSource; document.Paginate += printDocument_Paginate; document.GetPreviewPage += printDocument_GetPreviewPage; document.AddPages += printDocument_AddPages; //za wsqka stranica ot koqto iska6 da printira6 pi6e6 menigyr za printiraneto manager = PrintManager.GetForCurrentView(); manager.PrintTaskRequested += manager_PrintTaskRequested; pages = new List<UIElement>(); PrepareContent(); }
void PrintButton_Click(object sender, RoutedEventArgs e) { _PrintDocument = new PrintDocument(); _DocumentSource = _PrintDocument.DocumentSource; _PrintDocument.GetPreviewPage += new GetPreviewPageEventHandler(printDocument_GetPreviewPage); _PrintDocument.Paginate += new PaginateEventHandler(printDocument_Paginate); _PrintDocument.AddPages += new AddPagesEventHandler(printDocument_AddPages); var printManager = PrintManager.GetForCurrentView(); try { printManager.PrintTaskInitializing += new TypedEventHandler<PrintManager, PrintTaskInitializingEventArgs>(printManager_PrintTaskInitializing); } catch { } PrintManager.ShowPrintUI(); }
private async void OnPrintButtonClick(object sender, RoutedEventArgs e) { if (ApplicationView.Value != ApplicationViewState.Snapped) { document = new PrintDocument(); source = document.DocumentSource; document.Paginate += PrintDocumentPaginate; document.GetPreviewPage += PrintDocumentGetPreviewPage; document.AddPages += PrintDocumentAddPages; PrintManager manager = PrintManager.GetForCurrentView(); manager.PrintTaskRequested += ManagerPrintTaskRequested; pages = new List<UIElement>(); PrepareContent(); await Windows.Graphics.Printing.PrintManager.ShowPrintUIAsync(); } else { var message = new MessageDialog("This action is not supported in snapped view"); message.ShowAsync(); } }
/// <summary> /// This function registers the app for printing with Windows and sets up the necessary event handlers for the print process. /// </summary> protected virtual void RegisterForPrinting() { // Create the PrintDocument. printDocument = new PrintDocument(); // Save the DocumentSource. printDocumentSource = printDocument.DocumentSource; // Add an event handler which creates preview pages. printDocument.Paginate += CreatePrintPreviewPages; // Add an event handler which provides a specified preview page. printDocument.GetPreviewPage += GetPrintPreviewPage; // Add an event handler which provides all final print pages. printDocument.AddPages += AddPrintPages; // Create a PrintManager and add a handler for printing initialization. PrintManager printMan = PrintManager.GetForCurrentView(); printMan.PrintTaskRequested += PrintTaskRequested; // Initialize print content for this scenario PreparetPrintContent(); }
/// <summary> /// This function unregisters the app for printing with Windows. /// </summary> private void UnregisterForPrinting() { // Set the instance of the PrintDocument to null. printDocument = null; // Remove the handler for printing initialization. PrintManager printMan = PrintManager.GetForCurrentView(); printMan.PrintTaskRequested -= PrintTaskRequested; }
private void RegisterForPrinting() { PrintDocument pd = new PrintDocument(); pd.Paginate += (a, b) => { pd.SetPreviewPageCount(1, PreviewPageCountType.Final); }; pd.AddPages += (a, b) => { pd.AddPage(webReceipt); pd.AddPagesComplete(); }; pd.GetPreviewPage += (a, b) => { pd.SetPreviewPage(b.PageNumber, webReceipt); }; PrintManager.GetForCurrentView().PrintTaskRequested += (sender, e) => e.Request.CreatePrintTask("Účtenka RestSys", async args => { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { args.SetSource(pd.DocumentSource); }); }); }
void OnPrintTaskCompleted(PrintTask sender, PrintTaskCompletedEventArgs args) { this.pageCount = 0; this.document = null; }
/// <summary> /// Registers the app for printing with Windows and sets up the necessary event handlers for the print process. /// </summary> public void RegisterForPrinting(Page sourcePage, Type printPageType, object viewModel) { this.callingPage = sourcePage; if (PrintingRoot == null) { this.OnStatusChanged(new PrintServiceEventArgs("The calling page has no PrintingRoot Canvas.")); return; } this.printPageType = printPageType; this.DataContext = viewModel; // Prep the content this.PreparePrintContent(); // Create the PrintDocument. printDocument = new PrintDocument(); // Save the DocumentSource. printDocumentSource = printDocument.DocumentSource; // Add an event handler which creates preview pages. printDocument.Paginate += PrintDocument_Paginate; // Add an event handler which provides a specified preview page. printDocument.GetPreviewPage += PrintDocument_GetPrintPreviewPage; // Add an event handler which provides all final print pages. printDocument.AddPages += PrintDocument_AddPages; // Create a PrintManager and add a handler for printing initialization. PrintManager printMan = PrintManager.GetForCurrentView(); try { printMan.PrintTaskRequested += PrintManager_PrintTaskRequested; this.OnStatusChanged(new PrintServiceEventArgs("Registered successfully.")); } catch (InvalidOperationException) { // Probably already registered. this.OnStatusChanged(new PrintServiceEventArgs("You were already registered.")); } }
public PrintDocumentEvents(PrintDocument This) { this.This = This; }
private void AttachPrintContract() { // prepare print document and add pagination handlers printDocument = new PrintDocument(); printDocumentSource = printDocument.DocumentSource; printPages = new List<UIElement>(); printDocument.Paginate += CreatePrintPages; // creates preview/print pages printDocument.GetPreviewPage += GetCurrentPrintPage; // provides a specified preview/print page printDocument.AddPages += AddPrintPages; //provides all final print pages // Add a handler for printing initialization. var printMan = PrintManager.GetForCurrentView(); printMan.PrintTaskRequested += PrintTaskRequested; }
void OnPrintTaskCompleted(PrintTask sender, PrintTaskCompletedEventArgs args) { this.pageSize = null; this.imageableRect = null; this.document = null; this.pages = null; }
// #1 private void RegisterForPrinting() { doc = new PrintDocument(); // Attach handlers to relevant events doc.GetPreviewPage += OnGetPreviewPage; doc.Paginate += OnPaginate; doc.AddPages += OnAddPages; PrintManager printManager = PrintManager.GetForCurrentView(); printManager.PrintTaskRequested += OnPrintTaskRequested; }