Exemple #1
0
        /// <summary>
        /// Prints a graph over several pages, if necessary
        /// </summary>
        /// <param name="pd"></param>
        public void Print(PrintDialog pd)
        {
            pd.PrintTicket.PageOrientation = (DotGraph.ActualWidth > DotGraph.ActualHeight) ? PageOrientation.Landscape : PageOrientation.Portrait;
            Size           s         = new Size(pd.PrintableAreaWidth, pd.PrintableAreaHeight);
            GraphPaginator paginator = new GraphPaginator(DotGraph.Graph, s);

            try
            {
                pd.PrintDocument(paginator, "PAMainWindow");
            }
            catch (PrintSystemException x)
            {
                MessageBox.Show(x.Message, "PAMainWindow");
            }
        }
        protected override void OnPrintCommand()
        {
            // get a print dialog, defaulted to default printer and default printer's preferences.
            PrintDialog printDialog = new PrintDialog();

            printDialog.PrintQueue  = m_PrintQueue;
            printDialog.PrintTicket = m_PrintTicket;

            if (printDialog.ShowDialog() == true)
            {
                m_PrintQueue  = printDialog.PrintQueue;
                m_PrintTicket = printDialog.PrintTicket;
                printDialog.PrintDocument(this.Document.DocumentPaginator, "PrintPreviewJob");
            }
        }
        void OnPrint(object sender, ExecutedRoutedEventArgs e)
        {
            PrintDialog printDialog = PrintPreviewViewContent.PrintDialog;

            if (printDialog.ShowDialog() == true)
            {
                FlowDocument fd = DocumentPrinter.CreateFlowDocumentForEditor(this);
                fd.ColumnGap   = 0;
                fd.ColumnWidth = printDialog.PrintableAreaWidth;
                fd.PageHeight  = printDialog.PrintableAreaHeight;
                fd.PageWidth   = printDialog.PrintableAreaWidth;
                IDocumentPaginatorSource doc = fd;
                printDialog.PrintDocument(doc.DocumentPaginator, Path.GetFileName(this.FileName));
            }
        }
        private void Print_Click(object sender, RoutedEventArgs e)
        {
            PrintDialog printDialog = new PrintDialog
            {
                SelectedPagesEnabled = true,
                UserPageRangeEnabled = true
            };

            FlowDocument document = A4Page;

            if (printDialog.ShowDialog() == true)
            {
                printDialog.PrintDocument(((IDocumentPaginatorSource)document).DocumentPaginator, "Matrix Document");
            }
        }
Exemple #5
0
        /// <summary>
        /// Prints the content of a <see cref="RichTextBox"/>.
        /// </summary>
        /// <param name="richTextBox">
        /// The <see cref="RichTextBox"/> which holds the content.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// The parameters was passed as null.
        /// </exception>
        public static async Task PrintCodeAsync(RichTextBox richTextBox)
        {
            if (richTextBox == null)
            {
                throw new ArgumentNullException("richTextBox");
            }

            var printDialog = new PrintDialog();

            if (printDialog.ShowDialog() == true)
            {
                ////printDialog.PrintVisual(richTextBox, "PER PseudoCode");
                printDialog.PrintDocument(((IDocumentPaginatorSource)richTextBox.Document).DocumentPaginator, "PER PseudoCode");
            }
        }
Exemple #6
0
        public void printDocument(StringBuilder Text)
        {
            PrintDialog  pd = new PrintDialog();
            FlowDocument fd = new FlowDocument(new Paragraph(new Run(Text.ToString())));

            fd.Name        = "GroupMembers";
            fd.PagePadding = new Thickness(40);

            IDocumentPaginatorSource idpSource = fd;

            if (pd.ShowDialog().GetValueOrDefault(false))
            {
                pd.PrintDocument(idpSource.DocumentPaginator, "Group Members");
            }
        }
