Esempio n. 1
1
        public override void DoPrint(FlowDocument document)
        {
            var ph = document.PageHeight;
            var pw = document.PageWidth;
            var pp = document.PagePadding;
            var cg = document.ColumnGap;
            var cw = document.ColumnWidth;

            var q = PrinterInfo.GetPrinter(Printer.ShareName);
            var pd = new PrintDialog { PrintQueue = q };
            if (pd.PrintQueue.FullName == Printer.ShareName || pd.ShowDialog().GetValueOrDefault(false))
            {
                document.PageHeight = pd.PrintableAreaHeight;
                document.PageWidth = pd.PrintableAreaWidth;
                document.PagePadding = new Thickness(25);
                document.ColumnGap = 0;
                document.ColumnWidth = (document.PageWidth -
                                       document.ColumnGap -
                                       document.PagePadding.Left -
                                       document.PagePadding.Right);
                pd.PrintDocument(((IDocumentPaginatorSource)document).DocumentPaginator, "");
            }

            document.PageHeight = ph;
            document.PageWidth = pw;
            document.PagePadding = pp;
            document.ColumnGap = cg;
            document.ColumnWidth = cw;
        }
Esempio n. 2
0
 private void print_btn_Click(object sender, RoutedEventArgs e)
 {
     try
      {
             report.report_cr_dr p = new BMS.report.report_cr_dr();
         p.lst_balance.ItemsSource = dr;
         p.r_date.Content = DateTime.Now.Date.ToShortDateString();
         p.r_name.Content = "Top Debitors";
         PrintDialog pd = new PrintDialog();
         FixedDocument document = new FixedDocument();
         document.DocumentPaginator.PageSize = new Size(96 * 8.5, 96 * 11);
         FixedPage page1 = new FixedPage();
         page1.Width = document.DocumentPaginator.PageSize.Width;
         page1.Height = document.DocumentPaginator.PageSize.Height;
         Canvas can = p.layout;
         page1.Children.Add(can);
         PageContent page1Content = new PageContent();
         ((IAddChild)page1Content).AddChild(page1);
         document.Pages.Add(page1Content);
         pd.PrintDocument(document.DocumentPaginator, "My first document");
     }
     catch (Exception ex)
     {
         MessageBox.Show("Sorry some system error has occour please try again");
     }
 }
        private void cmdPrint_Click(object sender, RoutedEventArgs e)
        {
            PrintDialog pd = new PrintDialog();
            if (pd.ShowDialog().GetValueOrDefault())
            {
                PrintTicket ticket = pd.PrintTicket;

                if (cmboOrientation.SelectedIndex == 0)
                {
                    ticket.PageOrientation = PageOrientation.Landscape;
                }
                else
                {
                    ticket.PageOrientation = PageOrientation.Portrait;
                }
                pd.PrintTicket = ticket;


                mDoc.PageHeight = pd.PrintableAreaHeight;
                mDoc.PageWidth = pd.PrintableAreaWidth;
                mDoc.PagePadding = new Thickness(50);
                mDoc.ColumnGap = 0;
                mDoc.ColumnWidth = pd.PrintableAreaWidth;

                IDocumentPaginatorSource dps = mDoc;
                pd.PrintDocument(dps.DocumentPaginator, title);
            }
        }
        private void ButtonOk_Click(object sender, RoutedEventArgs e)
        {
            this.TextBoxRealReportNumber.Text  = this.TextBoxRealReportNumber.Text.ToUpper();
            this.TextBoxDummyReportNumber.Text = this.TextBoxDummyReportNumber.Text.ToUpper();

            if (this.TextBoxRealReportNumber.Text.Length < 4)
            {
                MessageBox.Show("The real report number does not appear to be a valid number.\n\nPlease check it and try again.", "Invalid report number", MessageBoxButton.OK);
                return;
            }
            string lastName = this.GetPatientLastName();

            if (lastName.Length == 0)
            {
                MessageBox.Show("The report number does not appear to be a valid number.\n\nPlease check it and try again.", "Case not found", MessageBoxButton.OK);
                return;
            }

            YellowstonePathology.UI.Login.CytologySlideLabelDocument cyologySlideLabelDocument = new CytologySlideLabelDocument(this.TextBoxDummyReportNumber.Text, lastName, false);
            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();

            System.Printing.PrintQueue printQueue = YellowstonePathology.UI.PrintQueueFactory.GetSlideLabelPrintQueue(YellowstonePathology.UI.Properties.Settings.Default.CytologySlideLabelPrinterName);
            printDialog.PrintQueue = printQueue;
            printDialog.PrintDocument(cyologySlideLabelDocument.DocumentPaginator, "Slide Labels");

            Close();
        }
Esempio n. 5
0
        public static void printOrder( Order o )
        {
            PrintDialog printDlg = new PrintDialog();

            String textToPrint = "";
            textToPrint += "\t\t Τραπέζι "+o.Table_id+"\n\n";

            textToPrint += "Παραγγελία : \n";
            String orderName = "";
            foreach (Items i in DBController.LoadItems())
            {
                if (i.Id == o.Items_id)
                    orderName = i.Name;
            }

            orderName += o.CharacteristicsInfo;
            textToPrint += "\t1 "+orderName+"\n";

            textToPrint += "\n\n";

            String waiterName = "";
            foreach (User u in DBController.LoadUsers())
            {
                if (u.User_id == o.User_id)
                    waiterName = u.Name;
            }

            textToPrint += "Σερβιτόρος : "+waiterName+"\n";
            textToPrint += "Ώρα : " + DateTime.Now.ToString("dd/MM/yyyy h:mm:ss tt");

            FlowDocument doc = new FlowDocument(new Paragraph(new Run(textToPrint)));
            doc.Name = "FlowDoc";
            IDocumentPaginatorSource idpSource = doc;
            printDlg.PrintDocument(idpSource.DocumentPaginator, "smart order");
        }
Esempio n. 6
0
 private void Print_Click(object sender, RoutedEventArgs e)
 {
     //If you reduce the size of the view area of the window, so the text does not all fit into one page, it will print separate pages
     PrintDialog printDialog = new PrintDialog();
     if (printDialog.ShowDialog() == true)
         printDialog.PrintDocument(((IDocumentPaginatorSource)flowDocument).DocumentPaginator, "This is a Flow Document");
 }
