예제 #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;
        }
        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);
            }
        }
예제 #3
0
파일: home.xaml.cs 프로젝트: sumit10/BMS
 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");
     }
 }
예제 #4
0
        private void Печать_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.PrintDialog dlg = new System.Windows.Controls.PrintDialog();
            dlg.PageRangeSelection   = PageRangeSelection.AllPages;
            dlg.UserPageRangeEnabled = true;

            Nullable <bool> result = dlg.ShowDialog();


            if (result == true)
            {
                // Create the print dialog object and set options
                PrintDialog pDialog = new PrintDialog();
                pDialog.PageRangeSelection   = PageRangeSelection.AllPages;
                pDialog.UserPageRangeEnabled = true;

                // Display the dialog. This returns true if the user presses the Print button.
                //Nullable<Boolean> print = pDialog.ShowDialog();
                //if (print == true)
                //{
                //    XpsDocument xpsDocument = new XpsDocument("C:\\FixedDocumentSequence.xps", FileAccess.ReadWrite);
                //    FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence();
                //    pDialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Test print job");
                //}
            }
        }
        /// <summary>
        /// Prints this instance.
        /// </summary>
        public bool Print()
        {
            try
            {
                PrintDialog printDlg = new System.Windows.Controls.PrintDialog();
                bool?       results  = printDlg.ShowDialog();
                if (results == null || results == false)
                {
                    return(false);
                }

                //get selected printer capabilities
                System.Printing.PrintCapabilities capabilities = printDlg.PrintQueue.GetPrintCapabilities(printDlg.PrintTicket);

                //get the size of the printer page
                System.Windows.Size printSize = new System.Windows.Size(
                    capabilities.PageImageableArea.ExtentHeight, capabilities.PageImageableArea.ExtentWidth);

                // Build print view
                this.Height = printSize.Height;
                this.Width  = printSize.Width;
                Measure(printSize);
                Arrange(new System.Windows.Rect(printSize));
                XpsDocumentWriter xpsdw = PrintQueue.CreateXpsDocumentWriter(printDlg.PrintQueue);
                printDlg.PrintTicket.PageOrientation = PageOrientation.Landscape;

                xpsdw.WriteAsync(this);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.GetBaseException().Message, "Printing Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            return(true);
        }
예제 #6
0
        public void PrintSnapshot()
        {
            PrintDialog printDlg = new System.Windows.Controls.PrintDialog();

            if (printDlg.ShowDialog() == true)
            {
                //get selected printer capabilities
                PrintCapabilities capabilities = printDlg.PrintQueue.GetPrintCapabilities(printDlg.PrintTicket);

                //Capture the image
                RenderTargetBitmap bmp = new RenderTargetBitmap((int)mainGrid.ActualWidth, (int)mainGrid.ActualHeight, 96, 96, PixelFormats.Pbgra32);
                bmp.Render(this);

                //Place on a panel
                StackPanel myPanel = new StackPanel();
                myPanel.Margin = new Thickness(25);
                Image myImage = new Image();
                myImage.Stretch = Stretch.Uniform;
                myImage.Source  = bmp;
                myPanel.Children.Add(myImage);
                //TextBlock myBlock = new TextBlock();
                //myBlock.Text = "A Great Image.";
                //myBlock.TextAlignment = TextAlignment.Center;
                //myPanel.Children.Add(myBlock);

                myPanel.Measure(new Size(printDlg.PrintableAreaWidth, printDlg.PrintableAreaHeight));
                myPanel.Arrange(new Rect(new Point(0, 0), myPanel.DesiredSize));

                printDlg.PrintVisual(myPanel, "Map capture");
            }
        }
        public MoSo_PrintPreview_ViewModel(string MaSo, string TenKH, string Tien, string LTK, string CMND, string DiaChi)
        {
            NguoiTaoPhieu      = LoginViewModel.TaiKhoanSuDung.HoTen;
            this.MaSo          = MaSo;
            this.TenKH         = TenKH;
            SoTienGui          = Tien;
            NgayMoSo           = DateTime.Now.ToString("dd/MM/yyyy");
            LoaiTietKiem       = LTK;
            this.CMND          = CMND;
            this.DiaChi        = DiaChi;
            CloseWindowCommand = new RelayCommand <object>((p) => { return(p == null ? false : true); }, (p) => {
                var ex = p as Window;
                ex.Close();
            });

            Print_Command = new RelayCommand <object>((p) => { return(p == null ? false : true); }, (p) =>
            {
                var ex = p as Window;
                try
                {
                    System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
                    if (printDialog.ShowDialog() == true)
                    {
                        printDialog.PrintVisual(ex, "Print report");
                    }
                }
                catch (Exception e)
                {
                    System.Windows.MessageBox.Show("Cannot print");
                }
            });
        }
예제 #8
0
        private void PrintPreview_Click(object sender, RoutedEventArgs e)
        {
            var printdialog = new PrintDialog();
            if (printdialog.ShowDialog() != true) { return; }
            var doc = new FixedDocument();
            doc.DocumentPaginator.PageSize = new Size(printdialog.PrintableAreaWidth, printdialog.PrintableAreaHeight);
            var queue = printdialog.PrintQueue;
            var caps = queue.GetPrintCapabilities();
            var area = caps.PageImageableArea;
            var marginwidth = (printdialog.PrintableAreaWidth - caps.PageImageableArea.ExtentWidth) / 2.0;
            var marginheight = (printdialog.PrintableAreaHeight - caps.PageImageableArea.ExtentHeight) / 2.0;

            double gutter;
            if (!Double.TryParse(GutterWidthTextbox.Text, out gutter)) { gutter = 0.25; }
            // Translate inches to device independent pixels
            gutter *= 96.0;

            var opts = new PrintOptions
            {
                PrintableWidth = area.ExtentWidth,
                PrintableHeight = area.ExtentHeight,
                MarginWidth = marginwidth,
                MarginHeight = marginheight,
                Gutter = gutter
            };

            var category = (CardCategory)DataContext;
            category.AddPagesToDocument(doc, opts, category.SelectedCards);

            var preview = new PrintPreview();
            preview.Document = doc;
            preview.ShowDialog();
        }
        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");
            }
        }
