public static void InializePrinting(List<BarCode> barCodeList, string printType)
        {
            _barCodeList = barCodeList;
            _printType = printType;
            var printPreviewDialog =
                new PrintPreviewDialog
                {
                    WindowState = FormWindowState.Maximized,
                    FormBorderStyle = FormBorderStyle.None,
                    UseAntiAlias = true,
                    Document = PrintDocument
                };

            if (AppContext.Counter != null)
                PrintDocument.PrinterSettings.PrinterName = AppContext.Counter.BarCodePrinter;

            PrintDocument.BeginPrint += PrintDocBeginPrint;
            if (Resources.ConstBarCodeTemplate5.Equals(_printType))
            {
                PrintDocument.PrintPage += BarcodeSample5_PrintPage;
                printPreviewDialog.ShowDialog();
                PrintDocument.PrintPage -= BarcodeSample5_PrintPage;
            }
            else if (Resources.ConstBarCodeTemplate4.Equals(_printType))
            {
                PrintDocument.PrintPage += BarcodeSample4_PrintPage;
                printPreviewDialog.ShowDialog();
                PrintDocument.PrintPage -= BarcodeSample4_PrintPage;
            }
            else if (Resources.ConstBarCodeTemplate3.Equals(_printType))
            {
                PrintDocument.PrintPage += BarcodeSample3_PrintPage;
                printPreviewDialog.ShowDialog();
                PrintDocument.PrintPage -= BarcodeSample3_PrintPage;
            }
            else if (Resources.ConstBarCodeTemplate2.Equals(_printType))
            {
                PrintDocument.PrintPage += BarcodeSample2_PrintPage;
                printPreviewDialog.ShowDialog();
                PrintDocument.PrintPage -= BarcodeSample2_PrintPage;
            }
            else if (Resources.ConstBarCodeTemplate1.Equals(_printType))
            {
                PrintDocument.PrintPage += BarcodeSample1_PrintPage;
                printPreviewDialog.ShowDialog();
                PrintDocument.PrintPage -= BarcodeSample1_PrintPage;
            }
            PrintDocument.BeginPrint -= PrintDocBeginPrint;
        }
        public override void Execute()
        {
            printDocument = new PrintDocument();

            printDocument.OriginAtMargins = true;
            printDocument.BeginPrint     += new PrintEventHandler(printDocument_BeginPrint);
            printDocument.PrintPage      += new PrintPageEventHandler(printDocument_PrintPage);

            Dictionary <String, Object> paperSettings = Printing.getPaperSettings(grtArguments);

            printDocument.DefaultPageSettings.Landscape = (string)paperSettings["orientation"] == "landscape";

            // Sizes must be given in inch * 100 (sigh).
            int       paperWidth  = (int)Math.Round((double)paperSettings["width"] / 0.254);
            int       paperHeight = (int)Math.Round((double)paperSettings["height"] / 0.254);
            PaperSize paperSize   = new PaperSize("Ignored anyway", paperWidth, paperHeight);

            if ((bool)paperSettings["marginsSet"])
            {
                printDocument.DefaultPageSettings.Margins =
                    new Margins((int)paperSettings["marginLeft"], (int)paperSettings["marginRight"],
                                (int)paperSettings["marginTop"], (int)paperSettings["marginBottom"]);
            }

            System.Windows.Forms.PrintPreviewDialog preview = new System.Windows.Forms.PrintPreviewDialog();

            preview.Document     = printDocument;
            preview.UseAntiAlias = true;

            preview.ShowDialog();
        }
Exemple #3
0
        public void printPreview(PrinteModel model)
        {
            if (model != null)
            {
                printModel = model;
            }
            else
            {
                return;
            }
            try
            {
                init();
                PrintPreviewDialog previewDialog = new PrintPreviewDialog();
                previewDialog.Document = docToPrint;
                var result = previewDialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    docToPrint.Print();
                }
            }
            catch (Exception ex)
            {

            }
        }