Exemple #7
0
        private void but_PrintChallan_Click(object sender, RoutedEventArgs e)
        {
            PrintDialog  printDialog = new PrintDialog();
            FlowDocument flowDoc     = challanPageRef.doc;

            flowDoc.PageHeight  = 11.7 * 96;
            flowDoc.PageWidth   = 8.5 * 96;
            flowDoc.ColumnWidth = printDialog.PrintableAreaWidth;
            flowDoc.PagePadding = new Thickness(50);
            if (printDialog.ShowDialog() == true)
            {
                IDocumentPaginatorSource dps = flowDoc;
                printDialog.PrintDocument(dps.DocumentPaginator, "doc");
            }
        }
        public void Print_Document()
        {
            try
            {
                PrintDialog printDialog = new PrintDialog();
                printDialog.PrintQueue  = LocalPrintServer.GetDefaultPrintQueue();
                printDialog.PrintTicket = printDialog.PrintQueue.DefaultPrintTicket;
                printDialog.PrintTicket.PageOrientation   = _pageOrientation;
                printDialog.PrintTicket.PageScalingFactor = 100;
                printDialog.PrintTicket.PageMediaSize     = new PageMediaSize(PageMediaSizeName.ISOA4);
                printDialog.PrintTicket.PageBorderless    = PageBorderless.None;
                printDialog.PageRangeSelection            = PageRangeSelection.AllPages;
                printDialog.UserPageRangeEnabled          = true;
                printDialog.CurrentPageEnabled            = true;

                printDialog.PrintTicket.PageResolution = new PageResolution(PageQualitativeResolution.High);
                if (printDialog.ShowDialog() == true)
                {
                    if (printDialog.PrintQueue.FullName == "Microsoft XPS Document Writer")
                    {
                        MessageWindow.Show("\"Microsoft XPS Document Writer\" not supported!!");
                        return;
                    }

                    DocumentViewer    viewer    = PrintView;
                    DocumentPaginator paginator = _fixedDocument.DocumentPaginator;
                    if (printDialog.PageRangeSelection == PageRangeSelection.UserPages)
                    {
                        paginator = new PageRangeDocumentPaginator(
                            _fixedDocument.DocumentPaginator,
                            printDialog.PageRange);
                    }
                    else if (printDialog.PageRangeSelection == PageRangeSelection.CurrentPage)
                    {
                        paginator = new CurrentPageDocumentPaginator(
                            _fixedDocument.DocumentPaginator,
                            PrintView.MasterPageNumber);
                    }
                    _fixedDocument.PrintTicket = printDialog.PrintTicket;
                    _documentName = _documentName.Replace("/", "-");
                    printDialog.PrintDocument(paginator, _documentName);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
        private void printDocument()
        {
            PrintDialog printDialog = new PrintDialog();

            bool?result = printDialog.ShowDialog();

            if (result == true)
            {
                double docWidth  = printDialog.PrintableAreaWidth;
                double docHeight = printDialog.PrintableAreaHeight;

                FlowDocument document = new FlowDocument();
                document.Background = Brushes.White;
                Section main = new Section();
                main.FontSize        = docWidth / A4_WIDTH * 10.5;
                main.FontFamily      = new FontFamily("Courier New");
                main.FontStretch     = FontStretches.UltraExpanded;
                document.PagePadding = new Thickness(docWidth / A4_WIDTH * MARGIN_WIDTH, docWidth / A4_WIDTH * MARGIN_HEIGHT, docWidth / A4_WIDTH * MARGIN_WIDTH, docWidth / A4_WIDTH * MARGIN_HEIGHT);
                List <String> text = new List <String>();

                foreach (List <BrailleSymbolSlotPosition> line in this._editor.Symbols)
                {
                    string txtLine = "";
                    foreach (BrailleSymbolSlotPosition s in line)
                    {
                        txtLine += s.Symbol.DisplayLettter;
                    }
                    text.Add(txtLine);
                }

                foreach (string line in text)
                {
                    Paragraph p = new Paragraph(new Run(line));
                    p.Margin               = new Thickness(0);
                    p.LineHeight           = docWidth / A4_WIDTH * 10.25;
                    p.LineStackingStrategy = LineStackingStrategy.BlockLineHeight;
                    main.Blocks.Add(p);
                }
                document.Blocks.Add(main);
                document.PageHeight = docHeight;
                document.PageWidth  = docWidth;

                document.ColumnGap   = 0;
                document.ColumnWidth = printDialog.PrintableAreaWidth;
                IDocumentPaginatorSource idpSource = document;
                printDialog.PrintDocument(idpSource.DocumentPaginator, "Braille");
            }
        }
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            PrintDialog pd = new PrintDialog();

            pd.PageRangeSelection   = PageRangeSelection.AllPages;
            pd.UserPageRangeEnabled = true;

            bool?ok = pd.ShowDialog();

            if (ok == true)
            {
                XpsDocument           doc = new XpsDocument(@"C:\demo.xps", FileAccess.Read);
                FixedDocumentSequence fds = doc.GetFixedDocumentSequence();
                pd.PrintDocument(fds.DocumentPaginator, "Demo #1");
            }
        }
Exemple #11
0
        public static void PrintDataViewer(DataPresenterViewModel vm, DataGrid grid)
        {
            PrintDialog printDialog = new PrintDialog();

            if (printDialog.ShowDialog() == false)
            {
                return;
            }

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

            CustomDataGridDocumentPaginator paginator = new CustomDataGridDocumentPaginator(grid, documentTitle, pageSize, new Thickness(30, 20, 30, 20));

            printDialog.PrintDocument(paginator, "Grid");
        }
Exemple #12
0
        public bool Print()
        {
            PrintDialog dlg = new PrintDialog();

            if (dlg.ShowDialog() == true)
            {
                PrintQueue        printQueue = dlg.PrintQueue;
                DocumentPaginator paginator  = GetPaginator(
                    printQueue.UserPrintTicket.PageMediaSize.Width.Value,
                    printQueue.UserPrintTicket.PageMediaSize.Height.Value
                    );
                dlg.PrintDocument(paginator, "TextEditor Printing");
                return(true);
            }
            return(false);
        }
Exemple #13
0
        private void Print_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            PrintDialog pDialog = new PrintDialog();

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

            bool?print = pDialog.ShowDialog();

            if (print == true)
            {
                XpsDocument           xpsDocument = new XpsDocument("C:\\FixedDocumentSequence.xps", FileAccess.ReadWrite);
                FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence();
                pDialog.PrintDocument(fixedDocSeq.DocumentPaginator, "打印任务");
            }
        }
Exemple #14
0
        private void PrintFile()
        {
            PrintDialog printDialog = new PrintDialog();

            printDialog.UserPageRangeEnabled = true;
            printDialog.SelectedPagesEnabled = true;
            printDialog.CurrentPageEnabled   = true;
            printDialog.SelectedPagesEnabled = true;

            if (printDialog.ShowDialog() == true)
            {
                FlowDocument             doc       = new FlowDocument(new Paragraph(new Run(Document.ActiveDocument.Scintilla.Text)));
                IDocumentPaginatorSource idpSource = doc;
                printDialog.PrintDocument(idpSource.DocumentPaginator, "Printing...");
            }
        }
Exemple #15
0
        private void PrintButtonClick(object sender, RoutedEventArgs e)
        {
            PrintDialog print = new PrintDialog();

            if (print.ShowDialog() != true)
            {
                return;
            }

            flowDocument.PageHeight = print.PrintableAreaHeight;
            flowDocument.PageWidth  = print.PrintableAreaWidth;

            var document = flowDocument as IDocumentPaginatorSource;

            print.PrintDocument(document.DocumentPaginator, "Printing");
        }
Exemple #16
0
        void PrintOnClick(object sender, RoutedEventArgs args)
        {
            PrintDialog dlg = new PrintDialog();

            if (dlg.ShowDialog().GetValueOrDefault())
            {
                PrintTicket prntkt = dlg.PrintTicket;
                prntkt.PageOrientation = PageOrientation.Portrait;
                dlg.PrintTicket        = prntkt;

                BannerDocumentPaginator paginator = new BannerDocumentPaginator();
                paginator.Text     = txtbox.Text;
                paginator.PageSize = new Size(dlg.PrintableAreaWidth, dlg.PrintableAreaHeight);
                dlg.PrintDocument(paginator, "Banner: " + txtbox.Text);
            }
        }
        protected override void OnPrintCommand()
        {
            // get a print dialog, defaulted to default printer and default printer's preferences.
            PrintDialog printDialog = new PrintDialog(); //Owner is always Application.Current.WMainWindow :(

            printDialog.PrintQueue  = m_PrintQueue;
            printDialog.PrintTicket = m_PrintTicket;

            if (printDialog.ShowDialog() == true)
            {
                m_PrintQueue  = printDialog.PrintQueue;
                m_PrintTicket = printDialog.PrintTicket;

                printDialog.PrintDocument(Document.DocumentPaginator, "PrintPreviewJob");
            }
        }
        private void ButtonPrintGroceryList_Click(object sender, RoutedEventArgs e)
        {
            var printDlg = new PrintDialog();

            var userCancelled = !printDlg.ShowDialog().Value;

            if (userCancelled)
            {
                return;
            }

            IDocumentPaginatorSource doc = richTxtBoxGroceryList.Document;

            printDlg.PrintDocument(doc.DocumentPaginator,
                                   "Recipe Helper - Print Grocery List");
        }
        /// <summary>
        /// Print
        /// </summary>
        /// <param name="flowDocument"></param>
        public void Print(FlowDocument flowDocument)
        {
            PrintDialog printDialog = new PrintDialog();

            if (printDialog.ShowDialog() != true)
            {
                return;
            }

            flowDocument.PageHeight = printDialog.PrintableAreaHeight;
            flowDocument.PageWidth  = printDialog.PrintableAreaWidth;

            IDocumentPaginatorSource idocument = flowDocument as IDocumentPaginatorSource;

            printDialog.PrintDocument(idocument.DocumentPaginator, "Printing ...");
        }
Exemple #20
0
        public void TestPrint() //without selecting printer
        {
            //Create a PrintDialog
            PrintDialog printDlg = new PrintDialog();

            // Create a FlowDocument dynamically
            FlowDocument doc = new FlowDocument(new Paragraph(new Run("Here is some Text.")));

            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");
        }
Exemple #21
0
        //
        // ToolStripButton Print wurde gedrückt
        //
        private void ToolStripButtonPrint_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            // Configure printer dialog box
            PrintDialog dlg = new PrintDialog();

            dlg.PageRangeSelection   = PageRangeSelection.AllPages;
            dlg.UserPageRangeEnabled = true;

            // Show and process save file dialog box results
            if (dlg.ShowDialog() == true)
            {
                //use either one of the below
                // dlg.PrintVisual(RichTextControl as Visual, "printing as visual");
                dlg.PrintDocument((((IDocumentPaginatorSource)RichTextControl.Document).DocumentPaginator), "printing as paginator");
            }
        }
        public void OnPrint(object param)
        {
            PrintDialog printDialog = new PrintDialog();

            if (printDialog.ShowDialog().Value)
            {
                FlowDocument      doc  = (FlowDocument)param;
                DocumentPaginator page = ((IDocumentPaginatorSource)doc).DocumentPaginator;
                IsEidtEnabled = true;
                printDialog.PrintDocument(page, "Test Description");
                IsEidtEnabled = false;

                Logger.Debug(string.Format("Printed prescription for customer- {0}", CustomerInfo));
                OnBack(null);
            }
        }