예제 #10
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;
        }
예제 #11
0
        protected override void OnPrintCommand()
        {
            PrintDialog printDialog = new PrintDialog();
            printDialog.PrintQueue = LocalPrintServer.GetDefaultPrintQueue();
            printDialog.PrintTicket = printDialog.PrintQueue.DefaultPrintTicket;

            printDialog.PrintTicket.PageOrientation = PageOrientation;

            if (printDialog.ShowDialog() == true)
            {
                // Code assumes this.Document will either by a FixedDocument or a FixedDocumentSequence
                FixedDocument fixedDocument = this.Document as FixedDocument;
                FixedDocumentSequence fixedDocumentSequence = this.Document as FixedDocumentSequence;

                if (fixedDocument != null)
                    fixedDocument.PrintTicket = printDialog.PrintTicket;

                if (fixedDocumentSequence != null)
                    fixedDocumentSequence.PrintTicket = printDialog.PrintTicket;

                XpsDocumentWriter writer = PrintQueue.CreateXpsDocumentWriter(printDialog.PrintQueue);

                if (fixedDocument != null)
                    writer.WriteAsync(fixedDocument, printDialog.PrintTicket);

                if (fixedDocumentSequence != null)
                    writer.WriteAsync(fixedDocumentSequence, printDialog.PrintTicket);
            }
        }
        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);
                }
            }

        }
 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.");
 }
예제 #14
0
        private void Print()
        {
            if (m_streams == null || m_streams.Count == 0)
            {
                return;
            }
            var ptdlg = new System.Windows.Controls.PrintDialog();

            if (ptdlg.ShowDialog() == true)
            {
                //const string printerName = "Microsoft Office Document Image Writer";
                string printerName = ptdlg.PrintQueue.FullName;

                PrintDocument printDoc = new PrintDocument();
                printDoc.PrinterSettings.PrinterName = printerName;
                if (!printDoc.PrinterSettings.IsValid)
                {
                    string msg = String.Format(
                        "Can't find printer \"{0}\".", printerName);
                    throw new InvalidOperationException(msg);
                }
                printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
                printDoc.Print();
            }
        }
예제 #15
0
        public static void PrintText(System.Windows.Controls.RichTextBox TxtBox)
        {
            string Text = new TextRange(TxtBox.Document.ContentStart, TxtBox.Document.ContentEnd).Text;

            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
            if (printDialog.ShowDialog() == true)
            {
                // Создать текст
                Run run = new Run(Text);

                // Поместить его в TextBlock
                TextBlock visual = new TextBlock();
                visual.Inlines.Add(run);

                // Использовать поля для получения рамки страницы
                visual.Margin = new Thickness(5);

                // Разрешить перенос для заполнения всей ширины страницы
                visual.TextWrapping = TextWrapping.Wrap;

                // Увеличить TextBlock по обоим измерениям в 5 раз.
                // (В этом случае увеличение шрифта дало бы тот же эффект,
                // потому что TextBlock — единственный элемент)
                visual.LayoutTransform = new ScaleTransform(5, 5);

                // Установить размер элемента
                System.Windows.Size pageSize = new System.Windows.Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight);
                visual.Measure(pageSize);
                visual.Arrange(new Rect(0, 0, pageSize.Width, pageSize.Height));

                // Напечатать элемент
                printDialog.PrintVisual(visual, "Распечатываем текст");
            }
        }