Esempio n. 7
0
        /// <summary>
        /// Invokes a System.Windows.Controls.PrintDialog to print the TextEditor.Document with specified title.
        /// </summary>
        public static void PrintDialog(this TextEditor textEditor, string title, bool withHighlighting)
        {
            PrintSettings settings = textEditor.Tag as PrintSettings;

            if (settings == null)
            {
                settings       = new PrintSettings();
                textEditor.Tag = settings;
            }

            settings.DocumentTitle = (title != null) ? title : String.Empty;
            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
            printDialog.PrintQueue = settings.PrintQueue;

            if (settings.PageSettings.Landscape)
            {
                settings.PrintTicket.PageOrientation = PageOrientation.Landscape;
            }

            printDialog.PrintTicket = settings.PrintTicket;
            printDialog.PrintQueue.DefaultPrintTicket.PageOrientation = settings.PrintTicket.PageOrientation;
            if (printDialog.ShowDialog() == true)
            {
                settings.PrintQueue  = printDialog.PrintQueue;
                settings.PrintTicket = printDialog.PrintTicket;
                printDialog.PrintDocument(CreateDocumentPaginatorToPrint(textEditor, withHighlighting), "PrintJob");
            }
        }
        private void btnPrint_Click_1(object sender, RoutedEventArgs e)
        {
            var printControl = new SummaryControl();
            printControl.DataContext = _reservation;
            printControl.Width = 8.27 * 96;
            printControl.Height = 11.69 * 96;

            //Create a fixed Document and Print the document
            FixedDocument fixedDoc = new FixedDocument();
            PageContent pageContent = new PageContent();
            FixedPage fixedPage = new FixedPage();
            fixedPage.Height = 11.69 * 96;
            fixedPage.Width = 8.27 * 96;

            fixedPage.Children.Add(printControl);
            ((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage);
            fixedDoc.Pages.Add(pageContent);

            PrintDialog dialog = new PrintDialog();
            if (dialog.ShowDialog() == true)
            {
                //dialog.PrintVisual(_PrintCanvas, "My Canvas");
                dialog.PrintDocument(fixedDoc.DocumentPaginator, "Print label");
            }
        }
        //----< prints FlowDocument deserialized from MemoryStream >-------
        void printFromStream(MemoryStream stream)
        {
            FlowDocument             fd   = (FlowDocument)System.Windows.Markup.XamlReader.Load(stream);
            IDocumentPaginatorSource idoc = fd as IDocumentPaginatorSource;

            printDialog.PrintDocument(idoc.DocumentPaginator, "printing analysis");
        }
Esempio n. 10
0
        /// <summary>
        /// Invokes a System.Windows.Controls.PrintDialog to print the TextEditor.Document with specified title.
        /// </summary>
        public static void PrintDialog(this TextEditor textEditor, string title)
        {
            Printing.mDocumentTitle = title;

              Printing.InitPageSettings();

              System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();

              printDialog.PrintQueue = mPrintQueue;

              if (mPageSettings.Landscape)
            Printing.mPrintTicket.PageOrientation = PageOrientation.Landscape;

              printDialog.PrintTicket = mPrintTicket;
              printDialog.PrintQueue.DefaultPrintTicket.PageOrientation = mPrintTicket.PageOrientation;

              if (printDialog.ShowDialog() == true)
              {
            Printing.mPrintQueue = printDialog.PrintQueue;

            Printing.mPrintTicket = printDialog.PrintTicket;

            printDialog.PrintDocument(CreateDocumentPaginatorToPrint(textEditor), "PrintJob");
              }
        }
Esempio n. 11
0
        private void cmdPrintCustom_Click(object sender, RoutedEventArgs e)
        {
            PrintDialog printDialog = new PrintDialog();
            if (printDialog.ShowDialog() == true)
            {
                FlowDocument doc = docReader.Document;
                
                // Save all the existing settings.                                
                double pageHeight = doc.PageHeight;
                double pageWidth = doc.PageWidth;
                Thickness pagePadding = doc.PagePadding;
                double columnGap = doc.ColumnGap;
                double columnWidth = doc.ColumnWidth;

                // Make the FlowDocument page match the printed page.
                doc.PageHeight = printDialog.PrintableAreaHeight;
                doc.PageWidth = printDialog.PrintableAreaWidth;
                doc.PagePadding = new Thickness(50);

                // Use two columns.
                doc.ColumnGap = 25;
                doc.ColumnWidth = (doc.PageWidth - doc.ColumnGap
                    - doc.PagePadding.Left - doc.PagePadding.Right) / 2;

                printDialog.PrintDocument(((IDocumentPaginatorSource)doc).DocumentPaginator, "A Flow Document");
                
                // Reapply the old settings.
                doc.PageHeight = pageHeight;
                doc.PageWidth = pageWidth;
                doc.PagePadding = pagePadding;
                doc.ColumnGap = columnGap;
                doc.ColumnWidth = columnWidth;
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Invokes a System.Windows.Controls.PrintDialog to print the TextEditor.Document with specified title.
        /// </summary>
        public static void PrintDialog(this TextEditor textEditor, string title)
        {
            Printing.mDocumentTitle = title;

            Printing.InitPageSettings();

            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();

            printDialog.PrintQueue = mPrintQueue;

            if (mPageSettings.Landscape)
            {
                Printing.mPrintTicket.PageOrientation = PageOrientation.Landscape;
            }

            printDialog.PrintTicket = mPrintTicket;
            printDialog.PrintQueue.DefaultPrintTicket.PageOrientation = mPrintTicket.PageOrientation;

            if (printDialog.ShowDialog() == true)
            {
                Printing.mPrintQueue = printDialog.PrintQueue;

                Printing.mPrintTicket = printDialog.PrintTicket;

                printDialog.PrintDocument(CreateDocumentPaginatorToPrint(textEditor), "PrintJob");
            }
        }
Esempio n. 13
0
        public override void DoPrint(FlowDocument document)
        {
            var ph = document.PageHeight;
            var pw = document.PageWidth;
            var pp = document.PagePadding;
            var cg = document.ColumnGap;
            var cw = document.ColumnWidth;

            var q = PrinterInfo.GetPrinter(Printer.ShareName);
            var pd = new PrintDialog { PrintQueue = q };
            if (pd.PrintQueue.FullName == Printer.ShareName || pd.ShowDialog().GetValueOrDefault(false))
            {
                document.FontFamily = new System.Windows.Media.FontFamily(LocalSettings.PrintFontFamily);
                document.Typography.EastAsianWidths = FontEastAsianWidths.Half;
                document.PageHeight = pd.PrintableAreaHeight;
                document.PageWidth = pd.PrintableAreaWidth;
                document.PagePadding = new Thickness(25);
                document.ColumnGap = 0;
                document.ColumnWidth = (document.PageWidth -
                                       document.ColumnGap -
                                       document.PagePadding.Left -
                                       document.PagePadding.Right);
                pd.PrintDocument(((IDocumentPaginatorSource)document).DocumentPaginator, "");
            }

            document.PageHeight = ph;
            document.PageWidth = pw;
            document.PagePadding = pp;
            document.ColumnGap = cg;
            document.ColumnWidth = cw;
        }
 private void btnPrint_Click(object sender, EventArgs e)
 {
     //REFACTOR ME
     dtgParentReport.Update();
     System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
     Nullable<bool> print = printDialog.ShowDialog();
     if (print == true)
     {
         try
         {
             XpsDocument xpsDocument = new XpsDocument("C:\\FixedDocumentSequence.xps", FileAccess.ReadWrite);
             FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence();
             printDialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Test print job");
         }
         catch (UnauthorizedAccessException e1)
         {
             const string message =
                 "Unauthoried to access that printer.";
             const string caption = "Unauthoried Access";
             var result = MessageBox.Show(message, caption,
                                         MessageBoxButtons.OK,
                                         MessageBoxIcon.Error);
         }
         catch (PrintDialogException e2)
         {
             const string message =
                 "Unknow error occurred.";
             const string caption = "Error Printing";
             var result = MessageBox.Show(message, caption,
                                         MessageBoxButtons.OK,
                                         MessageBoxIcon.Error);
         }
     }
 }
        public static void stampajUgovor()
        {
            PdfDocument pdf = PdfGenerator.GeneratePdf(
                @"<html>
                            <body style=""text-align:center;background-color:red"">
                                <p>
                                    <a href=""www.google.rs"">Hello World</a>
                                    This is html rendered text
                                </p>
                            </body>
                      </html>", PageSize.A4);

            pdf.Save("document.pdf");
            PrintDialog pDialog = new PrintDialog();

            pDialog.PageRangeSelection   = PageRangeSelection.AllPages;
            pDialog.UserPageRangeEnabled = true;

            // Display the dialog. This returns true if the user presses the Print button.
            bool?print = pDialog.ShowDialog();

            Aspose.Pdf.Document.Convert("document.pdf", null, "hello.xps", new XpsSaveOptions());
            if (print == true)
            {
                XpsDocument           xpsDocument = new XpsDocument("hello.xps", FileAccess.ReadWrite);
                FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence();
                pDialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Test print job");
            }
        }
Esempio n. 16
0
        public static void Print(FlowDocument printedPage)
        {
            PrintDialog dialog = new PrintDialog();

            dialog.PrintTicket = dialog.PrintQueue.DefaultPrintTicket;
            dialog.PrintTicket.PageOrientation = PageOrientation.Portrait;
            dialog.PrintTicket.OutputQuality = OutputQuality.High;
            dialog.PrintTicket.PageBorderless = PageBorderless.None;
            dialog.PrintTicket.PageMediaSize = new PageMediaSize(PageMediaSizeName.ISOA4);

            if (dialog.ShowDialog() == true)
            {
                double pageHeight = printedPage.PageHeight;
                double pageWidth = printedPage.PageWidth;
                Thickness pagePadding = printedPage.PagePadding;
                double columnGap = printedPage.ColumnGap;
                double columnWidth = printedPage.ColumnWidth;

                printedPage.PageHeight = dialog.PrintableAreaHeight;
                printedPage.PageWidth = dialog.PrintableAreaWidth;
                printedPage.PagePadding = new Thickness(50);

                dialog.PrintDocument(((IDocumentPaginatorSource)printedPage).DocumentPaginator, "");

                printedPage.PagePadding = pagePadding;
                printedPage.PageHeight = pageHeight;
                printedPage.PageWidth = pageWidth;
                printedPage.ColumnWidth = columnWidth;
                printedPage.ColumnGap = columnGap;

            }
        }
Esempio n. 17
0
        public override void DoPrint(FlowDocument document)
        {
            var ph = document.PageHeight;
            var pw = document.PageWidth;
            var pp = document.PagePadding;
            var cg = document.ColumnGap;
            var cw = document.ColumnWidth;
            var fm = document.FontFamily;
            var bg = document.Background;

            var q = PrinterInfo.GetPrinter(Printer.ShareName);
            var pd = new PrintDialog { PrintQueue = q };
            if (q != null || pd.PrintQueue.FullName == Printer.ShareName || Printer.ShareName.ToLower() == "default" || Printer.ShareName.Contains("/") || pd.ShowDialog().GetValueOrDefault(false))
            {
                document.Background = Brushes.Transparent;
                document.FontFamily = new FontFamily(LocalSettings.PrintFontFamily);
                document.PageHeight = pd.PrintableAreaHeight;
                document.PageWidth = pd.PrintableAreaWidth;
                document.PagePadding = new Thickness(25);
                document.ColumnGap = 0;
                document.ColumnWidth = (document.PageWidth -
                                       document.ColumnGap -
                                       document.PagePadding.Left -
                                       document.PagePadding.Right);
                pd.PrintDocument(((IDocumentPaginatorSource)document).DocumentPaginator, "");
            }

            document.Background = bg;
            document.FontFamily = fm;
            document.PageHeight = ph;
            document.PageWidth = pw;
            document.PagePadding = pp;
            document.ColumnGap = cg;
            document.ColumnWidth = cw;
        }
Esempio n. 18
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            //REFACTOR ME
            dtgParentReport.Update();
            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
            Nullable <bool> print = printDialog.ShowDialog();

            if (print == true)
            {
                try
                {
                    XpsDocument           xpsDocument = new XpsDocument("C:\\FixedDocumentSequence.xps", FileAccess.ReadWrite);
                    FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence();
                    printDialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Test print job");
                }
                catch (UnauthorizedAccessException e1)
                {
                    const string message =
                        "Unauthoried to access that printer.";
                    const string caption = "Unauthoried Access";
                    var          result  = MessageBox.Show(message, caption,
                                                           MessageBoxButtons.OK,
                                                           MessageBoxIcon.Error);
                }
                catch (PrintDialogException e2)
                {
                    const string message =
                        "Unknow error occurred.";
                    const string caption = "Error Printing";
                    var          result  = MessageBox.Show(message, caption,
                                                           MessageBoxButtons.OK,
                                                           MessageBoxIcon.Error);
                }
            }
        }
        private void ButtonOk_Click(object sender, RoutedEventArgs e)
        {
            this.TextBoxRealReportNumber.Text = this.TextBoxRealReportNumber.Text.ToUpper();
            this.TextBoxDummyReportNumber.Text = this.TextBoxDummyReportNumber.Text.ToUpper();

            if (this.TextBoxRealReportNumber.Text.Length < 4)
            {
                MessageBox.Show("The real report number does not appear to be a valid number.\n\nPlease check it and try again.", "Invalid report number", MessageBoxButton.OK);
                return;
            }
            string lastName = this.GetPatientLastName();

            if (lastName.Length == 0)
            {
                MessageBox.Show("The report number does not appear to be a valid number.\n\nPlease check it and try again.", "Case not found", MessageBoxButton.OK);
                return;
            }

            YellowstonePathology.UI.Login.CytologySlideLabelDocument cyologySlideLabelDocument = new CytologySlideLabelDocument(this.TextBoxDummyReportNumber.Text, lastName, false);
            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();

            System.Printing.PrintQueue printQueue = YellowstonePathology.UI.PrintQueueFactory.GetSlideLabelPrintQueue(YellowstonePathology.Properties.Settings.Default.CytologySlideLabelPrinterName);
            printDialog.PrintQueue = printQueue;
            printDialog.PrintDocument(cyologySlideLabelDocument.DocumentPaginator, "Slide Labels");

            Close();
        }
 public void PrintCommand()
 {
     PrintDialog printDlg = new PrintDialog();
     FlowDocument doc = new FlowDocument(new Paragraph(new Run(WebAddress))) {Name = "Directions"};
     IDocumentPaginatorSource idpSource = doc;
     printDlg.PrintDocument(idpSource.DocumentPaginator, "Directions Printing.");
 }
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            //Show a Print Dialog
            PrintDialog dialog = new PrintDialog();
            dialog.MaxPage = this.pdfViewer1.PageCount > 0 ? (uint)this.pdfViewer1.PageCount : 1;
            dialog.MinPage = 1;
            dialog.UserPageRangeEnabled = true;

            bool? result = dialog.ShowDialog();

            if (result.Value)
            {
                try
                {
                    //Set print parnameters.
                    this.pdfViewer1.PrintDialog = dialog;
                    //Get the PrintDocument.
                    dialog.PrintDocument(pdfViewer1.PrintDocument.DocumentPaginator, "Print Document");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }

        }
Esempio n. 22
0
 private void cmdPrint_Click(object sender, RoutedEventArgs e)
 {
     PrintDialog printDialog = new PrintDialog();
     if (printDialog.ShowDialog() == true)
     {                
         printDialog.PrintDocument(((IDocumentPaginatorSource)docReader.Document).DocumentPaginator, "A Flow Document");
     }
 }
Esempio n. 23
0
        public void PrintDocumentFD(FlowDocument Doc)
        {
            PrintDialog pdDialog = new PrintDialog();
            // Create IDocumentPaginatorSource from FlowDocument
            IDocumentPaginatorSource idpSource = Doc;

            // Call PrintDocument method to send document to printer
            pdDialog.PrintDocument(idpSource.DocumentPaginator, Doc.Name);
        }
 public void Print()
 {
     PrintDialog printDialog = new PrintDialog();
     if (printDialog.ShowDialog() == true)
     {
         var document = CreateDocument(new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight));
         printDialog.PrintDocument(document.DocumentPaginator, "MyPrintJobName");
     }
 }
Esempio n. 25
0
        public void Print(IDocument document, string jobTitle)
        {
            var printDialog = new PrintDialog();
            if (printDialog.ShowDialog() != true)
                return;

            DocumentPaginator documentPaginator = new XpsPrintingDocumentPaginator(document);
            printDialog.PrintDocument(documentPaginator, jobTitle);
        }
Esempio n. 26
0
		public static void Print(IEnumerable<BitmapSource> exportImages)
		{
			var printDialog = new PrintDialog();
			if (printDialog.ShowDialog() == true)
			{
				var paginator = new GanttPaginator(exportImages);
				printDialog.PrintDocument(paginator, "Print demo");
			}
		}
Esempio n. 27
0
 private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     PrintDialog dialog = new PrintDialog();
     if (dialog.ShowDialog() == true)
     {
         UpdateDoc();
         dialog.PrintDocument(((IDocumentPaginatorSource)doc).DocumentPaginator,"Print");
     }
 }
Esempio n. 28
0
        private void ButtonPrintTrackingDocument_Click(object sender, RoutedEventArgs e)
        {
            MaterialTrackingBatchSummary materialTrackingBatchSummary = new MaterialTrackingBatchSummary(this.m_MaterialTrackingBatch, this.m_MaterialTrackingLogViewCollection);

            System.Printing.PrintQueue          printQueue  = new System.Printing.LocalPrintServer().DefaultPrintQueue;
            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
            printDialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Portrait;
            printDialog.PrintQueue = printQueue;
            printDialog.PrintDocument(materialTrackingBatchSummary.FixedDocument.DocumentPaginator, "Material Tracking Batch Summary");
        }
Esempio n. 29
0
        private void PrintClick(object sender, RoutedEventArgs e)
        {
            var printDialog = new PrintDialog();
            if (printDialog.ShowDialog() != true) return;

            var paginator = new Paginador(new ServicoDados().ObterClientes(),
                                                new Size(printDialog.PrintableAreaWidth,
                                                printDialog.PrintableAreaHeight));
            printDialog.PrintDocument(paginator, "Impressão Wpf");
        }
Esempio n. 30
0
        public void Print()
        {
            System.Printing.PrintQueue printQueue = new System.Printing.LocalPrintServer().DefaultPrintQueue;

            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
            printDialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Portrait;
            printDialog.PrintQueue = printQueue;
            DocumentPaginator documentPaginator = ((IDocumentPaginatorSource)this).DocumentPaginator;
            printDialog.PrintDocument(documentPaginator, "PackingSlip");
        }
Esempio n. 31
0
 private void PrintReport_Method(object obj)
 {
     System.Windows.Controls.PrintDialog printDlg = new System.Windows.Controls.PrintDialog();
     if (printDlg.ShowDialog() == true)
     {
         //PrintReportDocumentPaginator prp = new PrintReportDocumentPaginator(eclipsedatamodel.CurrentPatient, eclipsedatamodel.CurrentPlanSetup,new Typeface("Calibri"),12,96*0.75,new Size(printDlg.PrintableAreaWidth,printDlg.PrintableAreaHeight));
         PrintReportDocumentPaginator prp = new PrintReportDocumentPaginator(rd1, rd2, new System.Windows.Media.Typeface("Calibri"), 12, 96 * 0.75, new Size(printDlg.PrintableAreaWidth, printDlg.PrintableAreaHeight));
         printDlg.PrintDocument(prp, "Print Report");
         Console.WriteLine("Here");
     }
 }
Esempio n. 32
0
 private void PrintTaskOrder(int copyCount)
 {
     Receiving.TaskOrderDataSheet        taskOrderDataSheet = new Receiving.TaskOrderDataSheet(this.m_TaskOrder, this.m_AccessionOrder);
     System.Printing.PrintQueue          printQueue         = new System.Printing.LocalPrintServer().DefaultPrintQueue;
     System.Windows.Controls.PrintDialog printDialog        = new System.Windows.Controls.PrintDialog();
     printDialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Portrait;
     printDialog.PrintTicket.CopyCount       = copyCount;
     printDialog.PrintQueue = printQueue;
     printDialog.PrintDocument(taskOrderDataSheet.FixedDocument.DocumentPaginator, "Task Order Data Sheet");
     MessageBox.Show("This task has been submitted to the printer.");
 }
Esempio n. 33
0
        public void Print()
        {
            System.Printing.PrintQueue printQueue = new System.Printing.LocalPrintServer().DefaultPrintQueue;

            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
            printDialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Portrait;
            printDialog.PrintQueue = printQueue;
            DocumentPaginator documentPaginator = ((IDocumentPaginatorSource)this).DocumentPaginator;

            printDialog.PrintDocument(documentPaginator, "PackingSlip");
        }
Esempio n. 34
0
        private void Print_Click(object sender, RoutedEventArgs e)
        {
            FlowDocument d = new FlowDocument();

            Document = d;

            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
            if (printDialog.ShowDialog() == true)
            {
                printDialog.PrintDocument(((IDocumentPaginatorSource)CurrentDocument.Document).DocumentPaginator, "Cheque");
            }
        }
Esempio n. 35
0
        private void Print()
        {
            // Create a PrintDialog.
            var printDialog = new PrintDialog();

            // Show the dialog and print the document if successful
            if (printDialog.ShowDialog() == true)
            {
                printDialog.PrintDocument((((IDocumentPaginatorSource)richTextBox.Document).DocumentPaginator),
                                          "printing as paginator");
            }
        }
Esempio n. 36
0
        private void PrintSimpleTextButton_Click(object sender, RoutedEventArgs e)
        {
            //    PrintDialog printDlg = new PrintDialog();

            //    // Create a FlowDocument dynamically.
            //    FlowDocument doc = CreateFlowDocument();
            //    doc.Name = "FlowDoc";

            //    // Create IDocumentPaginatorSource from FlowDocument
            //    IDocumentPaginatorSource idpSource = doc;

            //    // Call PrintDocument method to send document to printer
            //    printDlg.PrintDocument(idpSource.DocumentPaginator, "Hello WPF Printing.");
            PrintDialog pd = new PrintDialog();
            if (pd.ShowDialog() != true) return;
            FixedDocument document = new FixedDocument();
            document.DocumentPaginator.PageSize = new Size(8.5,11);
            FixedPage page1 = new FixedPage();
            page1.Width = document.DocumentPaginator.PageSize.Width;
            page1.Height = document.DocumentPaginator.PageSize.Height;
            Canvas can = new Canvas();
            TextBlock page1Text = new TextBlock();
            page1Text.Text = "This is the first page";
            page1Text.FontSize = 10; // 30pt text
            page1Text.Margin = new Thickness(5, 20, 30, 10);
            can.Children.Add(page1Text);
             // 1 inch margin
            //page1.Children.Add(page1Text);
            page1.Width = document.DocumentPaginator.PageSize.Width;
            page1.Height = document.DocumentPaginator.PageSize.Height;
            TextBlock page2Text = new TextBlock();
            page2Text.Text = "This is the first page";
            page2Text.FontSize = 40; // 30pt text
            page2Text.Margin = new Thickness(5, 20, 30, 10); // 1 inch margin
            can.Children.Add(page2Text);
            page1.Children.Add(can);
            PageContent page1Content = new PageContent();
            ((IAddChild)page1Content).AddChild(page1);
            document.Pages.Add(page1Content);
            //FixedPage page2 = new FixedPage();
            //page2.Width = document.DocumentPaginator.PageSize.Width;
            //page2.Height = document.DocumentPaginator.PageSize.Height;
            //TextBlock page2Text = new TextBlock();
            //page2Text.Text = "This is NOT the first page";
            //page2Text.FontSize = 40;
            //page2Text.Margin = new Thickness(96);
            //page2.Children.Add(page2Text);
            //PageContent page2Content = new PageContent();
            //((IAddChild)page2Content).AddChild(page2);
            //document.Pages.Add(page2Content);
            pd.PrintDocument(document.DocumentPaginator, "My first document");
        }
Esempio n. 37
0
        private void PrintReport(object param)
        {
            PrintDialog printDialog = new PrintDialog();

            if (printDialog.ShowDialog() == false)
                return;
            string documentTitle = string.Format("Inventory Transfers Report-{0}", DateTime.Now.ToLocalTime());
           
            Size pageSize = new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight);

            CustomDataGridDocumentPaginator paginator = new CustomDataGridDocumentPaginator(param as DataGrid, documentTitle, pageSize, new Thickness(30, 20, 30, 20));
            printDialog.PrintDocument(paginator, "Grid");
        }