Exemple #4
0
        public static void Print_DataGridView(DataGridView dgv1, string printTitle, bool printAllRows, bool fitToPageWidth)
        {
            PrintPreviewDialog ppvw;
            try
            {

                // Getting DataGridView object to print
                dgv = dgv1;

                // Getting all Coulmns Names in the DataGridView
                AvailableColumns.Clear();
                foreach (DataGridViewColumn c in dgv.Columns)
                {
                    if (!c.Visible) continue;
                    AvailableColumns.Add(c.HeaderText);
                }

                // Showing the PrintOption Form
                //PrintOptions dlg = new PrintOptions(AvailableColumns);
                //if (dlg.ShowDialog() != DialogResult.OK) return;

                PrintTitle = printTitle;
                PrintAllRows = printAllRows;
                FitToPageWidth = fitToPageWidth;
                SelectedColumns = AvailableColumns;

                RowsPerPage = 0;

                ppvw = new PrintPreviewDialog();
                PageSetupDialog psd = new PageSetupDialog();
                psd.Document = printDoc;
                psd.ShowDialog();
                printDoc.DefaultPageSettings = psd.PageSettings;
                ppvw.Document = printDoc;

                // Showing the Print Preview Page
                printDoc.BeginPrint += new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                printDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
                //printDoc.QueryPageSettings += new System.Drawing.Printing.QueryPageSettingsEventHandler(printDoc_QueryPageSettings);
                if (ppvw.ShowDialog() != DialogResult.OK)
                {
                    printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                    printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
                    return;
                }

                // Printing the Documnet
                printDoc.Print();
                printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {

            }
        }
Exemple #5
0
 /// <summary>
 /// 打印
 /// </summary>
 /// <param name="ShowSetupDialog">是否显示打印机选择框</param>
 /// <param name="IsDrawLine">是否画边框</param>
 public void Print(bool ShowSetupDialog, bool IsDrawLine)
 {
     try
     {
         ShowLine          = IsDrawLine;
         printDocument     = new PrintDocument();
         IsShowSetupDialog = ShowSetupDialog;
         if (IsShowSetupDialog)
         {
             pd.PrinterSettings = new PrinterSettings();
             //pageSetupDialog = new PageSetupDialog();
             //pageSetupDialog.AllowPrinter = true;
             //pageSetupDialog.PageSettings = ps;
             if (pd.ShowDialog() != DialogResult.OK)
             {
                 return;
             }
             //printDocument.DefaultPageSettings = ps;
         }
         printDocument.PrinterSettings     = pd.PrinterSettings;
         printDocument.DefaultPageSettings = ps;
         printDocument.PrintPage          += new PrintPageEventHandler(this.printDocument_PrintPage);
         printPreviewDialog                     = new PrintPreviewDialog();
         printPreviewDialog.Document            = printDocument;
         ((Form)printPreviewDialog).WindowState = FormWindowState.Maximized;
         printPreviewDialog.ShowDialog();
     }
     catch (Exception e)
     {
         throw new Exception("Printer error." + e.Message);
     }
 }
        public void print()
        {
            PrintDialog pd = new PrintDialog();
            PrintDocument pdoc = new PrintDocument();
            PrinterSettings ps = new PrinterSettings();
            Font font =new Font("Arial",12);
            PaperSize psize = new PaperSize("Custome", 100, 200);
            pd.Document = pdoc;
            pd.Document.DefaultPageSettings.PaperSize = psize;
            pdoc.DefaultPageSettings.PaperSize.Height = 320;
            pdoc.DefaultPageSettings.PaperSize.Width = 200;
            pdoc.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
            DialogResult result = pd.ShowDialog();
            if (result == DialogResult.OK)
            {
                PrintPreviewDialog ppd = new PrintPreviewDialog();
                ppd.Document = pdoc;
                result = ppd.ShowDialog();
                if (result == DialogResult.OK)
                {
                    pdoc.Print();

                }
            }



        }
        private void GetPrinters_Click(object sender, EventArgs e)
        {
            //PrintDocument pd = new PrintDocument();
            //pd.DefaultPageSettings.Bounds = new
            //pd.Print();

            PrintPreviewDialog ppd = new PrintPreviewDialog();
            PrintDocument pd = new PrintDocument();
            //设置边距
            Margins margin = new Margins(200, 20, 20, 0);
            pd.DefaultPageSettings.Margins = margin;
            //纸张设置默认
            PaperSize pageSize = new PaperSize("First custom size", getYc(58), 100);
            pd.DefaultPageSettings.PaperSize = pageSize;
            //打印事件设置
            pd.PrintPage += pd_PrintPage;
            ppd.Document = pd;
            ppd.ShowDialog();
            //try
            //{
            //    pd.Print();
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message, "打印出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    pd.PrintController.OnEndPrint(pd, new PrintEventArgs());
            //}
        }
        private void buttonPrintImage_Click(object sender, EventArgs e)
        {
            try
            {
                PrintDialog printDialog = new PrintDialog();
                printDialog.Document = this.printDocument1;
                if (printDialog.ShowDialog() != DialogResult.OK)
                {
                    throw new Exception();
                }
                /*
                PageSetupDialog pageSetupDialog = new PageSetupDialog();
                pageSetupDialog.Document = printDocument1;
                if (pageSetupDialog.ShowDialog() != DialogResult.OK)
                {
                    throw new Exception();
                }
                */
                PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
                printPreviewDialog.Document = this.printDocument1;
                printPreviewDialog.ShowDialog();

            }
            catch (Exception)
            {
                MessageBox.Show("打印已经取消");
            }
        }
        public override void Execute()
        {
            printDocument = new PrintDocument();

              printDocument.OriginAtMargins = true;
              printDocument.BeginPrint += new PrintEventHandler(printDocument_BeginPrint);
              printDocument.PrintPage += new PrintPageEventHandler(printDocument_PrintPage);

              Dictionary<String, Object> paperSettings = Printing.getPaperSettings(grtArguments);
              printDocument.DefaultPageSettings.Landscape = (string)paperSettings["orientation"] == "landscape";

              // Sizes must be given in inch * 100 (sigh).
              int paperWidth = (int)Math.Round((double)paperSettings["width"] / 0.254);
              int paperHeight = (int)Math.Round((double)paperSettings["height"] / 0.254);
              PaperSize paperSize = new PaperSize("Ignored anyway", paperWidth, paperHeight);

              if ((bool)paperSettings["marginsSet"])
            printDocument.DefaultPageSettings.Margins =
              new Margins((int)paperSettings["marginLeft"], (int)paperSettings["marginRight"],
            (int)paperSettings["marginTop"], (int)paperSettings["marginBottom"]);

              System.Windows.Forms.PrintPreviewDialog preview = new System.Windows.Forms.PrintPreviewDialog();

              preview.Document = printDocument;
              preview.UseAntiAlias = true;

              preview.ShowDialog();
        }
Exemple #10
0
		private void filePrintPreviewMenuItem_Click(Object sender , 
			EventArgs e) 
		{
			PrintPreviewDialog dlg = new PrintPreviewDialog();
			dlg.Document = printDoc;
			dlg.ShowDialog();
		}
Exemple #11
0
        public void PrintTokens(List<TokenPrint> tokens, Form parentDialog, string PrinterName, bool showPrintPreview)
        {
            _tokensToPrint = tokens;
            _pageCounter = 0;
            //bool showPrintPreview = true;
            PrintDocument pd = new PrintDocument();
            PrintDocument pd1 = new PrintDocument();

            pd.DefaultPageSettings.PaperSize = paperSize;
            pd.PrintPage += printDoc_PrintPage;
            pd.PrinterSettings.PrinterName = PrinterName;

            //ToDo: can remove preview in the actual production.
            if (showPrintPreview)
            {
                var ppDlg = new PrintPreviewDialog();
                ppDlg.SetBounds(30, 30, 1024, 500);
                ppDlg.PrintPreviewControl.AutoZoom = true;
                ppDlg.PrintPreviewControl.Zoom = 0.75;
                ppDlg.Document = pd;
                var dr = ppDlg.ShowDialog(parentDialog);
            }
            else
            {
                pd.Print();
            }
        }
 /// <summary>
 /// Shows the print preview dialog</summary>
 public void ShowPrintPreviewDialog()
 {
     PrintPreviewDialog dialog = new PrintPreviewDialog();
     PrintDocument printDocument = GetPrintDocument();
     dialog.Document = printDocument;
     dialog.ShowDialog();
 }
        /// <summary>
        /// A utility method to print preview and print an Aspose.Words document.
        /// </summary>
        internal static void Execute(Document document)
        {
            // This operation can take some time (for the first page) so we set the Cursor to WaitCursor.
            Cursor cursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;

            PrintPreviewDialog previewDlg = new PrintPreviewDialog();

            // Initialize the Print Dialog with the number of pages in the document.
            PrintDialog printDlg = new PrintDialog();
            printDlg.AllowSomePages = true;
            printDlg.PrinterSettings = new PrinterSettings();
            printDlg.PrinterSettings.MinimumPage = 1;
            printDlg.PrinterSettings.MaximumPage = document.PageCount;
            printDlg.PrinterSettings.FromPage = 1;
            printDlg.PrinterSettings.ToPage = document.PageCount;

            // Restore cursor.
            Cursor.Current = cursor;

            // Interesting, but PrintDialog will not show and will always return cancel
            // if you run this application in 64-bit mode.
            if (!printDlg.ShowDialog().Equals(DialogResult.OK))
                return;

            // Create the Aspose.Words' implementation of the .NET print document
            // and pass the printer settings from the dialog to the print document.
            AsposeWordsPrintDocument awPrintDoc = new AsposeWordsPrintDocument(document);
            awPrintDoc.PrinterSettings = printDlg.PrinterSettings;

            // Pass the Aspose.Words' print document to the .NET Print Preview dialog.
            previewDlg.Document = awPrintDoc;

            previewDlg.ShowDialog();
        }
Exemple #14
0
        private static int TotalWidth; // Summation of Columns widths

        #endregion Fields

        #region Methods

        public static void Print_DataGridView(DataGridView dgv1)
        {
            PrintPreviewDialog ppvw;
            try
            {
                // Getting DataGridView object to print
                dgv = dgv1;

                // Getting all Coulmns Names in the DataGridView
                AvailableColumns.Clear();
                foreach (DataGridViewColumn c in dgv.Columns)
                {
                    if (!c.Visible) continue;
                    AvailableColumns.Add(c.HeaderText);
                }

                // Showing the PrintOption Form
                PrintOptions dlg = new PrintOptions(AvailableColumns);
                if (dlg.ShowDialog() != DialogResult.OK) return;

                PrintAllRows = dlg.PrintAllRows;
                FitToPageWidth = dlg.FitToPageWidth;
                SelectedColumns = dlg.GetSelectedColumns();

                RowsPerPage = 0;

                ppvw = new PrintPreviewDialog();
                ppvw.Document = printDoc;

                // Showing the Print Preview Page
                printDoc.BeginPrint +=new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                printDoc.PrintPage +=new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
                printDoc.DefaultPageSettings.Landscape = true;
                PaperSize paperSize = new PaperSize("Letter", 850, 1100);
                paperSize.RawKind = (int)PaperKind.Custom;
                printDoc.DefaultPageSettings.PaperSize = paperSize;
                if (ppvw.ShowDialog() != DialogResult.OK)
                {
                    printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                    printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
                    return;
                }

                // Printing the Documnet
                printDoc.DefaultPageSettings.Landscape = true;
                printDoc.DefaultPageSettings.PaperSize = paperSize;
                printDoc.Print();
                printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {

            }
        }
Exemple #15
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            PrintPreviewDialog dlg = new PrintPreviewDialog();

            dlg.Document = context.PrintDocument;

            dlg.ShowDialog();
        }
        public void Preview(string title, string text, Font font)
        {
            try
            {
                this.text  = text;
                this.font  = font;
                this.title = title;
                this.document.DocumentName = title;


                dialogPrintPreview.ShowDialog();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message.ToString());
            }
        }