예제 #16
0
        protected override void OnPrintCommand()
        {
            // get a print dialog, defaulted to default printer and default printer's preferences.
            var printDialog = new PrintDialog();
            printDialog.PrintQueue = LocalPrintServer.GetDefaultPrintQueue();
            printDialog.PrintTicket = printDialog.PrintQueue.DefaultPrintTicket;

            string s = Document.GetType().ToString();

            // get a reference to the FixedDocumentSequence for the viewer.
            //FixedDocumentSequence docSeq = this.Document as FixedDocumentSequence;
            var docSeq = (FixedDocument) Document;

            // set the default page orientation based on the desired output.
            printDialog.PrintTicket = (PrintTicket) docSeq.PrintTicket;

            if (printDialog.ShowDialog() == true)
            {
                // set the print ticket for the document sequence and write it to the printer.
                docSeq.PrintTicket = printDialog.PrintTicket;

                var writer = PrintQueue.CreateXpsDocumentWriter(printDialog.PrintQueue);
                writer.WriteAsync(docSeq, printDialog.PrintTicket);
            }
        }
예제 #17
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");
        }
        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");
            }
        }
예제 #19
0
        public Task PrintCanvasAsync(Canvas canvas, CancellationToken token = default(CancellationToken))
        {
            System.Windows.Controls.PrintDialog     printDialog      = new System.Windows.Controls.PrintDialog();
            System.Drawing.Printing.PrinterSettings printer          = new System.Drawing.Printing.PrinterSettings();
            System.Printing.LocalPrintServer        localPrintServer = new System.Printing.LocalPrintServer();

            System.Printing.PrintTicket pt = new System.Printing.PrintTicket();
            System.Printing.PrintQueue  pq = new System.Printing.PrintQueue(localPrintServer, printer.PrinterName, System.Printing.PrintSystemDesiredAccess.UsePrinter);

            System.Printing.PageMediaSize PMS      = new System.Printing.PageMediaSize(canvas.ActualWidth + 20, canvas.ActualHeight + 20);
            System.Windows.Size           pageSize = new System.Windows.Size(canvas.ActualWidth + 20, canvas.ActualHeight + 20);
            canvas.Arrange(new Rect(0, 0, pageSize.Width, pageSize.Height));
            canvas.Measure(pageSize);

            pt.PageMediaSize = PMS;
            pt.PageMediaType = System.Printing.PageMediaType.Unknown;

            pq.DefaultPrintTicket.PageMediaSize = PMS;
            pq.DefaultPrintTicket.PageMediaType = System.Printing.PageMediaType.Unknown;

            printDialog.PrintQueue  = pq;
            printDialog.PrintTicket = pt;
            //printDialog.PrintQueue.Commit();

            if (printDialog.ShowDialog() == true)
            {
                printDialog.PrintVisual(canvas, "Состояние холста");
            }
            return(Task.FromResult(0)); //Task.CompletedTask;
        }
        void PrintOnClick(object sender, RoutedEventArgs args)
        {
            PrintDialog dlg = new PrintDialog();

            if (dlg.ShowDialog().GetValueOrDefault())
            {
                // Make sure orientation is Portrait.
                PrintTicket prntkt = dlg.PrintTicket;
                prntkt.PageOrientation = PageOrientation.Portrait;
                dlg.PrintTicket = prntkt;

                // Create new BannerDocumentPaginator object.
                BannerDocumentPaginator paginator = new BannerDocumentPaginator();

                // Set Text property from TextBox.
                paginator.Text = txtbox.Text;

                // Give it a PageSize property based on the paper dimensions.
                paginator.PageSize = new Size(dlg.PrintableAreaWidth,
                                              dlg.PrintableAreaHeight);

                // Call PrintDocument to print the document.
                dlg.PrintDocument(paginator, "Banner: " + txtbox.Text);
            }
        }
        /// <summary>
        /// Prints this instance.
        /// </summary>
        public bool Print()
        {
            try
            {
                PrintDialog printDlg = new System.Windows.Controls.PrintDialog();
                bool? results = printDlg.ShowDialog();
                if (results == null || results == false) return false;

                //get selected printer capabilities
                System.Printing.PrintCapabilities capabilities = printDlg.PrintQueue.GetPrintCapabilities(printDlg.PrintTicket);

                //get the size of the printer page
                System.Windows.Size printSize = new System.Windows.Size(
                    capabilities.PageImageableArea.ExtentHeight, capabilities.PageImageableArea.ExtentWidth);

                // Build print view
                this.Height = printSize.Height;
                this.Width = printSize.Width;
                Measure(printSize);
                Arrange(new System.Windows.Rect(printSize));
                XpsDocumentWriter xpsdw = PrintQueue.CreateXpsDocumentWriter(printDlg.PrintQueue);
                printDlg.PrintTicket.PageOrientation = PageOrientation.Landscape;

                xpsdw.WriteAsync(this);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.GetBaseException().Message, "Printing Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return false;
            }
            return true;
        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            var dialog = new PrintDialog();
            document.DocumentPaginator.PageSize = new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight);
            fixedPage = new FixedPage
            {
                Height = document.DocumentPaginator.PageSize.Height,
                Width = document.DocumentPaginator.PageSize.Width
            };
            grid = new Grid();
            grid.Arrange(new Rect(0, 0, fixedPage.Width, fixedPage.Height));
            fixedPage.Children.Add(grid);
            pageContent = new PageContent { Child = fixedPage };
            pageContent.Arrange(new Rect(0, 0, fixedPage.Width, fixedPage.Height));
            fixedPage.Margin = new Thickness(20, 44, 20, 44);

            for (int i = 0; i < totalRows; i++)
            {
                grid.RowDefinitions.Add(new RowDefinition());
            }
            for (int j = 0; j < totalColumns; j++)
            {
                grid.ColumnDefinitions.Add(new ColumnDefinition());
            }

            document.Pages.Add(pageContent);
        }