Esempio n. 38
0
        public static void PrintGrid(DataGrid param,string DocTitle)
        {
            printDialog= new PrintDialog();
            if (printDialog.ShowDialog() == false)
                return;

            string documentTitle = DocTitle;
            Size pageSize = new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight);

            CustomDataGridDocumentPaginator paginator = new CustomDataGridDocumentPaginator(param as DataGrid, documentTitle, pageSize, new Thickness(30, 20, 30, 20));
      
            printDialog.PrintDocument(paginator, "Grid");
        }
Esempio n. 39
0
 private void btnPrint_Click(object sender, RoutedEventArgs e)
 {
     var dlg = new PrintDialog();
     if (dlg.ShowDialog() == true)
     {
         var paginator = new C1RichTextBoxPaginator(
                             rtb,
                             new Size(dlg.PrintableAreaWidth, dlg.PrintableAreaHeight),
                             new Thickness(40, 60, 40, 60) /* hardcoded margin */
                         );
         dlg.PrintDocument(paginator, "Test");
     }
 }
Esempio n. 40
0
 /// <summary>
 /// Executes the ShowModuleAViewCommand
 /// </summary>
 public void Execute(object parameter)
 {
     FontsClearup.FixRegistryFonts();
     PrintDialog printdialog1 = new PrintDialog();
     //if (PrinterOffline.GetPrinterStatusInt(Parameter.printname) != 0)
     //{
     //    string str = PrinterOffline.GetPrinterStatus(Parameter.printname);
     //    MessageBox.Show("提示", "打印机处于" + str + "状态!");
     //}
     //else
     //{
         printdialog1.PrintDocument(m_ViewModel.mydocument.DocumentPaginator, DateTime.Now.ToString("yyyyMMdd")+"报告");
     //}
 }