Exemple #17
0
 private void button1_Click(object sender, EventArgs e)
 {
     PrintDocument document = new PrintDocument();
     document.PrintPage += new PrintPageEventHandler(document_PrintPage);
     PrintPreviewDialog preview = new PrintPreviewDialog();
     preview.Document = document;
     preview.ShowDialog(this);
 }
 private void btPrintPreview_Click(object sender, EventArgs e)
 {
     rowIndex            = 0;
     pageIndex           = 1;
     prnPreview.Document = prnDocument;
     //prnPreview.PrintPreviewControl.Zoom = 1;
     prnPreview.ShowDialog();
 }
Exemple #19
0
 public DialogResult PrintPreview()
 {
     var ppd = new PrintPreviewDialog();
     ppd.WindowState = FormWindowState.Maximized;
     ppd.Icon = ((Form)window).Icon;
     ppd.Document = PrintDocument;
     return ppd.ShowDialog(window);
 }
 // The Print Preview Button
 public void Preview(string title)
 {
     if (Setup(title))
       {
     var myPrintPreviewDialog = new PrintPreviewDialog {Document = printDocument};
     myPrintPreviewDialog.ShowDialog();
       }
 }
Exemple #21
0
 public DialogResult PrintPreview(ScintillaPrintDocument doc)
 {
     var ppd = new PrintPreviewDialog();
     ppd.WindowState = FormWindowState.Maximized;
     ppd.Icon = WB.Form.Icon;
     ppd.Document = doc;
     return ppd.ShowDialog(WB.Form);
 }