예제 #23
0
파일: Printing.cs 프로젝트: denis554/Edi-1
        /// <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");
            }
        }
예제 #24
0
        private void printButton_Click(object sender, RoutedEventArgs e)
        {
            PrintDialog printDlg = new System.Windows.Controls.PrintDialog();

            if (printDlg.ShowDialog() == true)
            {
                double zoom;

                double markerWidthInCm = markerBackground.ActualWidth * 0.026458333;

                zoom = markerWidthSlider.Value / markerWidthInCm;

                //markerCanvas.Background = Brushes.LightGray;

                markerCanvas.LayoutTransform = new ScaleTransform(zoom, zoom);

                Size pageSize = new Size(printDlg.PrintableAreaWidth - 20, printDlg.PrintableAreaHeight - 20);

                markerCanvas.Measure(pageSize);

                markerCanvas.Arrange(new Rect(10, 10, pageSize.Width, pageSize.Height));

                printDlg.PrintVisual(markerCanvas, "Marker");

                markerCanvas.Background      = null;
                markerCanvas.LayoutTransform = null;
            }
        }
예제 #25
0
        private void PrintElement(Visual visual)
        {
            PrintDialog printDlg = new System.Windows.Controls.PrintDialog();

            if (printDlg.ShowDialog() == true)
            {
                //get selected printer capabilities
                System.Printing.PrintCapabilities capabilities = printDlg.PrintQueue.GetPrintCapabilities(printDlg.PrintTicket);

                //get the size of the printer page
                Size sz = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);

                VisualBrush b = new VisualBrush(visual)
                {
                    Stretch    = Stretch.Uniform,
                    AlignmentX = AlignmentX.Center,
                    AlignmentY = AlignmentY.Center,
                };

                Canvas c = new Canvas
                {
                    Height     = sz.Height,
                    Width      = sz.Width,
                    Background = b,
                };

                var skinDescription = (SkinDescription)Application.Current.Properties["CurrentSkinDescription"];

                var license = skinDescription.License;
                if (!string.IsNullOrEmpty(license))
                {
                    license = "License: " + license;
                }

                var notice = string.Format("{0}\n{1}", skinDescription.CopyrightNotice, license).Trim();

                if (!string.IsNullOrWhiteSpace(notice))
                {
                    var t = new TextBlock
                    {
                        Text                = notice,
                        FontSize            = 8,
                        Margin              = new Thickness(5),
                        HorizontalAlignment = HorizontalAlignment.Right,
                        VerticalAlignment   = VerticalAlignment.Bottom,
                        TextAlignment       = TextAlignment.Right,
                    };

                    Canvas.SetRight(t, 0);
                    Canvas.SetBottom(t, 0);

                    c.Children.Add(t);
                }

                c.Measure(sz);
                c.Arrange(new Rect(new Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz));

                printDlg.PrintVisual(c, "Settlers Board Designer");
            }
        }
예제 #26
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);
                }
            }
        }
        public BaoCaoMoDong_PrintPreview_ViewModel(string MaBC, string Thang, string Nam, string LTK, ObservableCollection <ListBaoCaoDongMo> list)
        {
            ListBaoCaoDMPP     = list;
            NamBaoCao          = Nam;
            MaBaoCao           = MaBC;
            ThangBaoCao        = Thang;
            LoaiTietKiem       = LTK;
            NgayLapBaoCao      = DateTime.Now.ToString("dd/MM/yyyy");
            NguoiTaoPhieu      = LoginViewModel.TaiKhoanSuDung.HoTen;
            CloseWindowCommand = new RelayCommand <object>((p) => { return(p == null ? false : true); }, (p) => {
                var ex = p as Window;
                ex.Close();
            });

            Print_Command = new RelayCommand <object>((p) => { return(p == null ? false : true); }, (p) =>
            {
                var ex = p as Window;
                try
                {
                    System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
                    if (printDialog.ShowDialog() == true)
                    {
                        printDialog.PrintVisual(ex, "Print report");
                    }
                }
                catch (Exception e)
                {
                    System.Windows.MessageBox.Show("Cannot print");
                }
            });
        }