Esempio n. 41
0
        public void Print()
        {
            var print = new swc.PrintDialog();

            print.SetEtoSettings(PrintSettings);

            Control.PageSize = new sw.Size(print.PrintableAreaWidth, print.PrintableAreaHeight);
            var printCapabilities = print.PrintQueue.GetPrintCapabilities(print.PrintTicket);
            var ia = printCapabilities.PageImageableArea;

            Control.ImageableArea = new sw.Rect(ia.OriginWidth, ia.OriginHeight, ia.ExtentWidth, ia.ExtentHeight);
            //printCapabilities.PageImageableArea.OriginWidth, printCapabilities.PageImageableArea.OriginHeight
            print.PrintDocument(Control, Name);
        }
        private void btnPrintInvoke_Click(object sender, RoutedEventArgs e)
        {
            PrintDialog pDialog = new PrintDialog();
            pDialog.PageRangeSelection = PageRangeSelection.AllPages;
            pDialog.UserPageRangeEnabled = true;

            Nullable<Boolean> print = pDialog.ShowDialog();
            if (print == true)
            {
                XpsDocument xpsDocument = new XpsDocument("Entity.xps", FileAccess.ReadWrite);
                FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence();
                pDialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Test print job");
            }
        }
Esempio n. 43
0
        private void HyperLinkPrintLabel_Click(object sender, RoutedEventArgs e)
        {
            YellowstonePathology.Business.Test.PanelSetOrder panelSetOrder = this.m_AccessionOrder.PanelSetOrderCollection.GetPAP();
            YellowstonePathology.Business.OrderIdParser      orderIdParser = new Business.OrderIdParser(panelSetOrder.ReportNo);
            string dummyReportNo = (orderIdParser.ReportNoYear + 50).ToString() + "-" + orderIdParser.MasterAccessionNoNumber + "." + orderIdParser.ReportNoLetter;

            YellowstonePathology.UI.Login.CytologySlideLabelDocument cytologySlideLabelDocument = new Login.CytologySlideLabelDocument(dummyReportNo, this.m_AccessionOrder.PLastName, false);
            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();

            System.Printing.PrintServer printServer = new System.Printing.LocalPrintServer();
            System.Printing.PrintQueue  printQueue  = printServer.GetPrintQueue(YellowstonePathology.Business.User.UserPreferenceInstance.Instance.UserPreference.CytologySlideLabelPrinter);

            printDialog.PrintQueue = printQueue;
            printDialog.PrintDocument(cytologySlideLabelDocument.DocumentPaginator, "Slide Labels");
        }