Exemple #23
0
        private void PrintList(object sender, RoutedEventArgs e)
        {
            FlowDocument flowDocument           = new FlowDocument();
            bool         pageBreakBeforeSection = false;
            int          index = 0;
            Table        table = null;
            TableRow     currentRow;

            foreach (Member member in collectionViewSource.View)
            {
                if (index % 40 == 0)
                {
                    table = CreateNewReportTable(pageBreakBeforeSection);
                    flowDocument.Blocks.Add(table);
                    index = table.RowGroups[2].Rows.Count();
                }
                pageBreakBeforeSection = true;
                table.RowGroups[2].Rows.Add(new TableRow());
                currentRow = table.RowGroups[2].Rows[index];
                currentRow.Cells.Add(new TableCell(new Paragraph(new Run(member.Company))));
                currentRow.Cells.Add(new TableCell(new Paragraph(new Run(member.FirstName))));
                currentRow.Cells.Add(new TableCell(new Paragraph(new Run(member.LastName))));
                currentRow.Cells.Add(new TableCell(new Paragraph(new Run(member.PhoneNumber))));
                currentRow.Cells.Add(new TableCell(new Paragraph(new Run(member.CellPhone))));
                currentRow.Cells.Add(new TableCell(new Paragraph(new Run(member.EmailAddress))));
                currentRow.Cells.Add(new TableCell(new Paragraph(new Run(member.DepartmentClass))));
                currentRow.Cells.Add(new TableCell(new Paragraph(new Run(member.YearsOfService.ToString()))));
                index++;
            }

            //FlowDocumentView flowDocumentView = new FlowDocumentView();
            //flowDocumentView.flowDocumentReader.Document = flowDocument;
            //flowDocumentView.Show();

            PrintDialog printDialog = new PrintDialog();

            if (printDialog.ShowDialog() != true)
            {
                return;
            }
            flowDocument.PageHeight  = printDialog.PrintableAreaHeight;
            flowDocument.PageWidth   = printDialog.PrintableAreaWidth;
            flowDocument.ColumnWidth = printDialog.PrintableAreaWidth;
            IDocumentPaginatorSource documentPaginatorSource = flowDocument as IDocumentPaginatorSource;

            printDialog.PrintDocument(documentPaginatorSource.DocumentPaginator, "Printing List");
        }