예제 #28
0
        private bool modifyPrinter(ListBoxPrinter printer)
        {
            if (printer == null)
            {
                return(false);
            }

            // Initialize PrintDialog to use printer's Queue and Ticket
            System.Windows.Controls.PrintDialog pd = new System.Windows.Controls.PrintDialog();
            pd.PrintQueue = printer.Printer.Queue;
            // pd.PrintTicket = printer.Ticket;
            pd.UserPageRangeEnabled = false;

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

            // TODO FIXME This doesn't check that the printer is actually the same printer! It could be an invalid ticket!
            printer.Printer.Ticket = pd.PrintTicket;

            /*
             * printer.Dialog.UserPageRangeEnabled = false;
             *
             * // Show the dialog; if the user clicks Cancel, return.
             * if (printer.Dialog.ShowDialog() == false) return false;
             *
             * var pc = printer.Dialog.PrintQueue.GetPrintCapabilities();
             * // Save the ticket only if the user hits Print
             * printer.Ticket = printer.Dialog.PrintTicket;
             */
            return(true);
        }
예제 #29
0
        /// <summary>
        /// Print the current window ass best fit for a page
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PrintScreen_Button_Click(object sender, RoutedEventArgs e)
        {
            PrintDialog printDlg = new System.Windows.Controls.PrintDialog();

            printDlg.PrintTicket.PageOrientation = PageOrientation.Landscape;

            if (printDlg.ShowDialog() == true)
            {
                //get selected printer capabilities
                System.Printing.PrintCapabilities capabilities = printDlg.PrintQueue.GetPrintCapabilities(printDlg.PrintTicket);

                //get scale of the print wrt to screen of WPF visual
                double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / this.ActualWidth, capabilities.PageImageableArea.ExtentHeight /
                                        this.ActualHeight);

                //Transform the Visual to scale
                this.LayoutTransform = new ScaleTransform(scale, scale);

                //get the size of the printer page
                Size sz = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);

                //update the layout of the visual to the printer page size.
                this.Measure(sz);
                this.Arrange(new Rect(new Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz));

                //now print the visual to printer to fit on the one page.
                printDlg.PrintVisual(this, "Wpf controller");
            }
        }
예제 #30
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;
        }
예제 #31
0
        public static void Print(FrameworkElement obj)
        {
            PrintDialog printDlg = new System.Windows.Controls.PrintDialog();

            if (printDlg.ShowDialog() == true)
            {
                Transform transform = obj.LayoutTransform;

                // get selected printer capabilities
                System.Printing.PrintCapabilities capabilities = printDlg.PrintQueue.GetPrintCapabilities(printDlg.PrintTicket);

                // get scale of the print wrt to screen of WPF visual
                double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / obj.ActualWidth, capabilities.PageImageableArea.ExtentHeight / obj.ActualHeight);

                // Transform the Visual to scale
                obj.LayoutTransform = new ScaleTransform(scale, scale);

                // get the size of the printer page
                Size sz = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);

                // update the layout of the visual to the printer page size.
                obj.Measure(sz);
                obj.Arrange(new Rect(new Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz));

                // now print the visual to printer to fit on the one page.
                printDlg.PrintVisual(obj, "UnisensViewer");

                obj.LayoutTransform = transform;
            }
        }
        public PhieuRut_PrintPreview_ViewModel(string MaPR, string TenKH, string Ngay, string Tien)
        {
            MaPhieuRut         = MaPR;
            TenKhachhang       = TenKH;
            NgayRut            = Ngay;
            NguoiTaoPhieu      = LoginViewModel.TaiKhoanSuDung.HoTen;
            SoTienRut          = Tien;
            NgayTaoPhieu       = DateTime.Now.ToString("dd/MM/yyyy");
            CloseWindowCommand = new RelayCommand <object>((p) => { return(p == null ? false : true); }, (p) => {
                var ex = p as Window;
                ex.Close();
            });

            Print_Command = new RelayCommand <object>((p) => { return(p == null ? false : true); }, (p) =>
            {
                var ex = p as Window;
                try
                {
                    System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
                    if (printDialog.ShowDialog() == true)
                    {
                        printDialog.PrintVisual(ex, "Print report");
                    }
                }
                catch (Exception e)
                {
                    System.Windows.MessageBox.Show("Cannot print");
                }
            });
        }
        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();
        }
예제 #34
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");
 }
예제 #35
0
파일: Common.cs 프로젝트: Ashna/ShayanDent
        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;

            }
        }
예제 #36
0
 public static void SetEtoSettings(this swc.PrintDialog dialog, PrintSettings settings)
 {
     if (dialog == null)
     {
         return;
     }
     if (settings != null)
     {
         var handler = (PrintSettingsHandler)settings.Handler;
         dialog.PrintQueue  = handler.PrintQueue;
         dialog.PrintTicket = handler.Control;
         var maxPageRange = handler.MaximumPageRange;
         dialog.MinPage            = (uint)maxPageRange.Start;
         dialog.MaxPage            = (uint)maxPageRange.End;
         dialog.PageRange          = handler.SelectedPageRange.ToPageRange();
         dialog.PageRangeSelection = handler.PrintSelection.ToSWC();
     }
     else
     {
         dialog.PrintQueue         = null;
         dialog.PrintTicket        = null;
         dialog.MinPage            = 1;
         dialog.MaxPage            = 1;
         dialog.PageRangeSelection = swc.PageRangeSelection.AllPages;
         dialog.PageRange          = new swc.PageRange(1, 1);
     }
 }