Esempio n. 44
0
        private void ButtonTaskOrderPrint_Click(object sender, RoutedEventArgs e)
        {
            if (this.ListViewTaskOrders.SelectedItem != null)
            {
                YellowstonePathology.Business.Task.Model.TaskOrderView taskOrderView  = (YellowstonePathology.Business.Task.Model.TaskOrderView) this.ListViewTaskOrders.SelectedItem;
                YellowstonePathology.Business.Test.AccessionOrder      accessionOrder = YellowstonePathology.Business.Persistence.DocumentGateway.Instance.PullAccessionOrder(taskOrderView.TaskOrder.MasterAccessionNo, this.m_Writer);
                Login.Receiving.TaskOrderDataSheet taskOrderDataSheet = new Login.Receiving.TaskOrderDataSheet(taskOrderView.TaskOrder, accessionOrder);

                System.Printing.PrintQueue          printQueue  = new System.Printing.LocalPrintServer().DefaultPrintQueue;
                System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
                printDialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Portrait;
                printDialog.PrintQueue = printQueue;
                printDialog.PrintDocument(taskOrderDataSheet.FixedDocument.DocumentPaginator, "Task Order Data Sheet");
            }
        }
Esempio n. 45
0
        //http://shen7113.blog.fc2.com/blog-entry-50.html
        private void MyButton04_Click()
        {
            // 印刷ダイアログを作成。
            var dPrt = new System.Windows.Controls.PrintDialog();

            // 印刷ダイアログを表示して、プリンタ選択と印刷設定を行う。
            if (dPrt.ShowDialog() == true)
            {
                // ここから印刷を実行する。

                // 印刷可能領域を取得する。
                var area = dPrt.PrintQueue.GetPrintCapabilities().PageImageableArea;

                // 上と左の余白を含めた印刷可能領域の大きさのCanvasを作る。
                var canv = new Canvas();
                canv.Width  = area.OriginWidth + area.ExtentWidth;
                canv.Height = area.OriginHeight + area.ExtentHeight;

                // ここでCanvasに描画する。
                TextBlock tb = new TextBlock();
                tb.Text     = "sample02";
                tb.FontSize = 24;
                Canvas.SetTop(tb, 100);
                Canvas.SetLeft(tb, 100);
                canv.Children.Add(tb);

                /* ここで単ページのVisualを直接印刷する場合、PrintVisual()と言うメソッドもある。
                 * dPrt.PrintVisual(canv, "PrintTest1");
                 */

                // FixedPageを作って印刷対象(ここではCanvas)を設定する。
                var page = new FixedPage();
                page.Children.Add(canv);

                // PageContentを作ってFixedPageを設定する。
                var cont = new PageContent();
                cont.Child = page;

                // FixedDocumentを作ってPageContentを設定する。
                var doc = new FixedDocument();
                doc.Pages.Add(cont);

                // 印刷する。
                dPrt.PrintDocument(doc.DocumentPaginator, "Print1");
            }
        }
 public virtual void ExecutePrint(object parameter)
 {
     try
     {
         var printDialog = new System.Windows.Controls.PrintDialog();
         printDialog.PrintQueue  = CurrentPrinter;
         printDialog.PrintTicket = CurrentPrinter.UserPrintTicket;
         ShowProgressDialog();
         printDialog.PrintDocument(Paginator, "");
     }
     catch (Exception)
     {
     }
     finally
     {
         ProgressDialog.Hide();
     }
 }
        public void Print(FlowDocument fd)
        {
            var pd = new System.Windows.Controls.PrintDialog();

            if (pd.ShowDialog().Value)
            {
                IDocumentPaginatorSource document = fd as IDocumentPaginatorSource;
                try
                {
                    pd.PrintDocument(document.DocumentPaginator, "Printing FlowDocument.");
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
        private void ButtonPrintDataSheet_Click(object sender, RoutedEventArgs e)
        {
            if (this.m_AccessionOrder.PanelSetOrderCollection.Count > 0)
            {
                Business.Persistence.DocumentGateway.Instance.Save();
                YellowstonePathology.Document.Result.Data.AccessionOrderDataSheetData accessionOrderDataSheetData = YellowstonePathology.Business.Gateway.XmlGateway.GetAccessionOrderDataSheetData(this.m_AccessionOrder.MasterAccessionNo);
                YellowstonePathology.Document.Result.Xps.AccessionOrderDataSheet      accessionOrderDataSheet     = new Document.Result.Xps.AccessionOrderDataSheet(accessionOrderDataSheetData);
                System.Printing.PrintQueue printQueue = new System.Printing.LocalPrintServer().DefaultPrintQueue;

                System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
                printDialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Portrait;
                printDialog.PrintQueue = printQueue;
                printDialog.PrintDocument(accessionOrderDataSheet.FixedDocument.DocumentPaginator, "AccessionDataSheet");
            }
            else
            {
                MessageBox.Show("You must order something before the data sheet can be printed out.");
            }
        }
        /// <summary>
        /// Prints the report content.  This method is invoked by the PrintCommand.
        /// </summary>
        public void Print()
        {
            const double Inch = 96;

            // Create a PrintDialog
            System.Windows.Controls.PrintDialog printDlg = new System.Windows.Controls.PrintDialog();

            // Create IDocumentPaginatorSource from a copy of our flowdocument content
            MemoryStream stream         = new MemoryStream();
            TextRange    sourceDocument = new TextRange(Content.ContentStart, Content.ContentEnd);

            sourceDocument.Save(stream, System.Windows.DataFormats.Xaml);

            FlowDocument flowDocumentCopy  = new FlowDocument();
            TextRange    copyDocumentRange = new TextRange(flowDocumentCopy.ContentStart, flowDocumentCopy.ContentEnd);

            copyDocumentRange.Load(stream, System.Windows.DataFormats.Xaml);

            double xMargin = (1.25 * Inch);
            double yMargin = (1 * Inch);

            // Set the page padding
            flowDocumentCopy.PagePadding = new Thickness(yMargin, xMargin, xMargin, yMargin);

            IDocumentPaginatorSource idpSource = flowDocumentCopy;

            try
            {
                // Call PrintDocument method to send document to printer
                printDlg.PageRangeSelection   = PageRangeSelection.AllPages;
                printDlg.UserPageRangeEnabled = true;
                if (printDlg.ShowDialog() == true)
                {
                    printDlg.PrintDocument(idpSource.DocumentPaginator, Title);
                    this.OnRequestClose();
                }
            }
            catch (Exception printError)
            {
                WPFMessageBox.Show(Properties.Resources.Error_Encountered, Properties.Resources.CannotPrint + " " + printError.Message, WPFMessageBoxButtons.OK, WPFMessageBoxImage.Error);
            }
        }
Esempio n. 50
0
        private void ButtonDailyTaskOrderPrint_Click(object sender, RoutedEventArgs e)
        {
            if (this.ListViewDailyTaskOrders.SelectedItems.Count > 0)
            {
                YellowstonePathology.Business.Task.Model.TaskCytologySlideDisposal    taskCytologySlideDisposal    = new Business.Task.Model.TaskCytologySlideDisposal();
                YellowstonePathology.Business.Task.Model.TaskSurgicalSpecimenDisposal taskSurgicalSpecimenDisposal = new Business.Task.Model.TaskSurgicalSpecimenDisposal();
                YellowstonePathology.Business.Task.Model.TaskRetrospectiveReview      taskRetrospectiveReview      = new Business.Task.Model.TaskRetrospectiveReview();

                foreach (YellowstonePathology.Business.Task.Model.TaskOrder taskOrder in this.ListViewDailyTaskOrders.SelectedItems)
                {
                    if (taskOrder.TaskId == taskCytologySlideDisposal.TaskId)
                    {
                        YellowstonePathology.Business.Reports.CytologySlideDisposalReport report1 = new YellowstonePathology.Business.Reports.CytologySlideDisposalReport(taskOrder.TaskDate.Value);
                        System.Windows.Controls.PrintDialog printDialog1 = new System.Windows.Controls.PrintDialog();

                        printDialog1.ShowDialog();
                        printDialog1.PrintDocument(report1.Document.DocumentPaginator, "Cytology Slide Disposal");
                    }
                    else if (taskOrder.TaskId == taskSurgicalSpecimenDisposal.TaskId)
                    {
                        YellowstonePathology.Business.Reports.SurgicalSpecimenDisposalReport report2 = new YellowstonePathology.Business.Reports.SurgicalSpecimenDisposalReport(taskOrder.TaskDate.Value);
                        System.Windows.Controls.PrintDialog printDialog2 = new System.Windows.Controls.PrintDialog();
                        printDialog2.ShowDialog();
                        printDialog2.PrintDocument(report2.Document.DocumentPaginator, "Surgical Specimen Disposal Report for: ");
                    }
                    else if (taskOrder.TaskId == taskRetrospectiveReview.TaskId)
                    {
                        YellowstonePathology.Business.Reports.RetrospectiveReviewReport report = new YellowstonePathology.Business.Reports.RetrospectiveReviewReport(taskOrder.TaskDate.Value);
                        System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
                        printDialog.ShowDialog();
                        printDialog.PrintDocument(report.DocumentPaginator, "Retrospective Review");
                    }
                }
            }
            else
            {
                MessageBox.Show("Select a task to print.");
            }
        }
        public void PrintEButton_Click(object sender, RoutedEventArgs e)
        {
            //Method for printing table of employees
            int currentRow = 2;//Print method for the schedule

            System.Windows.Controls.PrintDialog printDlg = new System.Windows.Controls.PrintDialog();
            Nullable <bool> result = printDlg.ShowDialog();

            //Process print file dialog box results
            if (result == true)
            {
                FlowDocument fd = new FlowDocument();
                //Create a table to store all the values from datagrid
                Table table = new Table();
                fd.Blocks.Add(table);

                //Title of Page
                Paragraph t = new Paragraph(new Run("Current Employees"));
                //Set the font size and text alignment of the title of the page and add it
                t.FontSize      = 36;
                t.TextAlignment = TextAlignment.Center;

                //Create the Columns for the printed report
                string name  = "Name";
                string email = "Email";
                string shift = "Shift";


                table.RowGroups.Add(new TableRowGroup());
                table.RowGroups[0].Rows.Add(new TableRow());
                TableRow row = table.RowGroups[0].Rows[0];
                row.Cells.Add(new TableCell(t));
                row.Cells[0].Padding = new Thickness(0, 5, 0, 10);
                table.RowGroups[0].Rows.Add(new TableRow());
                row.Cells[0].ColumnSpan = 3;

                fd.ColumnWidth = printDlg.PrintableAreaWidth;
                fd.ColumnGap   = 10.0;

                //Create a new row for the column headers
                table.RowGroups[0].Rows.Add(new TableRow());
                row = table.RowGroups[0].Rows[1];

                //Create a new entry for name column and then position it correctly in the table
                Paragraph n = new Paragraph(new Run(name));
                row.Cells.Add(new TableCell(n));
                n.FontSize           = 24;
                row.Cells[0].Padding = new Thickness(0, 10, 0, 10);

                //Create a new entry for email column and then position it correctly in the table
                Paragraph em = new Paragraph(new Run(email));
                row.Cells.Add(new TableCell(em));
                row.Cells[1].Padding = new Thickness(0, 10, 0, 10);
                em.FontSize          = 24;

                //Create a new entry for shift column and then position it correctly in the table
                Paragraph s = new Paragraph(new Run(shift));
                row.Cells.Add(new TableCell(s));
                row.Cells[2].Padding = new Thickness(0, 10, 0, 10);
                s.FontSize           = 24;
                //Now add the data from the Listview
                table.RowGroups[0].Rows.Add(new TableRow());
                Paragraph u = new Paragraph();
                foreach (User item in Users.Items)
                {
                    string username = item.userName;
                    email = item.email;
                    shift = item.shift;

                    //If employee name is somehow empty, skip it
                    if (username.Length == 0)
                    {
                        continue;
                    }

                    table.RowGroups.Add(new TableRowGroup());
                    table.RowGroups[0].Rows.Add(new TableRow());
                    row = table.RowGroups[0].Rows[currentRow];

                    //Add each field to the cell in the table
                    row.Cells.Add(new TableCell(new Paragraph(new Run(username))));
                    row.Cells.Add(new TableCell(new Paragraph(new Run(email))));
                    row.Cells.Add(new TableCell(new Paragraph(new Run(shift))));

                    currentRow++;
                }

                fd.Name = "Employees";
                IDocumentPaginatorSource idpSource = fd;
                //printDlg.ShowDialog();
                printDlg.PrintDocument(idpSource.DocumentPaginator, "List of Employees");
            }
        }
Esempio n. 52
0
        private void Print()
        {
            // Create a PrintDialog
            System.Windows.Controls.PrintDialog dlg = new System.Windows.Controls.PrintDialog();

            FlowDocument doc = MainFlowReader.MonsterFlowReader.Document;

            //doc.PageHeight = dlg.PrintableAreaHeight;
            //doc.PageWidth = dlg.PrintableAreaWidth;

            double w = doc.ColumnWidth;

            doc.PageHeight = 11;

            //doc.ColumnGap = 1;

            //IDocumentPaginatorSource idpSource = MainFlow;

            dlg.PrintDocument(((IDocumentPaginatorSource)doc).DocumentPaginator, "XPSPrint");



            //var pageSize = new Size(8.26 * 96, 11.69 * 96); // A4 page, at 96 dpi
            //var document = new FixedDocument();
            //document.DocumentPaginator.PageSize = pageSize;

            //// Create FixedPage
            //var fixedPage = new FixedPage();
            //fixedPage.Width = pageSize.Width;
            //fixedPage.Height = pageSize.Height;
            //// Add visual, measure/arrange page.
            //fixedPage.Children.Add((UIElement)MainFlow);
            //fixedPage.Measure(pageSize);
            //fixedPage.Arrange(new Rect(new Point(), pageSize));
            //fixedPage.UpdateLayout();

            //// Add page to document
            //var pageContent = new PageContent();
            //((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage);
            //document.Pages.Add(pageContent);

            //// Send to the printer.
            //var pd = new System.Windows.Controls.PrintDialog();
            //pd.PrintDocument(document.DocumentPaginator, "My Document");

            //IDocumentPaginatorSource idpSource = MainFlow;
            //System.Windows.Controls.PrintDialog dlg = new System.Windows.Controls.PrintDialog();
            //// create a document
            //FixedDocument document = new FixedDocument();
            //document.DocumentPaginator.PageSize = new Size(dlg.PrintableAreaWidth, dlg.PrintableAreaHeight);

            //for (int i = 1; i < idpSource.DocumentPaginator.PageCount; i++)
            //{



            //    // create a page
            //    FixedPage page1 = new FixedPage();
            //    page1.Width = document.DocumentPaginator.PageSize.Width;
            //    page1.Height = document.DocumentPaginator.PageSize.Height;


            //    // add some text to the page
            //    TextBlock page1Text = new TextBlock();
            //    page1Text.Text = "This is the first page";
            //    page1Text.FontSize = 40; // 30pt text
            //    page1Text.Margin = new Thickness(96); // 1 inch margin
            //    //page1.Children.Add((UIElemnt)idpSource.DocumentPaginator.GetPage(i).Visual);
            //    // add the page to the document

            //    PageContent page1Content = new PageContent();
            //    //page1Content = (PageContent)idpSource.DocumentPaginator.GetPage(i);



            //    ((System.Windows.Markup.IAddChild)page1Content).AddChild(idpSource.DocumentPaginator.GetPage(i));
            //    document.Pages.Add(page1Content);


            //    i++;

            //    // do the same for the second page
            //    FixedPage page2 = new FixedPage();
            //    page2.Width = document.DocumentPaginator.PageSize.Width;
            //    page2.Height = document.DocumentPaginator.PageSize.Height;



            //    //TextBlock page2Text = new TextBlock();
            //    //page2Text.Text = "This is NOT the first page";
            //    //page2Text.FontSize = 40;
            //    //page2Text.Margin = new Thickness(96);
            //    //page2.Children.Add(page2Text);
            //    PageContent page2Content = new PageContent();
            //    ((System.Windows.Markup.IAddChild)page2Content).AddChild(idpSource.DocumentPaginator.GetPage(i));
            //    document.Pages.Add(page2Content);
            //    // and print
            //    dlg.PrintDocument(document.DocumentPaginator, "My first document");
            //}



            //System.Windows.Controls.PrintDialog dlg = new System.Windows.Controls.PrintDialog();

            //// create a document
            //FixedDocument document = new FixedDocument();
            //document.DocumentPaginator.PageSize = new Size(dlg.PrintableAreaWidth, dlg.PrintableAreaHeight);

            //// create a page
            //FixedPage page1 = new FixedPage();
            //page1.Width = document.DocumentPaginator.PageSize.Width;
            //page1.Height = document.DocumentPaginator.PageSize.Height;

            //// add some text to the page
            //TextBlock page1Text = new TextBlock();
            //page1Text.Text = "This is the first page";
            //page1Text.FontSize = 40; // 30pt text
            //page1Text.Margin = new Thickness(96); // 1 inch margin
            //page1.Children.Add(page1Text);
            //// add the page to the document
            //PageContent page1Content = new PageContent();
            //((System.Windows.Markup.IAddChild)page1Content).AddChild(page1);
            //document.Pages.Add(page1Content);

            //// do the same for the second page
            //FixedPage page2 = new FixedPage();
            //page2.Width = document.DocumentPaginator.PageSize.Width;
            //page2.Height = document.DocumentPaginator.PageSize.Height;
            //TextBlock page2Text = new TextBlock();
            //page2Text.Text = "This is NOT the first page";
            //page2Text.FontSize = 40;
            //page2Text.Margin = new Thickness(96);
            //page2.Children.Add(page2Text);
            //PageContent page2Content = new PageContent();
            //((System.Windows.Markup.IAddChild)page2Content).AddChild(page2);
            //document.Pages.Add(page2Content);
            //// and print
            //dlg.PrintDocument(document.DocumentPaginator, "My first document");



            //IDocumentPaginatorSource idpSource = MainFlow;
            //System.Windows.Controls.PrintDialog dlg = new System.Windows.Controls.PrintDialog();
            //// create a document



            //if ((bool)dlg.ShowDialog().GetValueOrDefault())
            //{
            //    for (int i = 0; i < MainFlowReader.Document.Blocks.Count - 1; i++)
            //    {
            //        MainFlowReader.Document.Blocks.ElementAt(i).BringIntoView();

            //        Size pageSize = new Size(dlg.PrintableAreaWidth, dlg.PrintableAreaHeight);
            //        MainFlowReader.Measure(pageSize);
            //        MainFlowReader.Arrange(new Rect(5, 5, pageSize.Width, pageSize.Height));

            //        dlg.PrintVisual(MainFlowReader, "XPSPrint" + i.ToString());
            //    }

            //   // dlg.PrintVisual(MainFlowReader, "XPSPrint");

            //}



            //IDocumentPaginatorSource idpSource = MainFlow;

            //idpSource.DocumentPaginator.PageSize = pageSize;

            //dlg.PrintDocument(idpSource.DocumentPaginator, "XPSPrint");
            //dlg.PrintVisual(MainFlowReader, "XPSPrint");
        }
Esempio n. 53
0
        //private FlowDocument m_doc;
        private void bt_printClick(object sender, RoutedEventArgs e)
        {
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load("Result/config.xml");
                XmlNode xn = xmlDoc.SelectSingleNode("items/szdy");

                if (xn.InnerXml == "1")
                {
                    if (this.dg_ShowUserinfor.SelectedItem != null)
                    {
                        User user = this.dg_ShowUserinfor.SelectedItem as User;
                        str_userID = user.id;
                        string sql = "select * from EHR_Arch_OldHerb where ID = '" + str_userID + "'";
                        DBhelp.writelog(sql);
                        DataSet datat = DBhelp.GetDataSet(sql);

                        int i = 0;

                        string ID                 = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ID"]);
                        string ARCHIVEID          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ARCHIVEID"]);
                        string IDENTITYNO         = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["IDENTITYNO"]);
                        string SERVICEID          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["SERVICEID"]);
                        string SERVICENAME        = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["SERVICENAME"]);
                        string FULLNAME           = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["FULLNAME"]);
                        string ISENERGETI         = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISENERGETI"]));
                        string ISTIRED            = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISTIRED"]));
                        string ISLOSEHEART        = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISLOSEHEART"]));
                        string ISDEEPVOICE        = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISDEEPVOICE"]));
                        string ISLISTLESS         = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISLISTLESS"]));
                        string ISJITTER           = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISJITTER"]));
                        string ISALONE            = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISALONE"]));
                        string ISSCARE            = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSCARE"]));
                        string ISHEAVY            = strTosnum34(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISHEAVY"]));
                        string ISEYEDRY           = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISEYEDRY"]));
                        string ISEXTRECOLD        = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISEXTRECOLD"]));
                        string ISAFAIDCOLD        = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISAFAIDCOLD"]));
                        string ISRESISTCOLD       = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISRESISTCOLD"]));
                        string ISCATCHCOLD        = strTosnum35(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISCATCHCOLD"]));
                        string ISSNORTY           = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSNORTY"]));
                        string ISSTERTOROUS       = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSTERTOROUS"]));
                        string ISALLERGIC         = strTosnum36(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISALLERGIC"]));
                        string ISHIVES            = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISHIVES"]));
                        string ISENDERMICBLOOD    = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISENDERMICBLOOD"]));
                        string ISSCORE            = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSCORE"]));
                        string ISFEVERDRY         = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISFEVERDRY"]));
                        string ISBODYPAIN         = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISBODYPAIN"]));
                        string ISFACELIGHT        = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISFACELIGHT"]));
                        string ISFLECK            = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISFLECK"]));
                        string ISTETTER           = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISTETTER"]));
                        string ISLIKEDRINK        = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISLIKEDRINK"]));
                        string ISMOUTHBITTER      = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISMOUTHBITTER"]));
                        string IFFAT              = strTosnum37(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["IFFAT"]));
                        string ISSCARECOLDFOOD    = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSCARECOLDFOOD"]));
                        string ISSTOOLSTICK       = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSTOOLSTICK"]));
                        string ISSTOOLDRY         = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISSTOOLDRY"]));
                        string ISLINGUAMASSIN     = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISLINGUAMASSIN"]));
                        string ISLINGUAVEIN       = strTosnum33(DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["ISLINGUAVEIN"]));
                        string PHYSIQUE_QXZ       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_QXZ"]);
                        string PHYSIQUE_YANGXZ    = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_YANGXZ"]);
                        string PHYSIQUE_YINXZ     = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_YINXZ"]);
                        string PHYSIQUE_TSZ       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_TSZ"]);
                        string PHYSIQUE_SRZ       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_SRZ"]);
                        string PHYSIQUE_XYZ       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_XYZ"]);
                        string PHYSIQUE_QYZ       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_QYZ"]);
                        string PHYSIQUE_TBZ       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_TBZ"]);
                        string PHYSIQUE_PHZ       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHYSIQUE_PHZ"]);
                        string REPORTDATE         = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["REPORTDATE"]);
                        string REPORTDOC          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["REPORTDOC"]);
                        string STATUS             = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["STATUS"]);
                        string CREATED_BY         = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["CREATED_BY"]);
                        string CREATED_DATE       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["CREATED_DATE"]);
                        string UPDATED_BY         = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["UPDATED_BY"]);
                        string UPDATED_DATE       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["UPDATED_DATE"]);
                        string DISABLED_BY        = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["DISABLED_BY"]);
                        string DUNS               = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["DUNS"]);
                        string DISABLED_DATE      = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["DISABLED_DATE"]);
                        string QXZ_SCORE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["QXZ_SCORE"]);
                        string YANGXZ_SCORE       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["YANGXZ_SCORE"]);
                        string YINXZ_SCORE        = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["YINXZ_SCORE"]);
                        string TSZ_SCORE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["TSZ_SCORE"]);
                        string SRZ_SCORE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["SRZ_SCORE"]);
                        string XYZ_SCORE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["XYZ_SCORE"]);
                        string QYZ_SCORE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["QYZ_SCORE"]);
                        string TBZ_SCORE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["TBZ_SCORE"]);
                        string PHZ_SCORE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHZ_SCORE"]);
                        string QXZ_GUIDE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["QXZ_GUIDE"]);
                        string YANGXZ_GUIDE       = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["YANGXZ_GUIDE"]);
                        string YINXZ_GUIDE        = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["YINXZ_GUIDE"]);
                        string TSZ_GUIDE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["TSZ_GUIDE"]);
                        string SRZ_GUIDE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["SRZ_GUIDE"]);
                        string XYZ_GUIDE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["XYZ_GUIDE"]);
                        string QYZ_GUIDE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["QYZ_GUIDE"]);
                        string TBZ_GUIDE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["TBZ_GUIDE"]);
                        string PHZ_GUIDE          = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHZ_GUIDE"]);
                        string QXZ_GUIDE_OTHER    = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["QXZ_GUIDE_OTHER"]);
                        string YANGXZ_GUIDE_OTHER = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["YANGXZ_GUIDE_OTHER"]);
                        string YINXZ_GUIDE_OTHER  = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["YINXZ_GUIDE_OTHER"]);
                        string TSZ_GUIDE_OTHER    = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["TSZ_GUIDE_OTHER"]);
                        string SRZ_GUIDE_OTHER    = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["SRZ_GUIDE_OTHER"]);
                        string XYZ_GUIDE_OTHER    = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["XYZ_GUIDE_OTHER"]);
                        string QYZ_GUIDE_OTHER    = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["QYZ_GUIDE_OTHER"]);
                        string TBZ_GUIDE_OTHER    = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["TBZ_GUIDE_OTHER"]);
                        string PHZ_GUIDE_OTHER    = DBhelp.ObjectToString(datat.Tables["Table"].Rows[i]["PHZ_GUIDE_OTHER"]);

                        string  sql1    = "select docname from EHR_His_doc where card_id = '" + REPORTDOC + "'";
                        DataSet doc     = DBhelp.GetDataSet(sql1);
                        string  docname = DBhelp.ObjectToString(doc.Tables["Table"].Rows[0]["docname"]);
                        DBhelp.writelog(docname);

                        string str1 = ID + "$" + ARCHIVEID + "$" + IDENTITYNO + "$" + SERVICEID + "$" + SERVICENAME + "$" + FULLNAME + "$" + ISENERGETI + "$" + ISTIRED + "$" + ISLOSEHEART + "$" + ISDEEPVOICE + "$" + ISLISTLESS + "$" + ISJITTER + "$" + ISALONE + "$" + ISSCARE + "$" + ISHEAVY + "$" + ISEYEDRY + "$" + ISEXTRECOLD + "$" + ISAFAIDCOLD + "$" + ISRESISTCOLD + "$" + ISCATCHCOLD + "$" + ISSNORTY + "$" + ISSTERTOROUS + "$" + ISALLERGIC + "$" + ISHIVES + "$" + ISENDERMICBLOOD + "$" + ISSCORE + "$" + ISFEVERDRY + "$" + ISBODYPAIN + "$" + ISFACELIGHT;
                        string str2 = ISFLECK + "$" + ISTETTER + "$" + ISLIKEDRINK + "$" + ISMOUTHBITTER + "$" + IFFAT + "$" + ISSCARECOLDFOOD + "$" + ISSTOOLSTICK + "$" + ISSTOOLDRY + "$" + ISLINGUAMASSIN + "$" + ISLINGUAVEIN + "$" + QXZ_SCORE + "$" + YANGXZ_SCORE + "$" + YINXZ_SCORE + "$" + TSZ_SCORE + "$" + SRZ_SCORE + "$" + XYZ_SCORE + "$" + QYZ_SCORE + "$" + TBZ_SCORE + "$" + PHZ_SCORE + "$" + REPORTDATE + "$" + docname + "$" + PHYSIQUE_QXZ + "$" + PHYSIQUE_YANGXZ + "$" + PHYSIQUE_YINXZ + "$" + PHYSIQUE_TSZ + "$" + PHYSIQUE_SRZ + "$" + PHYSIQUE_XYZ + "$" + PHYSIQUE_QYZ + "$" + PHYSIQUE_TBZ + "$" + PHYSIQUE_PHZ;
                        ;

                        //DBhelp.writelog(str1);
                        //DBhelp.writelog(str2);
                        //  m_doc = LoadDocumentAndRender("OrderDocument.xaml", tabPage);
                        //OrderDocument orderDoc = (OrderDocument)m_doc;
                        //string strPath = FileHelper.SaveXPS(m_doc, false, "w2");
                        //XpsDocument xpsDocument = new XpsDocument(strPath, FileAccess.Read);

                        //FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence();
                        System.Windows.Controls.PrintDialog dialog = new System.Windows.Controls.PrintDialog();
                        dialog.PrintQueue = LocalPrintServer.GetDefaultPrintQueue();

                        //dialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Test print");
                        //xpsDocument.Close();

                        //string qustionstrs1 = "201605186110240000202$612525195001181417$58$男$15463216531$苗留成$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1";
                        H_Print_trouble h_pr = new H_Print_trouble(str1);

                        string      strPath1     = FileHelper.SaveXPS1(h_pr.printArea, false, "w2");
                        XpsDocument xpsDocument1 = new XpsDocument(strPath1, FileAccess.Read);

                        FixedDocumentSequence fixedDocSeq1 = xpsDocument1.GetFixedDocumentSequence();

                        System.Windows.Controls.PrintDialog dialog1 = new System.Windows.Controls.PrintDialog();
                        dialog1.PrintQueue = LocalPrintServer.GetDefaultPrintQueue();
                        dialog1.PrintDocument(fixedDocSeq1.DocumentPaginator, FULLNAME + "");
                        xpsDocument1.Close();



                        //string qustionstrs2 = "1$1$1$1$1$1$1$1$1$1$4$4$4$4$4$4$4$4$21$2017/4/17$612525195001181417$$$$$SX0088_1$$$$SX0401_1";
                        H_Print_trouble1      h_pr1                 = new H_Print_trouble1(str2);
                        string                strPath2              = FileHelper.SaveXPS1(h_pr1.p2, false, "w2");
                        XpsDocument           xpsDocument2          = new XpsDocument(strPath2, FileAccess.Read);
                        FixedDocumentSequence fixedDocSeq2          = xpsDocument2.GetFixedDocumentSequence();
                        System.Windows.Controls.PrintDialog dialog2 = new System.Windows.Controls.PrintDialog();
                        dialog2.PrintQueue = LocalPrintServer.GetDefaultPrintQueue();
                        dialog2.PrintDocument(fixedDocSeq2.DocumentPaginator, FULLNAME + "_2");
                        xpsDocument2.Close();



                        H_Print_trouble       arv          = new H_Print_trouble(str1);
                        string                strPath      = FileHelper.SaveXPS1(arv.printArea, false, "w2");
                        XpsDocument           xpsDocument  = new XpsDocument(strPath, FileAccess.Read);
                        FixedDocumentSequence fixedDocSeq  = xpsDocument.GetFixedDocumentSequence();
                        RenderTargetBitmap    targetBitmap = new RenderTargetBitmap(1240, 1750, 150d, 150d, PixelFormats.Pbgra32);
                        targetBitmap.Render(arv.printArea);
                        PngBitmapEncoder encoder = new PngBitmapEncoder();
                        encoder.Frames.Add(BitmapFrame.Create(targetBitmap));
                        FileStream fs = File.Open(System.AppDomain.CurrentDomain.BaseDirectory + @"\Result\" + FULLNAME + "_1.png", FileMode.Create);
                        encoder.Save(fs);
                        fs.Close();
                        xpsDocument.Close();

                        H_Print_trouble1 arv1 = new H_Print_trouble1(str2);
                        strPath      = FileHelper.SaveXPS1(arv1.p2, false, "w2");
                        xpsDocument  = new XpsDocument(strPath, FileAccess.Read);
                        fixedDocSeq  = xpsDocument.GetFixedDocumentSequence();
                        targetBitmap = new RenderTargetBitmap(1240, 1750, 150d, 150d, PixelFormats.Pbgra32);
                        targetBitmap.Render(arv1.p2);
                        encoder = new PngBitmapEncoder();
                        encoder.Frames.Add(BitmapFrame.Create(targetBitmap));
                        fs = File.Open(System.AppDomain.CurrentDomain.BaseDirectory + @"\Result\" + FULLNAME + "_2.png", FileMode.Create);
                        encoder.Save(fs);
                        fs.Close();
                        xpsDocument.Close();
                    }
                    else
                    {
                        MessageBox.Show("请选择要打印人员!!");
                    }
                }

                //IsUserInforShowPrint = false ;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void PrintSButton_Click(object sender, RoutedEventArgs e)
        {
            //Print method for the schedule
            int currentRow = 2;

            System.Windows.Controls.PrintDialog printDlg = new System.Windows.Controls.PrintDialog();
            Nullable <bool> result = printDlg.ShowDialog();

            //Process print file dialog box results
            if (result == true)
            {
                FlowDocument fd = new FlowDocument();
                //Create a table to store all the values from datagrid
                Table table = new Table();
                fd.Blocks.Add(table);

                //Title of Page
                Paragraph t = new Paragraph(new Run("Today's Schedule"));
                //Set the font size and text alignment of the title of the page and add it
                t.FontSize      = 36;
                t.TextAlignment = TextAlignment.Center;

                //Create the Columns for the printed report
                string name  = "Name";
                string shift = "Shift";
                string role  = "Role";


                table.RowGroups.Add(new TableRowGroup());
                table.RowGroups[0].Rows.Add(new TableRow());
                TableRow row = table.RowGroups[0].Rows[0];
                row.Cells.Add(new TableCell(t));
                row.Cells[0].Padding = new Thickness(0, 5, 0, 10);
                table.RowGroups[0].Rows.Add(new TableRow());
                row.Cells[0].ColumnSpan = 3;

                fd.ColumnWidth = printDlg.PrintableAreaWidth;
                fd.ColumnGap   = 10.0;

                //Create a new row for the column headers
                table.RowGroups[0].Rows.Add(new TableRow());
                row = table.RowGroups[0].Rows[1];

                //Create a new entry for name column and then position it correctly in the table
                Paragraph n = new Paragraph(new Run(name));
                row.Cells.Add(new TableCell(n));
                n.FontSize           = 24;
                row.Cells[0].Padding = new Thickness(0, 10, 0, 10);

                //Create a new entry for shift column and then position it correctly in the table
                Paragraph s = new Paragraph(new Run(shift));
                row.Cells.Add(new TableCell(s));
                row.Cells[1].Padding = new Thickness(0, 10, 0, 10);
                s.FontSize           = 24;

                //Create a new entry for role column and then position it correctly in the table
                Paragraph r = new Paragraph(new Run(role));
                row.Cells.Add(new TableCell(r));
                row.Cells[2].Padding = new Thickness(0, 10, 0, 10);
                r.FontSize           = 24;
                //Now add the data from the Listview
                table.RowGroups[0].Rows.Add(new TableRow());
                Paragraph u = new Paragraph();

                foreach (DataRowView item in schedule.ItemsSource)
                {
                    //Get the name, shift, and role from the datagrid
                    string employeeName = (string)item[0];
                    shift = (string)item[1];
                    role  = (string)item[2];
                    //If employee name is somehow empty, skip it
                    if (employeeName.Length == 0)
                    {
                        continue;
                    }

                    table.RowGroups.Add(new TableRowGroup());
                    table.RowGroups[0].Rows.Add(new TableRow());
                    row = table.RowGroups[0].Rows[currentRow];

                    //Add each field to the cell in the table
                    row.Cells.Add(new TableCell(new Paragraph(new Run(employeeName))));
                    row.Cells.Add(new TableCell(new Paragraph(new Run(shift))));
                    row.Cells.Add(new TableCell(new Paragraph(new Run(role))));

                    currentRow++;
                }
                fd.Name = "Schedule";
                IDocumentPaginatorSource idpSource = fd;
                //Print the dialog to the specific location
                printDlg.PrintDocument(idpSource.DocumentPaginator, "Today's Schedule");
            }
        }