Exemple #24
0
        private void Print()
        {
            // Show print dialog.
            var printDialog = new PrintDialog();

            if (printDialog.ShowDialog() == true)
            {
                // Get the page size from the print dialog.
                var pageSize = new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight);

                // Convert document into FixedDocument.
                var fixedDocument = TextEditor.CreateFixedDocument(pageSize, DisplayName);

                // Print.
                printDialog.PrintDocument(fixedDocument.DocumentPaginator, DisplayName);
            }
        }
Exemple #25
0
        internal static void PrintSolutions(List <ScrabbleSolution> solutions, double?fontSize = null)
        {
            var printDialog = new PrintDialog();

            if (printDialog.ShowDialog() == false)
            {
                return;
            }

            var fixedDocument = new FixedDocument();

            fixedDocument.DocumentPaginator.PageSize = new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight);

            var it = solutions.GetEnumerator();

            it.MoveNext();

            var fixedPages = new List <FixedPage>();

            for (;;)
            {
                var page = new FixedPage
                {
                    Width  = printDialog.PrintableAreaWidth,
                    Height = printDialog.PrintableAreaHeight
                };

                LayoutPage(ref it, page, fontSize);

                if (page.Children.Count == 0)
                {
                    break;
                }

                var pc = new PageContent
                {
                    Child = page
                };
                fixedDocument.Pages.Add(pc);
            }

            if (fixedDocument.Pages.Count != 0)
            {
                printDialog.PrintDocument(fixedDocument.DocumentPaginator, "ScrabbleGenerator Solutions");
            }
        }
        public static void Print(RadGanttView ganttView)
        {
            var printDialog = new PrintDialog();

            if (printDialog.ShowDialog() == true)
            {
                var exportImages     = Enumerable.Empty <BitmapSource>();
                var printingSettings = new ImageExportSettings(new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight), true, GanttArea.AllAreas);
                using (var export = ganttView.ExportingService.BeginExporting(printingSettings))
                {
                    exportImages = export.ImageInfos.ToList().Select(info => info.Export());
                }

                var paginator = new GanttPaginator(exportImages);
                printDialog.PrintDocument(paginator, "Print demo");
            }
        }