예제 #37
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);
         }
     }
 }
예제 #38
0
        private void InvokePrint(object sender, RoutedEventArgs e)
        {
            TitleGrid.Margin  = new Thickness(60, 40, 60, 0);
            FirstPage.Margin  = new Thickness(60, 0, 60, 0);
            SecondPage.Margin = new Thickness(60, 0, 60, 0);

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

            if (printDialog.ShowDialog() == true)
            {
                PrintButton.Visibility    = Visibility.Collapsed;
                IntroPanel.Visibility     = Visibility.Collapsed;
                CopyrightPanel.Visibility = Visibility.Visible;

                PrintPanel(MainStackPanel, "3D Objects cheat sheet", printDialog, 0.75); // customScale = 0.75 - this should fit the document to 2 pages

                CopyrightPanel.Visibility = Visibility.Collapsed;
                IntroPanel.Visibility     = Visibility.Visible;
                PrintButton.Visibility    = Visibility.Visible;
            }

            TitleGrid.Margin  = new Thickness(20, 0, 20, 0);
            FirstPage.Margin  = new Thickness(20, 0, 20, 0);
            SecondPage.Margin = new Thickness(20, 0, 20, 0);
        }
예제 #39
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");
              }
        }
예제 #40
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");
            }
        }
예제 #41
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;
            }
        }
예제 #42
0
        public BaoCaoDoanhSo_PrintPreview_ViewModel(ObservableCollection <BaoCaoDS> listBaoCao, DateTime ngayBaoCao)
        {
            ListBaoCaoDoanhSo = listBaoCao;
            //for (int i = 0; i < listBaoCao.Count(); i++)
            //    ListBaoCaoDoanhSo[i].SoThuTu = i + 1;

            NgayBaoCao    = ngayBaoCao;
            NguoiTaoPhieu = LoginViewModel.TaiKhoanSuDung.HoTen;

            CloseWindowCommand = new RelayCommand <object>((p) => { return(p == null ? false : true); }, (p) => {
                var ex = p as Window;
                ex.Close();
            });

            Print_Command = new RelayCommand <object>((p) => { return(p == null ? false : true); }, (p) =>
            {
                var ex = p as Window;
                try
                {
                    System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
                    if (printDialog.ShowDialog() == true)
                    {
                        printDialog.PrintVisual(ex, "Print report");
                    }
                }
                catch (Exception e)
                {
                    System.Windows.MessageBox.Show("Cannot print");
                }
            });
        }
예제 #43
0
        private void _print()
        {
            try
            {
                PrintDialog printDlg = new System.Windows.Controls.PrintDialog();
                printDlg.PrintTicket.PageMediaSize = new PageMediaSize((Double)395.0, (Double)220.0);
                //printDlg.ShowDialog();

                //get selected printer capabilities
                System.Printing.PrintCapabilities capabilities = printDlg.PrintQueue.GetPrintCapabilities(printDlg.PrintTicket);

                //get scale of the print wrt to screen of WPF visual
                double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / this.Width, capabilities.PageImageableArea.ExtentHeight / this.Height);

                //Transform the Visual to scale
                this.LayoutTransform = new ScaleTransform(scale, scale);

                //get the size of the printer page
                Size sz = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);

                //update the layout of the visual to the printer page size.
                this.Measure(sz);

                this.Arrange(new Rect(new Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz));

                //now print the visual to printer to fit on the one page.
                printDlg.PrintVisual(this, "BoxSlip_KrausUSA_A");
            }
            catch (Exception)
            {
            }
        }
        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();
        }
예제 #45
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Common.Print(printedPage);
            PrintDialog printDlg = new PrintDialog();

            printDlg.PrintVisual(mygrid, "Grid Printing.");
        }
예제 #46
0
        private void btnolustur_Click(object sender, RoutedEventArgs e)
        {
            cv         cvpage = new cv();
            raporlarBO bo     = new raporlarBO();
            raporlar   r      = new raporlar();

            r = bo.getir(Convert.ToInt32(txbsicilno.Text));
            cvpage.lblAd.Text = (r.adSoyad);

            cvpage.txtckimlk.Text  = (r.tcKimlikNo);
            cvpage.txdogumyer.Text = Convert.ToString(r.dogumYeri);
            cvpage.txdogumtar.Text = (r.dogumTarihi).ToShortDateString();
            cvpage.txasker.Text    = (r.askerlikDurumu);
            cvpage.txkan.Text      = Convert.ToString(r.kanGrubu);
            cvpage.txbolum.Text    = (r.Lokasyon);
            cvpage.txbirim.Text    = (r.Birim);
            cvpage.txisbasi.Text   = (r.kurumaBaslamaTarihi).ToShortDateString();
            //cvpage.txhizmetyil.Text
            cvpage.txegitim.Text  = (r.egitimDurumu);
            cvpage.txokul.Text    = (r.okulAdi);
            cvpage.txokbolum.Text = (r.Bolumu);
            cvpage.txbitirme.Text = (r.bitirdigiTarih).ToShortDateString();
            cvpage.istel.Text     = Convert.ToString(r.isTel);
            cvpage.adres.Text     = (r.adres);
            cvpage.ceptel.Text    = (r.cepTel);

            DateTime sontarih = DateTime.Now;
            DateTime ilktarih = r.kurumaBaslamaTarihi;

            ikitarihfark a = new ikitarihfark();

            int[] sonuc = (a.ikiTarihFarki(sontarih, ilktarih));
            cvpage.txhizmetyil.Text = sonuc[0] + " YIL " + sonuc[1] + " Ay " + sonuc[2] + " Gün";

            int uzunluk = (r.Unvan).Length;

            if (uzunluk > 10)
            {
                cvpage.lblUnvan.FontSize = 18;
            }


            cvpage.lblUnvan.Text = r.Unvan;


            try
            {
                cvpage.IsEnabled = false;
                System.Windows.Controls.PrintDialog pd = new System.Windows.Controls.PrintDialog();
                if (pd.ShowDialog() == true)
                {
                    pd.PrintVisual(cvpage, "aaaa");
                }
            }
            finally
            {
                cvpage.IsEnabled = true;
            }
        }