Exemple #22
0
		public DialogResult PrintPreview()
		{
			PrintPreviewDialog ppd = new PrintPreviewDialog();
			ppd.WindowState = FormWindowState.Maximized;

			ppd.Document = _printDocument;
			return ppd.ShowDialog();
		}
        public bool ShowPrintPreviewDialog(PrintDocument document)
        {
            var dialog = new WF.PrintPreviewDialog();

            dialog.Document = document;
            dialog.ShowIcon = false;
            return(dialog.ShowDialog() == WF.DialogResult.OK);
        }
 public void PrintPreview()
 {
     PrintPreviewDialog dlg = new PrintPreviewDialog();
     dlg.Document = printDocument;
     dlg.WindowState = FormWindowState.Maximized;
     dlg.ShowInTaskbar = false;            
     dlg.ShowDialog();
 }
Exemple #25
0
 private void bPay_Click(object sender, EventArgs e)
 {
     MessageBox.Show("Payment Options here");
     var ppd = new PrintPreviewDialog();
     PrintDocument pd = new PrintDocument();
     ppd.Document = pd;
     pd.PrintPage += Pd_PrintPage;
     ppd.ShowDialog();
 }
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (prop.PathReportsTemplates != "")
         {
             string y1, m1, d1, y2, m2, d2;
             string usrfilter;
             usrfilter = checkCurentUser.Checked ? "=" + usr.Id_user.ToString() : ">0";
             y1 = txtDateBegin.Value.Year.ToString();
             m1 = txtDateBegin.Value.Month < 10
                      ? "0" + txtDateBegin.Value.Month.ToString()
                      : txtDateBegin.Value.Month.ToString();
             d1 = txtDateBegin.Value.Day < 10
                      ? "0" + txtDateBegin.Value.Day.ToString()
                      : txtDateBegin.Value.Day.ToString();
             y2 = txtDateEnd.Value.Year.ToString();
             m2 = txtDateEnd.Value.Month < 10
                      ? "0" + txtDateEnd.Value.Month.ToString()
                      : txtDateEnd.Value.Month.ToString();
             d2 = txtDateEnd.Value.Day < 10
                      ? "0" + txtDateEnd.Value.Day.ToString()
                      : txtDateEnd.Value.Day.ToString();
             SqlCommand db_command =
                 new SqlCommand(
                 "SELECT name, CASE WHEN paper = 1 THEN 'Глянцевая бумага' ELSE 'Матовая бумага' END AS paper, SUM(t1) AS t1, SUM(t2) AS t2, SUM(t3) AS t3, SUM(t4) AS t4, SUM(t5) AS t5 FROM (SELECT name, paper, CASE WHEN (typeaction = 1 AND quantity > 0) THEN quantity ELSE 0 END AS t1, CASE WHEN (typeaction = 2 AND quantity > 0) THEN quantity ELSE 0 END AS t2, CASE WHEN (typeaction = 3 AND quantity > 0) THEN quantity ELSE 0 END AS t3, CASE WHEN (typeaction = 4 AND quantity > 0) THEN quantity ELSE 0 END AS t4, CASE WHEN (typeaction = 5 AND quantity > 0) THEN quantity ELSE 0 END AS t5 FROM (SELECT name, SUM(quantity) AS quantity, typeaction, paper FROM vwTehActionFull WHERE (datea >= CONVERT(datetime, '" + y1 + "/" + m1 + "/" + d1 + " 00:00:00.000', 120)) AND (datea <= CONVERT(datetime, '" + y2 + "/" + m2 + "/" + d2 + " 23:59:59.999', 120)) AND (id_user " + usrfilter + ") GROUP BY name, typeaction, paper) AS TMP) AS TMP2 GROUP BY name, paper",
                     db_connection);
             SqlDataAdapter db_adapter = new SqlDataAdapter(db_command);
             DataTable tbl = new DataTable("discarding");
             db_adapter.Fill(tbl);
             rep.Load(prop.PathReportsTemplates, "Discarding");
             rep.DataSource.Recordset = tbl;
             rep.Fields["titleDates"].Text = "с " + txtDateBegin.Value.ToShortDateString() + " по " +
                                             txtDateEnd.Value.ToShortDateString();
             if (checkCurentUser.Checked)
                 rep.Fields["titleDates"].Text += " для " + usr.Name;
             else
                 rep.Fields["titleDates"].Text += " для всех пользователей";
             PrintPreviewDialog pd = new PrintPreviewDialog();
             pd.Document = rep.Document;
             pd.ShowDialog();
         }
         else
         {
             MessageBox.Show("Не выбран файл шаблонов отчетов", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         ErrorNfo.WriteErrorInfo(ex);
         MessageBox.Show("Ошибка вывода отчета\n" + ex.Message + "\n" + ex.Source + "\n" + ex.StackTrace, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     finally
     {
         this.DialogResult = DialogResult.OK;
     }
 }
    public void PreviewDocument(Document document, PrinterSettings printerSettings)
    {
      fDocument = document;
      fPrintDocument.PrinterSettings = printerSettings;

      PrintPreviewDialog dlg = new PrintPreviewDialog();
      dlg.Document = fPrintDocument;
      dlg.ShowDialog();
    }
Exemple #28
0
        private void bunifuFlatButton2_Click(object sender, EventArgs e)
        {
            PrintPreviewDialog dlg = new System.Windows.Forms.PrintPreviewDialog();

            //dlg.Height = 250;
            //dlg.Width = 15000;
            dlg.Document = PrintDocument;
            dlg.ShowDialog();
        }
        private static int TotalWidth; // Summation of Columns widths

        #endregion Fields

        #region Methods

        public static void Print_DataGridView(DataGridView dgv1)
        {
            PrintPreviewDialog ppvw;
            try
            {
                // Getting DataGridView object to print
                dgv = dgv1;

                // Getting all Coulmns Names in the DataGridView
                AvailableColumns.Clear();
                foreach (DataGridViewColumn c in dgv.Columns)
                {
                    if (!c.Visible) continue;
                    AvailableColumns.Add(c.HeaderText);
                }

                // Showing the PrintOption Form
                OpcoesImprimir dlg = new OpcoesImprimir(AvailableColumns);
                if (dlg.ShowDialog() != DialogResult.OK) return;

                PrintTitle = dlg.PrintTitle;
                PrintAllRows = dlg.PrintAllRows;
                FitToPageWidth = dlg.FitToPageWidth;
                SelectedColumns = dlg.GetSelecionarColunas();

                RowsPerPage = 0;

                ppvw = new PrintPreviewDialog();
                ppvw.Document = printDoc;

                // Showing the Print Preview Page
                printDoc.DefaultPageSettings.Landscape = true;
                ((Form)ppvw).WindowState = FormWindowState.Maximized;
                printDoc.BeginPrint += new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                printDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
                if (ppvw.ShowDialog() != DialogResult.OK)
                {
                    printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                    printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
                    return;
                }

                // Printing the Documnet
                printDoc.Print();
                printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {

            }
        }
 // The Print Preview Button
 private void btnPrintPreview_Click(object sender, EventArgs e)
 {
     if (SetupThePrinting())
        {
     PrintPreviewDialog MyPrintPreviewDialog = new PrintPreviewDialog();
     MyPrintPreviewDialog.Document = MyPrintDocument;
     MyPrintPreviewDialog.ShowDialog();
     this.Close();
        }
 }
 private void btnPrintPreview_Click(object sender,EventArgs e)
 {
     if(SetupThePrinting()) {
         PrintPreviewDialog MyPrintPreviewDialog = new PrintPreviewDialog();
         MyPrintPreviewDialog.Document = MyPrintDocument;
         MyPrintPreviewDialog.PrintPreviewControl.Zoom = 1.0;
         ((Form)MyPrintPreviewDialog).WindowState = FormWindowState.Maximized;
         MyPrintPreviewDialog.ShowDialog();
     }
 }
        public void ePrint(string printPage = "OR")
        {
            PrintDialog printDioalog = new PrintDialog();
            PrintDocument printDocument = new PrintDocument();
            PrintPreviewDialog previewDialog = new PrintPreviewDialog();

            previewDialog.Height = 600;
            previewDialog.Width = 800;

            previewDialog.PrintPreviewControl.Rows = 10;

            // set properties
            if (isLandscape)
                printDocument.DefaultPageSettings.Landscape = true;

            printDioalog.Document = printDocument;

            switch (printPage)
            {
                case "OR":
                {

                    printDocument.PrintPage += new PrintPageEventHandler(ePrint_officialReceipt);
                    break;
                }
                case "OP":
                {
                    printDocument.PrintPage += new PrintPageEventHandler(ePrint_orderOfPayment);
                    break;
                }
                case "DRLayoutOne":
                {
                    printDocument.PrintPage += new PrintPageEventHandler(ePrint_dailyReportLayoutOne);
                    break;
                }

            }

            if (forReport)
            {
                // do some Stuff
                // Show Print Preview Dialog
                previewDialog.Document = printDocument;

                previewDialog.ShowDialog();
                printDocument.DefaultPageSettings.PaperSize = new PaperSize("Legal", 850, 1400);
            }

            DialogResult result = printDioalog.ShowDialog();

            if (result == DialogResult.OK)
            {
                printDocument.Print();
            }
        }
Exemple #33
0
        private static int TotalWidth; // Summation of Columns widths

        #endregion Fields

        #region Methods

        public static void Print_DataGrid(C1.Win.C1FlexGrid.C1FlexGrid dgF, String title)
        {
            PrintTitle = title;
            PrintPreviewDialog ppvw;
            try
            {
                dg = dgF;
                PrintFont = dg.Font;
                PrintFontColor = dg.ForeColor;

                //khoaht added
                foreach (Column c in dg.Cols)
                    if (c.Visible)
                        AvailableColumns.Add(c.Caption);

                // Show PrintOption Form
                PrintOptions dlg = new PrintOptions(PrintTitle, AvailableColumns);
                //if (dlg.ShowDialog() != DialogResult.OK) return;

                PrintTitle = dlg.PrintTitle;
                PrintAllRows = dlg.PrintAllRows;
                SelectedColumns = dlg.GetSelectedColumns();
                if (dlg.PrintFont != null) PrintFont = dlg.PrintFont;
                if (dlg.PrintFontColor.Name != "" & dlg.PrintFontColor.Name != "0")
                    PrintFontColor = dlg.PrintFontColor;

                RowsPerPage = 0;

                ppvw = new PrintPreviewDialog();
                ppvw.Document = printDoc;

                // Show Print Preview Page
                printDoc.BeginPrint += new System.Drawing.Printing.PrintEventHandler(printDoc_BeginPrint);
                printDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDoc_PrintPage);
                if (ppvw.ShowDialog() != DialogResult.OK)
                {
                    printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(printDoc_BeginPrint);
                    printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(printDoc_PrintPage);
                    return;
                }

                // Print the Documnet
                printDoc.Print();
                printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(printDoc_BeginPrint);
                printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(printDoc_PrintPage);
            }
            catch (Exception ex)
            {
                MsgBoxVN.ShowError(ex.Message, Dic.STRING_TITLE_ERROR);
            }
            finally
            {

            }
        }
Exemple #34
0
        private static int TotalWidth; // Summation of Columns widths

        #endregion Fields

        #region Methods

        public static void Print_DataGridView(DataGridView dgv1, String title)
        {
            PrintPreviewDialog ppvw;
            titleReport = title;
            try
            {
                // Getting DataGridView object to print
                dgv = dgv1;

                // Getting all Coulmns Names in the DataGridView
                AvailableColumns.Clear();
                foreach (DataGridViewColumn c in dgv.Columns)
                {
                    if (!c.Visible) continue;
                    AvailableColumns.Add(c.HeaderText);
                }

                // Showing the PrintOption Form
                PrintOptions dlg = new PrintOptions(AvailableColumns);
                if (dlg.ShowDialog() != DialogResult.OK) return;
                //PrintTitle = dlg.PrintTitle;
                //PrintAllRows = dlg.PrintAllRows;
                //FitToPageWidth = dlg.FitToPageWidth;
                PrintAllRows = true;
                FitToPageWidth = true;
                SelectedColumns = dlg.GetSelectedColumns();
                RowsPerPage = 0;

                ppvw = new PrintPreviewDialog();
                ppvw.Document = printDoc;

                // Showing the Print Preview Page
                printDoc.BeginPrint += new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                printDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
                if (ppvw.ShowDialog() != DialogResult.OK)
                {
                    printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                    printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
                    return;
                }

                // Printing the Documnet
                printDoc.Print();
                printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {

            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            PrintDocument pd = new PrintDocument();
            pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);

            PrintPreviewDialog ppd = new PrintPreviewDialog();
            ppd.Document = pd;

            // 인쇄 미리보기 창 출력시 PrintPage 메서드가 실행되게 됨
            ppd.ShowDialog();
        }
Exemple #36
0
 private void mnuPrintPreview_Click(object sender, EventArgs e)
 {
     System.Windows.Forms.PrintPreviewDialog dlg;
     dlg = new System.Windows.Forms.PrintPreviewDialog();
     prdJump.DocumentName              = Neptune.DevInfo.ProductName + " " + Neptune.DevInfo.SN + " " + this.Text;
     dlg.Document                      = prdJump;
     dlg.UseAntiAlias                  = true;
     dlg.PrintPreviewControl.AutoZoom  = true;
     dlg.PrintPreviewControl.BackColor = System.Drawing.SystemColors.ActiveCaption;
     dlg.ShowDialog();
 }
Exemple #37
0
 /// <summary>
 /// 显示打印预览
 /// </summary>
 public void ShowPreview()
 {
     try{
         if (_PreviewDialog.ShowDialog() == DialogResult.OK)
         {
         }
     }
     catch {
         MessageBox.Show("打印出错,请检查本地或者网络打印机是否正确安装!", "打印提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #38
0
 private void DisplayInvoice()
 {
     prnPreview.Document = this.prnDocument;
     try
     {
         prnPreview.ShowDialog();
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString());
     }
 }
        private void ShowPreviewWithDialog(AbstractRenderer renderer, double zoomFaktor)
        {
            System.Drawing.Printing.PrintDocument doc = renderer.ReportDocument;

            printPreviewControl1.InvalidatePreview();
            previewDlg.Document                 = doc;
            previewDlg.Text                     = renderer.ReportSettings.ReportName;
            previewDlg.Text                     = renderer.ReportSettings.ReportName;
            previewDlg.StartPosition            = FormStartPosition.CenterParent;
            previewDlg.PrintPreviewControl.Zoom = zoomFaktor;
            previewDlg.ShowDialog();
        }
Exemple #40
0
        private void simpleButton4_Click(object sender, System.EventArgs e)
        {
//			printDialog1.ShowDialog();
            printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDocument1_PrintPage);

//			printDialog1.Document = printDocument1;
//			printDialog1.ShowDialog();
            pageSetupDialog1.Document = printDocument1;
            pageSetupDialog1.ShowDialog();

            printPreviewDialog1.Document = printDocument1;
            printPreviewDialog1.ShowDialog();
        }
Exemple #41
0
        //显示打印预览窗口
        private void ShowPrintPreview()
        {
            try
            {
                printPreviewDialog1.ShowDialog();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                System.Windows.MessageBox.Show(e.Message, "Error");

                //throw;
            }
        }
Exemple #42
0
 private void mnuPrintPreview_Click(object sender, System.EventArgs e)
 {
     try
     {
         if (_activeControl is IPrintableUserControl)
         {
             printPreviewDialog.Document = ((IPrintableUserControl)_activeControl).PrintDocument;
             printPreviewDialog.ShowDialog(this);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, "Unable to print. " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #43
0
        private void prntPrevMenu_Click(object sender, System.EventArgs e)
        {
            pagenum = 0;
            if (activeReport != null)
            {
                printRep = ReportBuilder.ReloadRep(activeReport, true);

                /**
                 * this.Controls.Remove(activeReport);
                 * activeReport = printRep;
                 * this.Controls.Add(activeReport);
                 **/
                printPreviewDialog1.ShowDialog(this);
            }
        }
Exemple #44
0
        private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            switch (toolBar1.Buttons.IndexOf(e.Button))
            {
            case 0:
                printDialog.ShowDialog();
                break;

            case 1:
                printPreviewDialog.ShowDialog();
                break;

            case 2:
                pageSetupDialog.ShowDialog();
                break;

            case 4:
                timer1.Enabled = !timer1.Enabled;
                break;

            default:
                break;
            }
        }
Exemple #45
0
        public void Print(int printItem = 1)
        {
            PrintDocument recordDoc;

            // Create the document and name it
            recordDoc = new PrintDocument();
            recordDoc.DocumentName = "Inventory Receipt";
            PaperSize ps = new PaperSize();

            ps.RawKind = 119;
            ps.Width   = 200;
            recordDoc.DefaultPageSettings.PaperSize    = ps;
            recordDoc.DefaultPageSettings.Margins.Top  = 1;
            recordDoc.DefaultPageSettings.Margins.Left = 1;
            if (printItem == 1)
            {
                recordDoc.PrintPage += new PrintPageEventHandler(this.PrintReceiptPage);
                CalculatePrint();
            }
            else
            {
                recordDoc.PrintPage += new PrintPageEventHandler(this.PrintUtangPage);
                CalculateUtangPrint();
            }
            ps.Height = m_ReceiptSize;

            // Preview document
            System.Windows.Forms.PrintPreviewDialog dlgPreview = new System.Windows.Forms.PrintPreviewDialog();
            dlgPreview.Document = recordDoc;

            Profile _myProfile = new Profile();

            _myProfile.ReadXML();
            if (_myProfile.EnablePreview == true)
            {
                dlgPreview.ShowDialog();
            }
            else
            {
                recordDoc.Print();
                dlgPreview.Close();
            }
            // Dispose of document when done printing
            recordDoc.Dispose();
        }
Exemple #46
0
 public void ShowPrintDialog()
 {
     oPrintDialog.Document = printDoc;
     if (oPrintDialog.ShowDialog() == DialogResult.OK)
     {
         try
         {
             oPageSettings.PrinterSettings = printDoc.PrinterSettings;
             printDoc.DefaultPageSettings  = oPageSettings;
             ppDialog.Document             = printDoc;
             ppDialog.ShowDialog();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
     }
 }
Exemple #47
0
 //打印预览
 public void m_mthprintPreview()
 {
     #region 打印设置
     PaperSize PS = null;
     foreach (PaperSize objPs in ((System.Drawing.Printing.PrintDocument)printDocument1).PrinterSettings.PaperSizes)
     {
         if (objPs.PaperName == "LIS_QC")
         {
             PS = objPs;
             break;
         }
     }
     if (PS != null)
     {
         ((System.Drawing.Printing.PrintDocument)printDocument1).DefaultPageSettings.PaperSize = PS;
     }
     else
     {
         try
         {
             string strWidth  = "26";
             string strHeight = "18.4";
             if (Microsoft.VisualBasic.Information.IsNumeric(strWidth) &&
                 Microsoft.VisualBasic.Information.IsNumeric(strHeight))
             {
                 double       dblWidth_cm      = double.Parse(strWidth);             //double.Parse(this.m_txtPaperWidth.Text.Trim());
                 double       dblHeight_cm     = double.Parse(strHeight);            //double.Parse(this.m_txtPaperHeight.Text.Trim());
                 int          intWidth_01mm    = (int)(dblWidth_cm * 100);
                 int          intHeight_01mm   = (int)(dblHeight_cm * 100);
                 int          intWidth_001inc  = System.Drawing.Printing.PrinterUnitConvert.Convert(intWidth_01mm, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display);
                 int          intHeight_001inc = System.Drawing.Printing.PrinterUnitConvert.Convert(intHeight_01mm, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display);
                 PageSettings ps = printDocument1.DefaultPageSettings;
                 ps.PaperSize = new PaperSize("LIS_QC", intWidth_001inc, intHeight_001inc);
             }
         }
         catch
         {
             MessageBox.Show("打印机故障!", "iCare", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     #endregion
     m_printPrevDlg.Document = printDocument1;
     m_printPrevDlg.ShowDialog();
 }
Exemple #48
0
 public override void Run(Altaxo.Graph.GUI.GraphController ctrl)
 {
     try
     {
         System.Windows.Forms.PrintPreviewDialog dlg = new System.Windows.Forms.PrintPreviewDialog();
         Current.PrintingService.PrintDocument.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(ctrl.EhPrintPage);
         dlg.Document = Current.PrintingService.PrintDocument;
         dlg.ShowDialog(ctrl.View.Form);
         dlg.Dispose();
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show(ctrl.View.Form, ex.ToString());
     }
     finally
     {
         Current.PrintingService.PrintDocument.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(ctrl.EhPrintPage);
     }
 }
Exemple #49
0
        private void printOutSummary()
        {
            printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDocument1_PrintPage);
            printPreviewDialog1.Document = printDocument1;

            paperLength = calculatePaperLength();

            PaperSize psize = new PaperSize("Custom", 255, paperLength);
            printDocument1.DefaultPageSettings.PaperSize = psize;
            DialogResult result;
            printPreviewDialog1.Width = 512;
            printPreviewDialog1.Height = 768;

            result = printPreviewDialog1.ShowDialog();
            if (result == DialogResult.OK)
            {
                printDocument1.Print();
            }
        }
Exemple #50
0
        public void InitPrintPreview()
        {
            printDoc.EndPrint          += new PrintEventHandler(printDoc_EndPrint);
            printDoc.PrintPage         += new System.Drawing.Printing.PrintPageEventHandler(this.printDoc_PrintPage);
            printDoc.QueryPageSettings += new QueryPageSettingsEventHandler(this.printDoc_QueryPageSettings);
            printDoc.BeginPrint        += new PrintEventHandler(printDoc_BeginPrint);


            //this.printPreviewDialog.AutoScrollMargin = new System.Drawing.Size(0, 0);
            //this.printPreviewDialog.AutoScrollMinSize = new System.Drawing.Size(0, 0);

            //this.printPreviewDialog.ClientSize = new System.Drawing.Size(1400, 1300);
            this.printPreviewDialog.Document = this.printDoc;
            this.printPreviewDialog.Enabled  = true;
            this.printPreviewDialog.Name     = "printPreviewDialog1";
            (this.printPreviewDialog as Form).WindowState = FormWindowState.Maximized;
            (this.printPreviewDialog as Form).AutoScroll  = true;
            //this.printDoc.Print();
            printPreviewDialog.ShowDialog();
        }
        public void ShowPrintDialog()
        {
            //Set to defaults

            oPrintDialog.Document = printDoc;
            if (oPrintDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    //Ensure the correct PrinterSettings object is used
                    oPageSettings.PrinterSettings = printDoc.PrinterSettings;
                    //Assign PageSettings object to all pages
                    printDoc.DefaultPageSettings = oPageSettings;
                    ppDialog.Document            = printDoc;
                    ppDialog.ShowDialog();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Exemple #52
0
 public override bool ShowPrintPreviewDialog(PrintPageEventHandler printPageEventHandler, QueryPageSettingsEventHandler queryPageSettingsEventHandler)
 {
     try
     {
         System.Windows.Forms.PrintPreviewDialog dlg = new System.Windows.Forms.PrintPreviewDialog();
         Current.PrintingService.PrintDocument.PrintPage         += printPageEventHandler;
         Current.PrintingService.PrintDocument.QueryPageSettings += queryPageSettingsEventHandler;
         dlg.Document = Current.PrintingService.PrintDocument;
         dlg.ShowDialog(MainWindow);
         dlg.Dispose();
         return(true);
     }
     catch (Exception ex)
     {
         Current.Gui.ErrorMessageBox(ex.ToString());
     }
     finally
     {
         Current.PrintingService.PrintDocument.PrintPage         -= printPageEventHandler;
         Current.PrintingService.PrintDocument.QueryPageSettings -= queryPageSettingsEventHandler;
     }
     return(false);
 }
Exemple #53
0
 public void Preview()
 {
     printPreviewDialog1.PrintPreviewControl.Zoom = 1;
     this.printPreviewDialog1.WindowState         = FormWindowState.Maximized;
     printPreviewDialog1.ShowDialog();
 }
Exemple #54
0
 private void miFilePrintPreview_Click(object sender, System.EventArgs e)
 {
     dlgPrintPreview.ShowDialog();
 }
 private void btnPrintPreview_Click(object sender, System.EventArgs e)
 {
     printPreviewDialog1.ShowDialog();
 }
Exemple #56
0
 private void menuItem7_Click(object sender, System.EventArgs e)
 {
     printPreviewDialog1.Document = printDocument1;
     printPreviewDialog1.ShowDialog();
 }
Exemple #57
0
 private void printPreviewClick(object sender, System.EventArgs e)
 {
     printPreviewDialog.Document = printDocument;
     DialogResult res = printPreviewDialog.ShowDialog();
 }
Exemple #58
0
 private void buttonPrint_Click(object sender, System.EventArgs e)
 {
     printPreviewDialog1.Bounds = this.Bounds;
     printPreviewDialog1.ShowDialog();
 }
Exemple #59
0
 // Print Preview
 private void miPreview_Click(object sender, System.EventArgs e)
 {
     // Call Dialog Box
     printPreviewDialog1.ShowDialog();
 }
Exemple #60
-2
        public void print()
        {
            PrintDialog pd = new PrintDialog();
            pdoc = new PrintDocument();
            PrinterSettings ps = new PrinterSettings();
            Font font = new Font("Courier New", 15);

            PaperSize psize = new PaperSize("Custom", 300, 100);
            ps.DefaultPageSettings.PaperSize = psize;

            pd.Document = pdoc;
            pd.Document.DefaultPageSettings.PaperSize = psize;

            pdoc.DefaultPageSettings.PaperSize = psize;

            pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);

            DialogResult result = pd.ShowDialog();
            if (result == DialogResult.OK)
            {
                PrintPreviewDialog pp = new PrintPreviewDialog();
                pp.Document = pdoc;

                result = pp.ShowDialog();
                if (result == DialogResult.OK)
                {
                    pdoc.Print();
                }
            }
        }