Exemple #27
0
        private void printButton_Click(object sender, RoutedEventArgs e)
        {
            PrintDialog  printDlg = new PrintDialog();
            FlowDocument doc      = CreateFlowDocument();

            doc.Name = "FlowDoc";
            IDocumentPaginatorSource idpSource = doc;

            printDlg.PrintDocument(idpSource.DocumentPaginator, "Billing");
            BillingOperation Bo = new BillingOperation(billingNo.Text, customerName.Text, Convert.ToDateTime(billingDate.Text), tableNo.Text, contact.Text,
                                                       Convert.ToDouble(subTotal.Text), Convert.ToDouble(serviceTax.Text), Convert.ToDouble(vat.Text), Convert.ToDouble(discount.Text), Total);
            BillingService bs = new BillingService();

            bs.AddBilling(Bo);
            bs.TruncateOrder();
            this.Close();
        }
        private void Natisni_Click(object sender, RoutedEventArgs e)
        {
            //ne sprinta iste pisave
            PrintDialog natisni = new PrintDialog();

            FlowDocument dokument = new FlowDocument(new Paragraph(new Run(txtBoxNaslov.Text)));

            dokument.Blocks.Add(new Paragraph(new Run(txtBoxVsebina.Text)));
            IDocumentPaginatorSource idpSource = dokument;

            natisni.PrintDocument(idpSource.DocumentPaginator, " ");

            PrintQueue printer = LocalPrintServer.GetDefaultPrintQueue();

            Console.WriteLine("Status : {0}", printer.QueueStatus);
            new PrintServer();
        }
 void OnPrint(object sender, ExecutedRoutedEventArgs e)
 {
     if (originalDocument == null)
     {
         return;
     }
     e.Handled = true;
     if (printDialog.ShowDialog() == true)
     {
         // re-apply settings if changed
         if (originalDocument is FlowDocument)
         {
             ApplySettingsToFlowDocument(printDialog, (FlowDocument)originalDocument);
         }
         printDialog.PrintDocument(originalDocument.DocumentPaginator, this.Description);
     }
 }
Exemple #30
0
        private void OnPrint(object sender, RoutedEventArgs e)
        {
            var printDialog = new PrintDialog();

            if (printDialog.ShowDialog() == true)
            {
                var dataSet = new DataSet();
                dataSet.ReadXmlSchema("store.xsd");
                dataSet.ReadXml("store.xml");

                DocumentPaginator paginator = new StoreDataSetPaginator(dataSet.Tables[0],
                                                                        new Typeface("Calibri"), 24, 96 * 0.75,
                                                                        new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight));

                printDialog.PrintDocument(paginator, "Custom-Printed Pages");
            }
        }