예제 #47
0
 private void menuPrint_Click(object sender, RoutedEventArgs e)
 {
     System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
     if (printDialog.ShowDialog() == true)
     {
         printDialog.PrintVisual(canvas, "My First Print Job");
     }
 }
예제 #48
0
 public PrintSettingsHandler(swc.PrintDialog dialog)
 {
     Control           = dialog.PrintTicket;
     PrintQueue        = dialog.PrintQueue;
     MaximumPageRange  = new Range <int>((int)dialog.MinPage, (int)dialog.MaxPage);
     SelectedPageRange = dialog.PageRange.ToEto();
     PrintSelection    = dialog.PageRangeSelection.ToEto();
 }
예제 #49
0
 private void PrintJ(object sender, RoutedEventArgs e)
 {
     System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
     if (printDialog.ShowDialog() == true)
     {
         printDialog.PrintVisual(JournalDataGrid, "Распечатка журнала");
     }
 }
예제 #50
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
     if (printDialog.ShowDialog() == true)
     {
         printDialog.PrintVisual(canvas, "Распечатываем элемент Canvas");
     }
 }
예제 #51
0
 public static PrintSettings GetEtoSettings(this swc.PrintDialog dialog, Eto.Generator generator)
 {
     if (dialog == null)
     {
         return(null);
     }
     return(new PrintSettings(generator, new PrintSettingsHandler(dialog)));
 }
예제 #52
0
        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            PrintDialog printDialog = new PrintDialog();

            if (printDialog.ShowDialog() == true)
            {
                lb_DialogResult.Items.Add("打印已选择");
            }
        }
예제 #53
-1
        void IUIJob.OnNewOperation(IOperationViewer operationViewer, Operation operation)
        {
            // Only print if we don't have already (verrrrrrrrrrrry helpful during debugging, but also a sanity-check)
            if (CheckIsOperationAlreadyPrinted(operation, true))
            {
                return;
            }

            PrintQueue printQueue = _printQueue.Value;
            // If printing is not possible (an error occurred because the print server is not available etc.).
            if (printQueue == null)
            {
                Logger.Instance.LogFormat(LogType.Warning, this, "Cannot print job because the configured printer seems not available! Check log entries.");
                return;
            }

            // We need to wait for a bit to let the UI "catch a breath".
            // Otherwise, if printing immediately, it may have side-effects that parts of the visual aren't visible (bindings not updated etc.).
            Thread.Sleep(_configuration.WaitInterval);

            PrintDialog dialog = new PrintDialog();
            dialog.PrintQueue = printQueue;
            dialog.PrintTicket = dialog.PrintQueue.DefaultPrintTicket;
            dialog.PrintTicket.PageOrientation = PageOrientation.Landscape;
            dialog.PrintTicket.CopyCount = _configuration.CopyCount;

            FrameworkElement visual = operationViewer.Visual;
            // Measure and arrange the visual before printing otherwise it looks unpredictably weird and may not fit on the page
            visual.Measure(new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight));
            visual.Arrange(new Rect(new Point(0, 0), visual.DesiredSize));

            dialog.PrintVisual(visual, "New alarm " + operation.OperationNumber);
        }
예제 #54
-1
        private void PrintPageDialog(Messages.PrintPage printMessage)
        {
            PrintDialog printDialog = new PrintDialog();
            if (printDialog.ShowDialog() == true)
            {
                PrintCapabilities capabilities = printDialog.PrintQueue.GetPrintCapabilities(printDialog.PrintTicket);

                //get scale of the print wrt to screen of WPF visual
                double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / this.ActualWidth, capabilities.PageImageableArea.ExtentHeight /  this.ActualHeight);

                //Transform the Visual to scale
                this.LayoutTransform = new ScaleTransform(scale, scale);

                //get the size of the printer page
                Size sz = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);

                //update the layout of the visual to the printer page size.
                printMessage.Element.Measure(sz);
                printMessage.Element.Arrange(new Rect(new Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz));

                //now print the visual to printer to fit on the one page.
                printDialog.PrintVisual(printMessage.Element, printMessage.Description);
            }
            
        }
예제 #55
-1
        public void PrintDocumentVis(Bitmap bm, string DocumentName)
        {
            DrawingVisual vis = new DrawingVisual();
            DrawingContext dc = vis.RenderOpen();
            BitmapImage imgSource = new BitmapImage();
            using (MemoryStream memory = new MemoryStream())
            {
                bm.Save(memory, ImageFormat.Png);
                memory.Position = 0;
                imgSource.BeginInit();
                imgSource.StreamSource = memory;
                imgSource.CacheOption = BitmapCacheOption.OnLoad;
                imgSource.EndInit();
            }

            dc.DrawImage(imgSource, new Rect(0, 0, imgSource.Width, imgSource.Height));
            dc.Close();
            PrintDialog pdDialog = new PrintDialog();
            pdDialog.PrintVisual(vis, DocumentName);

            //  Cleanup
            vis = null;
            dc = null;
            imgSource = null;
            pdDialog = null;
        }
예제 #56
-1
        void PrintOnClick(object sender, RoutedEventArgs args)
        {
            PrintDialog dlg = new PrintDialog();

            if ((bool)dlg.ShowDialog().GetValueOrDefault())
            {
               //     Create DrawingVisual and open DrawingContext.
                DrawingVisual vis = new DrawingVisual();
                DrawingContext dc = vis.RenderOpen();

                // Draw ellipse.
                dc.DrawEllipse(Brushes.LightGray, new Pen(Brushes.Black, 3),
                               new Point(dlg.PrintableAreaWidth / 2,
                                         dlg.PrintableAreaHeight / 2),
                               dlg.PrintableAreaWidth / 2,
                               dlg.PrintableAreaHeight / 2);

                // Close DrawingContext.
                dc.Close();

                // Finally, print the page.
                dlg.PrintVisual(vis, "My first print job");

            }
        }
예제 #57
-1
 public static void AskToPrint( ContentPresenter content
                              , string printJobDesc = "Tab Content Visual")
 {
     var dlg = new PrintDialog();
     if (dlg.ShowDialog() != true) return;
     dlg.PrintVisual(content, printJobDesc);
 }
예제 #58
-1
        public static void AskToPrint( FrameworkElement ctrl
                                     , string printJobDesc = "Scaled Visual")
        {
            PrintDialog print = new PrintDialog();
            if (print.ShowDialog() != true) return;

            PrintCapabilities capabilities = print.PrintQueue.GetPrintCapabilities(print.PrintTicket);

            double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / ctrl.ActualWidth,
                                    capabilities.PageImageableArea.ExtentHeight / ctrl.ActualHeight);

            //Transform oldTransform = ctrl.LayoutTransform;

            ctrl.LayoutTransform = new ScaleTransform(scale, scale);

            //Size oldSize = new Size(ctrl.ActualWidth, ctrl.ActualHeight);

            Size sz = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);
            ctrl.Measure(sz);
            ((UIElement)ctrl).Arrange(new Rect(new Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight),
                sz));

            ctrl.Focus();

            print.PrintVisual(ctrl, printJobDesc);
            //ctrl.LayoutTransform = oldTransform;

            //ctrl.Measure(oldSize);

            //((UIElement)ctrl).Arrange(new Rect(new Point(0, 0),
            //    oldSize));
        }
예제 #59
-1
파일: Common.cs 프로젝트: Ashna/ShayanDent
        public static void Print(Grid 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.Height;
                double pageWidth = printedPage.Width;

                printedPage.Height = dialog.PrintableAreaHeight;
                printedPage.Width = dialog.PrintableAreaWidth;

                dialog.PrintVisual(printedPage, "");

                printedPage.Height = pageHeight;
                printedPage.Width = pageWidth;

            }
        }
예제 #60
-1
파일: Printing.cs 프로젝트: Stankim/Onion
        public static void PrintVisual(Grid g)
        {
            printDialog = new PrintDialog();
            if (printDialog.ShowDialog() == false)
                return;
            FrameworkElement e = g as FrameworkElement;
            Transform originalScale = e.LayoutTransform;   
           
            //get selected printer capabilities
            PrintCapabilities capabilities = printDialog.PrintQueue.GetPrintCapabilities(printDialog.PrintTicket);
            //get scale of the print wrt to screen of WPF visual
            double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / g.ActualWidth, capabilities.PageImageableArea.ExtentHeight /
            g.ActualHeight);
            //Transform the Visual to scale
            g.LayoutTransform = new ScaleTransform(scale, scale);
            //get the size of the printer page

            Size sz = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);
            //update the layout of the visual to the printer page size.

            g.Measure(sz);
            g.Arrange(new Rect(new Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz));

            //now print the visual to printer to fit on the one page.
           
            printDialog.PrintVisual(g, "Onion Smart Solutions");

            e.LayoutTransform = originalScale;
        }