Exemplo n.º 1
0
        private void _printButton_Click(object sender, EventArgs e)
        {
            using (var form = new PrintDialog())
            using (var document = _document.CreatePrintDocument())
            {
                form.AllowSomePages = true;
                form.Document = document;
                form.UseEXDialog = true;
                form.Document.PrinterSettings.FromPage = 1;
                form.Document.PrinterSettings.ToPage = _document.PageCount;

                if (form.ShowDialog(FindForm()) == DialogResult.OK)
                {
                    try
                    {
                        if (form.Document.PrinterSettings.FromPage <= _document.PageCount)
                            form.Document.Print();
                    }
                    catch
                    {
                        // Ignore exceptions; the printer dialog should take care of this.
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void tsddButtonImprimir_Click(object sender, EventArgs e)
        {
            Parametros configCfd = new Parametros(DatosConexionDB.Elemento.Intercompany);   //Carga configuración desde xml

            var pdialago = new System.Windows.Forms.PrintDialog();

            configCfd.NombreImpresora     = pdialago.PrinterSettings.PrinterName;
            tsComboDestinoRep.ToolTipText = configCfd.NombreImpresora;

            txtbxMensajes.Text = "";
            txtbxMensajes.Refresh();

            tsComboDestinoRep.Enabled = false;
            if (!configCfd.emite && configCfd.reporteador.Equals("CRYSTAL"))    //Se habilitó esta opción porque el visor de crystal no puede imprimir.
            {
                tsComboDestinoRep.Enabled = true;
            }

            if (dGridActivo.CurrentRow != null)
            {
                if (dGridActivo.CurrentCell.Selected)
                {
                    tsTextDesde.Text = dGridActivo.CurrentRow.Cells[idxSopnumbe].Value.ToString();
                    tsTextHasta.Text = dGridActivo.CurrentRow.Cells[idxSopnumbe].Value.ToString();
                }
                else
                {
                    txtbxMensajes.Text = "No seleccionó ninguna factura. Debe marcar la factura que desea imprimir y luego presionar el botón de impresión.";
                }
            }
        }
Exemplo n.º 3
0
        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", 219, 1000);
            pd.Document = pdoc;
            //pd.Document.DefaultPageSettings.PaperSize = psize;

            if (pd.Document.DefaultPageSettings.PaperSize.Width <= 284)
            {
                k = Convert.ToDouble(pd.Document.DefaultPageSettings.PaperSize.Width) / 284;
            }

            pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);

            DialogResult result = pd.ShowDialog();
            if (result == DialogResult.OK)
            {
                PrintPreviewDialog pp = new PrintPreviewDialog();
                pp.Document = pdoc;
                System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
                pp.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
                pp.PrintPreviewControl.Zoom = 1f;
                result = pp.ShowDialog();
                if (result == DialogResult.OK)
                {
                    pdoc.Print();
                }
            }
        }
Exemplo n.º 4
0
        private Boolean Print()
        {
            Boolean returnValue = default(Boolean);

            System.Windows.Forms.PrintDialog printDialog = new System.Windows.Forms.PrintDialog();
            Boolean?dialogResult = (printDialog.ShowDialog() == DialogResult.OK);

            if (dialogResult.HasValue && dialogResult.Value)
            {
                try
                {
                    //printDialog.PrintVisual(/*_view.ChartControl*/, "app_name");

                    returnValue = true;
                }
                catch (Exception ex)
                {
                    Log.Write(ex, MethodBase.GetCurrentMethod(), EventLogEntryType.Error);

                    throw ex;
                }
            }

            return(returnValue);
        }
Exemplo n.º 5
0
 public override void Print(bool ShowDialog)
 {
     printDoc = new PrintDocument();
         printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
         pd = new PrintDialog();
         pd.Document = printDoc;
         pd.AllowSomePages = true;
         if ((!ShowDialog) || (pd.ShowDialog() == DialogResult.OK))
         {
             printDoc.DocumentName = "debuglog-" + DateTime.Now.Date.ToShortDateString() + ".txt";
             strPrintText = RawTrafficText.Text.Length > 0 ? RawTrafficText.Text : " ";
             switch (pd.PrinterSettings.PrintRange)
             {
                 case PrintRange.AllPages:
                     startPage = 1;
                     totalPages = pd.PrinterSettings.MaximumPage;
                     break;
                 case PrintRange.SomePages:
                     startPage = pd.PrinterSettings.FromPage;
                     totalPages = pd.PrinterSettings.ToPage - startPage + 1;
                     break;
             }
             // start printing
             pageNumber = 1;
             printDoc.Print();
         }
 }
        // The printing setup function
        private bool SetupThePrinting()
        {
            PrintDialog MyPrintDialog = new PrintDialog();
               MyPrintDialog.AllowCurrentPage = false;
               MyPrintDialog.AllowPrintToFile = false;
               MyPrintDialog.AllowSelection = false;
               MyPrintDialog.AllowSomePages = false;
               MyPrintDialog.PrintToFile = false;
               MyPrintDialog.ShowHelp = false;
               MyPrintDialog.ShowNetwork = false;

               if (MyPrintDialog.ShowDialog() != DialogResult.OK)
            return false;
               MyPrintDocument.DocumentName = "Planilla de ventas peluquería";
               MyPrintDialog.PrinterSettings.DefaultPageSettings.Landscape = true; //página horizontal
               //MyPrintDialog.PrinterSettings.DefaultPageSettings.Landscape = false; //página vertical
               MyPrintDocument.PrinterSettings = MyPrintDialog.PrinterSettings;
               MyPrintDocument.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings;
               MyPrintDocument.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40);

               //if (MessageBox.Show("¿Desea centrar el reporte en la pagina?",
               // "InvoiceManager - Center on Page", MessageBoxButtons.YesNo,
               // MessageBoxIcon.Question) == DialogResult.Yes)
               // MyDataGridViewPrinter = new DataGridViewPrinter(MyDataGridView,
               // MyPrintDocument, true, true, "Listado Completo de Facturas", new Font("Tahoma", 15,
               // FontStyle.Bold, GraphicsUnit.Point), Color.Black, true);
               //else
               string encabezado = "Vendedor: Cecilia Toscani             Zona: " + txtZona.Text + "               Fecha: " + DateTime.Now.ToLongDateString();
            MyDataGridViewPrinter = new DataGridViewPrinter(MyDataGridView,
            MyPrintDocument, false, true, encabezado, new Font("Tahoma", 13,
            FontStyle.Bold, GraphicsUnit.Point), Color.Black, true);
               return true;
        }
Exemplo n.º 7
0
 internal static bool showPrintDialog(
     PrintDialog printDialog,
     ref string deviceName,
     ref string driverName,
     ref string port,
     ref csReportPaperType paperSize,
     ref int orientation,
     ref int fromPage,
     ref int toPage,
     ref int copies,
     ref int paperBin)
 {
     printDialog.AllowSomePages = true;
     var settings = printDialog.PrinterSettings;
     settings.PrinterName = deviceName;
     settings.FromPage = fromPage;
     settings.ToPage = toPage;
     settings.Copies = (short)copies;
     if (printDialog.ShowDialog() == DialogResult.OK)
     {
         deviceName = settings.PrinterName;
         fromPage = settings.FromPage;
         toPage = settings.ToPage;
         copies = settings.Copies;
         return true;
     }
     else
     {
         return false;
     }
 }
Exemplo n.º 8
0
        private void TmrPrint_Tick(object sender, EventArgs e)
        {
            pnlPrint.Visible = false;
            TmrPrint.Enabled = false;

            using (System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument())
            {
                printDocument.PrintPage += printDocument_PrintPage;
                CaptureScreen();
                try
                { 
                    
                    PrintDialog dlg = new PrintDialog();
                    dlg.Document = printDocument;
                    dlg.PrinterSettings.Copies = 3;
                    if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        printDocument.PrinterSettings = dlg.PrinterSettings;
                        printDocument.Print();
                    }
                    else
                    {
                        pnlPrint.Visible = true;
                        return;
                    }
                }
                catch (Exception ex)
                { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,MessageBoxIcon.Error); }
            }
            Close();
            pnlPrint.Visible = true;
            
        }
Exemplo n.º 9
0
        public void Printing()
        {
            PrintDialog pDialog = new PrintDialog();
            FileStream fs = new FileStream(@"Szervíz_Feltételek.txt", FileMode.Open, FileAccess.Read);
            StreamReader sr = new StreamReader(fs);

            contract = sr.ReadToEnd();

            try
            {
                try
                {
                    PrintDocument pd = new PrintDocument();
                    pd.PrintPage += new PrintPageEventHandler(pd_PrintRent);

                    if (pDialog.ShowDialog() == DialogResult.OK)
                    {
                        pd.PrinterSettings = pDialog.PrinterSettings;
                        // Print the document.
                        pd.Print();
                    }

                }
                finally
                {

                }
            }
            catch (Exception ex)
            {

            }
        }
Exemplo n.º 10
0
        //Stream streamToPrint, string streamType
        //2�����Print��ӡ����
        public void StartPrint()
        {
            //����ֵ��PageSettings A4\A5
            PageSettings ps = new PageSettings();
            //��ʾ���ô�ӡҳ�Ի���
            PageSetupDialog Psdl = new PageSetupDialog();
            //��ӡ������ã�ע�⣬�÷��������printpage�������档
            PrintDialog pt = new PrintDialog();
            pt.AllowCurrentPage = true;
            pt.AllowSomePages = true;
            pt.AllowPrintToFile = true;
            //       StreamToPrint = streamToPrint;//��ӡ���ֽ���
            //       StreamType = streamType; //��ӡ������
            //       printDocument1.DocumentName = Filename; //��ӡ���ļ���
            Psdl.Document = printDocument1;
            //       PrintPreview.Document = printDocument1;
            pt.Document = printDocument1;
            Psdl.PageSettings = printDocument1.DefaultPageSettings;
            try
            {
                //ҳ�����öԻ���
                if (Psdl.ShowDialog() == DialogResult.OK)
                {
                    ps = Psdl.PageSettings;
                    printDocument1.DefaultPageSettings = Psdl.PageSettings;
                }
                //ѡ���ӡ���Ի���
                if (pt.ShowDialog() == DialogResult.OK)
                {
                    printDocument1.PrinterSettings.Copies = pt.PrinterSettings.Copies;
                    //printDocument1.Print();
                    if (!checkBoxAll.Checked)
                    {
                        printDocument1.Print();
                    }
                    else
                    {
                        for (int i = 0; i < dataGridView1.RowCount; i++)
                        {
                            ShowTag(i);
                            printDocument1.Print();
                        }
                    }

                }
                ////��ӡԤ���Ի���
                //if (PrintPreview.ShowDialog() == DialogResult.OK)
                //{
                //    //���ô�ӡ
                //    printDocument1.Print();
                //}

                //PrintDocument�����Print()������PrintController����ִ��PrintPage�¼���
            }
            catch (InvalidPrinterException ex)
            {
                MessageBox.Show(ex.Message, "Simple Editor", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
Exemplo n.º 11
0
 public void PrintDoc()
 {
     System.Windows.Forms.PrintDialog dialog = new System.Windows.Forms.PrintDialog();
     if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         pagecontrol = new PageControl(settings[0]);
         if (pagecontrol.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             if (dialog.PrinterSettings.PrintToFile == false)
             {
                 control.PrintDocument(dialog.PrinterSettings, text);
                 File.AppendAllText(Environment.CurrentDirectory + "\\Output", pagecontrol.output);
                 this.Close();
             }
         }
         else
         {
             System.Windows.Forms.MessageBox.Show("Printing was canceled");
         }
     }
     else
     {
         System.Windows.Forms.MessageBox.Show("Printing was canceled");
     }
 }
Exemplo n.º 12
0
 public override void Run()
 {
     IWorkbenchWindow activeWorkbenchWindow = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
     if (activeWorkbenchWindow != null)
     {
         if (activeWorkbenchWindow.ViewContent is IPrintable)
         {
             PrintDocument printDocument = ((IPrintable) activeWorkbenchWindow.ViewContent).PrintDocument;
             if (printDocument != null)
             {
                 using (PrintDialog dialog = new PrintDialog())
                 {
                     dialog.Document = printDocument;
                     dialog.AllowSomePages = true;
                     if (dialog.ShowDialog(WorkbenchSingleton.MainForm) == DialogResult.OK)
                     {
                         printDocument.Print();
                     }
                 }
             }
             else
             {
                 MessageService.ShowError("${res:SkyMap.Net.Commands.Print.CreatePrintDocumentError}");
             }
         }
         else
         {
             MessageService.ShowError("${res:SkyMap.Net.Commands.Print.CantPrintWindowContentError}");
         }
     }
 }
Exemplo n.º 13
0
 private void btnin_Click(object sender, EventArgs e)
 {
     if(issave == false)
     {
         if(MessageBox.Show("Bạn phải lưu trước khi in, lưu ngay?", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             btnluu.PerformClick();
             System.Drawing.Printing.PrintDocument myPrintDocument1 = new System.Drawing.Printing.PrintDocument();
             PrintDialog myPrinDialog1 = new PrintDialog();
             myPrintDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(myPrintDocument2_PrintPage);
             myPrinDialog1.Document = myPrintDocument1;
             if (myPrinDialog1.ShowDialog() == DialogResult.OK)
             {
                 myPrintDocument1.Print();
                 MessageBox.Show("In phiếu đặt chỗ thành công!", "Thông báo");
             }
         }
         else
         {
             System.Drawing.Printing.PrintDocument myPrintDocument1 = new System.Drawing.Printing.PrintDocument();
             PrintDialog myPrinDialog1 = new PrintDialog();
             myPrintDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(myPrintDocument2_PrintPage);
             myPrinDialog1.Document = myPrintDocument1;
             if (myPrinDialog1.ShowDialog() == DialogResult.OK)
             {
                 myPrintDocument1.Print();
                 MessageBox.Show("In phiếu đặt chỗ thành công!", "Thông báo");
             }
         }
     }
 }
Exemplo n.º 14
0
        private void btstampa_Click(object sender, EventArgs e)
        {
            string imageFilePath = Globalne.pathfolder + "\\priznanica.bmp";
            Bitmap bitmap = (Bitmap)Image.FromFile(imageFilePath);//load the image file

            using (Graphics graphics = Graphics.FromImage(bitmap))
            {
                using (Font f = new Font("Times New Roman", 12))
                {
                    Point loc = new Point(480, 262);

                    Size s1 = new Size(134, 31);
                    Rectangle rec = new Rectangle(loc, s1);
                    graphics.DrawString(DateTime.Today.ToString().Substring(0, DateTime.Today.ToString().Length - 12), f, Brushes.Black, rec);
                    rec.X = 485;
                    rec.Y = 303;
                    graphics.DrawString(ukupno.ToString(), f, Brushes.Black, rec);

                }
            }

            bitmap.Save(Globalne.pathfolder + "\\priznanicaP.bmp");

                PrintDialog printDialog = new PrintDialog();
                printDialog.Document = printDocument1;
                printDialog.UseEXDialog = true;
                if (DialogResult.OK == printDialog.ShowDialog())
                {
                    printDocument1.DocumentName = "Račun";
                    printDocument1.Print();
                }
        }
Exemplo n.º 15
0
        public bool Print(bool showPrintDialog)
        {
            if (showPrintDialog)
            {
                var pd = new PrintDialog
                {
                    Document = this._printDocument,
                    UseEXDialog = true,
                    AllowCurrentPage = true,
                    AllowSelection = true,
                    AllowSomePages = true,
                    PrinterSettings = this.PageSettings.PrinterSettings
                };

                if (pd.ShowDialog(Scintilla) == DialogResult.OK)
                {
                    this._printDocument.PrinterSettings = pd.PrinterSettings;
                    this._printDocument.Print();
                    return true;
                }

                return false;
            }

            this._printDocument.Print();
            return true;
        }
Exemplo n.º 16
0
        //private void CalcTotalCost()
        //{
        //    long gID = rentalsToPrint[0].groupID;
        //    deposit = (long)SQLConnection.Execute.RentalGroupsTable.Single(rg => rg.groupID == gID).deposit;
        //    totalCost = 0;
        //    foreach (var item in rentalsToPrint)
        //    {
        //        //if (item.isPaid != true)
        //        //{
        //            totalCost += calc.getRentCost(item.rentalStart, item.rentalEnd, (long)item.actualPrice, (float)item.discount); // (long)((item.rentalEnd - item.rentalStart).Days * item.actualPrice * (1 - item.discount));
        //        //}
        //    }
        //    //totalCost -= deposit;
        //}
        //private string CalcPartCost(DateTime start, DateTime end, long price, float discount)
        //{
        //    int hours;
        //    hours = calc.getIntervalInHours(start, end);
        //    if (hours == 0)
        //    {
        //        hours = 1;
        //    }
        //    return ((long)Math.Round((double)(hours * (price / 10) * (1 - discount)), 0)).ToString("C0");
        //}
        public void Printing()
        {
            //long rtpID;
            PrintDialog pDialog = new PrintDialog();
            try
            {
                FileStream fs = new FileStream(@"Kölcsönzés_Feltételek.txt", FileMode.Open, FileAccess.Read);
                StreamReader sr = new StreamReader(fs);
                contract = sr.ReadToEnd();
            }
            catch (Exception)
            {
                contract = string.Empty;
            }

            //CalcTotalCost();

            try
            {
                    PrintDocument pd = new PrintDocument();
                    pd.PrintPage += new PrintPageEventHandler(pd_PrintRent);

                    if (pDialog.ShowDialog() == DialogResult.OK)
                    {
                        pd.PrinterSettings = pDialog.PrinterSettings;
                        // Print the document.
                        pd.Print();
                    }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 17
0
        private void PrintClicked(object sender, System.EventArgs e)
        {
            if (Viewer == null)
            {
                return;
            }

            PrintDocument pd = new PrintDocument();
            pd.DocumentName = Viewer.SourceFile.LocalPath;
            pd.PrinterSettings.FromPage = 1;
            pd.PrinterSettings.ToPage = Viewer.PageCount;
            pd.PrinterSettings.MaximumPage = Viewer.PageCount;
            pd.PrinterSettings.MinimumPage = 1;
            pd.DefaultPageSettings.Landscape = Viewer.PageWidth > Viewer.PageHeight ? true : false;
            using (PrintDialog dlg = new PrintDialog())
            {
                dlg.Document = pd;
                dlg.AllowSelection = true;
                dlg.AllowSomePages = true;
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    Viewer.Print(pd);
                }
            }

        }
Exemplo n.º 18
0
        private void button1_Click(object sender, EventArgs e)
        {
            // 프린터 설정 관련 객체
            PrinterSettings ps = new PrinterSettings();

            // 프린터 설정 관련 다이얼로그
            PrintDialog pdlg = new PrintDialog();

            // 설정 내용을 ps에 담음
            pdlg.PrinterSettings = ps;

            // PrintDialog 대화상자 출력
            pdlg.ShowDialog();

            string info = String.Format(" PrinterName = {0} \r\n PaperSizes = {1}",
                                          ps.PrinterName, ps.Copies);
            MessageBox.Show(info);

            /*
            // 프린트 설정내용을 PrintDocument 객체에 설정
            PrintDocument pd1 = new PrintDocument();
            pd1.PrinterSettings = ps;
            ...
            */
        }
Exemplo n.º 19
0
        public bool A4PrintSelectPrint(string printContent, int printContentLineCount)
        {
            //PrintDocument doc = new TextDocument(printContent, printContentLineCount);
            PrintDocument doc = new TextDocument(printContent);//@Salim

            doc.PrintPage += this.printDocument1_PrintPage;

            PrintDialog printDialog1 = new PrintDialog();

            // pageSetupDialog1 = new PageSetupDialog();

            if (printDialog1.ShowDialog() == DialogResult.OK)
            {
                // printDialog1.ShowDialog();

                if (printDialog1.PrinterSettings.PrinterName != null)
                {
                    if (printDialog1.PrinterSettings.PrinterName != null)
                    {
                        doc.DefaultPageSettings.PrinterSettings.PrinterName = printDialog1.PrinterSettings.PrinterName;
                        // doc.DefaultPageSettings.PrinterSettings.PrinterName = printDialog1.PrinterSettings.PaperSizes ;
                    }

                    doc.DefaultPageSettings.Landscape = true;
                    PrintDialog dlgSettings = new PrintDialog();
                    dlgSettings.Document = doc;

                    //if (dlgSettings.ShowDialog() == DialogResult.OK)
                    //{
                    doc.Print();
                }
            }
            return true;
        }
Exemplo n.º 20
0
        public MapOutPut(AxPageLayoutControl pagecontrol)
        {
            axPageLayoutControl1 = pagecontrol;

            printDialog1 = new System.Windows.Forms.PrintDialog(); //create a print dialog object
            InitializePageSetupDialog();                           //intitialize the page setup dialog

            comboBox1.Items.Add("esriPageMappingTile");
            comboBox1.Items.Add("esriPageMappingCrop");
            comboBox1.Items.Add("esriPageMappingScale");
            comboBox1.SelectedIndex = 0;

            // create a new PrintPreviewDialog using constructor
            printPreviewDialog1 = new PrintPreviewDialog();
            //set the size, location, name and the minimum size the dialog can be resized to
            printPreviewDialog1.ClientSize  = new System.Drawing.Size(800, 600);
            printPreviewDialog1.Location    = new System.Drawing.Point(29, 29);
            printPreviewDialog1.Name        = "PrintPreviewDialog1";
            printPreviewDialog1.MinimumSize = new System.Drawing.Size(375, 250);
            //set UseAntiAlias to true to allow the operating system to smooth fonts
            printPreviewDialog1.UseAntiAlias = true;

            //associate the event-handling method with the document's PrintPage event
            this.document.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(document_PrintPage);
        }
Exemplo n.º 21
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            PrintDialog pd = new PrintDialog();
            pdoc = new PrintDocument();
            PrinterSettings ps = new PrinterSettings();
            Font font = new Font("Courier New", 15);

            PaperSize psize = new PaperSize("Custom", 100, 200);

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

            pdoc.DefaultPageSettings.PaperSize.Width = 620;

            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();
                }
            }
        }
Exemplo n.º 22
0
		public bool Print(bool showPrintDialog)
		{
			if (showPrintDialog)
			{
				PrintDialog pd = new PrintDialog();
				pd.Document = _printDocument;
				pd.UseEXDialog = true;
				pd.AllowCurrentPage = true;
				pd.AllowSelection = true;
				pd.AllowSomePages = true;
				pd.PrinterSettings = PageSettings.PrinterSettings;

				if (pd.ShowDialog(Scintilla) == DialogResult.OK)
				{
					_printDocument.PrinterSettings = pd.PrinterSettings;
					_printDocument.Print();
					return true;
				}

				return false;
			}

			_printDocument.Print();
			return true;
		}
Exemplo n.º 23
0
        public MapOutPut(AxPageLayoutControl pagecontrol)
        {
            axPageLayoutControl1 = pagecontrol;

            printDialog1 = new System.Windows.Forms.PrintDialog(); //create a print dialog object
            InitializePageSetupDialog(); //intitialize the page setup dialog

            comboBox1.Items.Add("esriPageMappingTile");
            comboBox1.Items.Add("esriPageMappingCrop");
            comboBox1.Items.Add("esriPageMappingScale");
            comboBox1.SelectedIndex = 0;

            // create a new PrintPreviewDialog using constructor
            printPreviewDialog1 = new PrintPreviewDialog();
            //set the size, location, name and the minimum size the dialog can be resized to
            printPreviewDialog1.ClientSize = new System.Drawing.Size(800, 600);
            printPreviewDialog1.Location = new System.Drawing.Point(29, 29);
            printPreviewDialog1.Name = "PrintPreviewDialog1";
            printPreviewDialog1.MinimumSize = new System.Drawing.Size(375, 250);
            //set UseAntiAlias to true to allow the operating system to smooth fonts
            printPreviewDialog1.UseAntiAlias = true;

            //associate the event-handling method with the document's PrintPage event
            this.document.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(document_PrintPage);
        }
Exemplo n.º 24
0
        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("Doesn't matter", paperWidth, paperHeight);
              printDocument.DefaultPageSettings.PaperSize = paperSize;

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

              printDialog = new System.Windows.Forms.PrintDialog();
              printDialog.Document = printDocument;
              printDialog.AllowPrintToFile = true;

              pageNumber = 0;
              pageCount = -1;

              if (printDialog.ShowDialog() == DialogResult.OK)
              {
            printDocument.Print();
              }
        }
        /// <summary>
        /// Confirms the printer settings.
        /// </summary>
        /// <param name="dvPriced">The dv priced.</param>
        /// <param name="dvUnpriced">The dv unpriced.</param>
        /// <param name="stvPrinterName">Name of the STV printer.</param>
        /// <param name="deliveryNotePrinter">The delivery note printer.</param>
        /// <returns></returns>
        private static bool ConfirmPrinterSettings(DataTable dvPriced, DataTable dvUnpriced, out string stvPrinterName,
                                           out string deliveryNotePrinter)
        {
            // get the printer for the stv.
            PrintDialog dialog = new PrintDialog();
            stvPrinterName = deliveryNotePrinter = "";
            if (dvPriced.Rows.Count > 0 && dialog.ShowDialog() == DialogResult.Cancel)
            {
                return false;
            }

            if (dvPriced.Rows.Count > 0)
            {
                stvPrinterName = dialog.PrinterSettings.PrinterName;
            }

            if (dvUnpriced.Rows.Count > 0)
            {
                if (dvPriced.Rows.Count > 0 &&
                    XtraMessageBox.Show(
                        "This transaction contains both priced items and unpriced items (delivery note). Are you sure you want to proceed?",
                        "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.No)
                {
                    return false;
                }

                if (dialog.ShowDialog() == DialogResult.Cancel)
                {
                    return false;
                }
                deliveryNotePrinter = dialog.PrinterSettings.PrinterName;
            }
            return true;
        }
        public void DoPrint() {
            PrintDialog printDialog = new PrintDialog();

            docToPrint.DocumentName = this.documentName;
            printDialog.AllowSomePages = true;

            printDialog.ShowHelp = true;

            printDialog.Document = docToPrint;

            DialogResult result = printDialog.ShowDialog();

            docToPrint.PrintPage += new PrintPageEventHandler(document_PrintPage);

            pages = this.printPageList.Count;
            currentPage = 0;
            if (this.printPageList.Count <= 0)
                return;

            if (result == DialogResult.OK) {
                try {
                    docToPrint.Print();
                } catch (Exception e) {
                    MessageBox.Show("Fehler beim Drucken: " + e.ToString());
                }
            }
            
        }
Exemplo n.º 27
0
        /// <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();
        }
Exemplo n.º 28
0
        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();

                }
            }



        }
Exemplo n.º 29
0
        /// <summary>
        /// 打印变量的基础定义.
        /// </summary>
        private void Init()
        {
            // 初始化 打印文档.
            printDocument1 = new PrintDocument();
            // 定义 打印文档的事件.
            printDocument1.BeginPrint += new System.Drawing.Printing.PrintEventHandler(this.BeginPrint);
            printDocument1.EndPrint   += new System.Drawing.Printing.PrintEventHandler(this.EndPrint);
            printDocument1.PrintPage  += new System.Drawing.Printing.PrintPageEventHandler(this.PrintPage);

            // 定义打印文档的附加信息.
            printDocument1.DocumentName = "打印测试";


            // 初始化 页面设置对话框.
            pageSetupDialog1          = new PageSetupDialog();
            pageSetupDialog1.Document = printDocument1;

            // 初始化 打印预览对话框.
            printPreviewDialog1          = new PrintPreviewDialog();
            printPreviewDialog1.Document = printDocument1;

            // 初始化 打印对话框.
            printDialog1          = new PrintDialog();
            printDialog1.Document = printDocument1;
        }
Exemplo n.º 30
0
        internal static cPrinter getcPrint(
            PrintDialog printDialog,
            string deviceName, 
            string driverName, 
            string port, 
            int orientation, 
            int paperSize, 
            int width, 
            int height)
        {
            cPrinter o = new cPrinter(printDialog);

            o.setDeviceName(deviceName);
            o.setDriverName(driverName);
            o.setPort(port);

            cReportPaperInfo paperInfo = o.getPaperInfo();

            paperInfo.setOrientation(orientation);
            paperInfo.setPaperSize((csReportPaperType)paperSize);

            if (width == 0 || height == 0)
            {
                getSizeFromPaperSize((csReportPaperType)paperSize, orientation, out width, out height);
            }

            paperInfo.setWidth(width);
            paperInfo.setHeight(height);
            return o;
        }
Exemplo n.º 31
0
        private bool Print(bool showPrintDialog, ScintillaPrintDocument doc)
        {
            if (showPrintDialog)
            {
                var pd = new PrintDialog();
                pd.Document = doc;
                pd.UseEXDialog = true;
                pd.AllowCurrentPage = true;
                pd.AllowSelection = true;
                pd.AllowSomePages = true;
                pd.PrinterSettings = doc.DefaultPageSettings.PrinterSettings;

                if (pd.ShowDialog(WB.Form) == DialogResult.OK)
                {
                    doc.PrinterSettings = pd.PrinterSettings;
                    doc.Print();
                    return true;
                }

                return false;
            }

            doc.Print();
            return true;
        }
Exemplo n.º 32
0
        public static void Imprimir(Entidades.Álbum.Álbum álbum, ItensImpressão itens)
        {
            using (PrintDocument documento = new PrintDocument())
            {
                documento.DocumentName = "Álbum " + álbum.Nome;

                using (PrintDialog dlg = new PrintDialog())
                {
                    dlg.AllowCurrentPage = false;
                    dlg.AllowSelection = false;
                    dlg.AllowSomePages = true;
                    dlg.UseEXDialog = true;
                    dlg.Document = documento;

                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        ControleImpressão ctrl = new ControleImpressão(álbum, itens);

                        ctrl.página = new Página(
                                documento.PrinterSettings.DefaultPageSettings.PrintableArea.Width / 100f,
                                documento.PrinterSettings.DefaultPageSettings.PrintableArea.Height / 100f,
                                4, 5);
            
                        ctrl.daPágina = dlg.PrinterSettings.FromPage;
                        ctrl.atéPágina = dlg.PrinterSettings.ToPage != 0 ?
                            dlg.PrinterSettings.ToPage : int.MaxValue;

                        documento.PrintPage += new PrintPageEventHandler(ctrl.ImprimirPágina);
                        documento.Print();
                    }
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            PrintDialog pd = new PrintDialog();
            PrinterSettings ps = new PrinterSettings();
            pd.PrinterSettings = ps;
            DialogResult dr = pd.ShowDialog();

            if (dr == DialogResult.OK) {
                QRPrint printer = new QRPrint();
                printer.PrintMode = QRPrint.PrintModes.PsyBanknote;
                printer.NotesPerPage = (int)numVouchersPerPage.Value;
                switch (cboArtworkStyle.Text.ToLower()) {
                    case "yellow":
                    case "green":
                    case "blue":
                    case "purple":
                    case "greyscale":
                        printer.ImageFilename = "note-" + cboArtworkStyle.SelectedItem.ToString().ToLowerInvariant() + ".png";
                        break;
                }
                printer.Denomination = txtDenomination.Text;
                printer.keys = new List<KeyCollectionItem>(Items.Count);
                printer.PreferUnencryptedPrivateKeys = chkPrintUnencrypted.Checked;
                foreach (KeyCollectionItem a in Items) printer.keys.Add(a);
                printer.PrinterSettings = pd.PrinterSettings;
                printer.Print();
                PrintAttempted = true;
            }
        }
Exemplo n.º 34
0
        /// <summary>
        /// 打印
        /// <param name="tabletitle">表头</param>
        /// <param name="table">打印内容</param>
        /// <param name="tf">设置打印横向还是纵向</param>
        /// <param name="title">打印文件的标题</param>
        /// <param name="add">附加打印内容1</param>
        /// <param name="add1">附加打印内容2</param>
        /// <param name="add2">附加打印内容3</param>
        ///  </summary>
        public static void Print(List <string> tabletitle, List <List <string> > table, bool tf, string title, string add,
                                 string add1, string add2)
        {
            try
            {
                System.Windows.Forms.PrintDialog pd = new System.Windows.Forms.PrintDialog();
                pd.AllowSomePages = true;


                var doc = CreatePrintDocument(tabletitle, table, tf, title, add, add1, add2);
                if (doc == null)
                {
                    var information = WlstMessageBox.Show
                                          ("打印提示", "打印超过10张,请重新筛选数据后打印!", WlstMessageBoxType.Ok);
                    return;
                }
                pd.Document = doc;
                if (pd.ShowDialog() == DialogResult.OK)
                {
                    doc.Print();
                    //CreatePrintDocument(tabletitle, table, tf, title, add, add1, add2).Print();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("打印错误,请检查打印设置!");
            }
        }
Exemplo n.º 35
0
        public bool ShowPrintDialog(PrintDocument document)
        {
            var dialog = new WF.PrintDialog();

            dialog.Document    = document;
            dialog.UseEXDialog = true;
            return(dialog.ShowDialog() == WF.DialogResult.OK);
        }
Exemplo n.º 36
0
        private void Print(string thetext)
        {
            try //source: https://stackoverflow.com/questions/44979794/how-to-print-a-long-string-into-multiple-pages-in-c-sharp
            {
                System.Drawing.Printing.PrintDocument p = new System.Drawing.Printing.PrintDocument();

                var font  = new Font("Times New Roman", 12);
                var brush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

                // what still needs to be printed
                var remainingText = thetext;

                p.PrintPage += delegate(object sender1, System.Drawing.Printing.PrintPageEventArgs e1)
                {
                    int charsFitted, linesFilled;

                    // measure how many characters will fit of the remaining text

                    var realsize = e1.Graphics.MeasureString(
                        remainingText,
                        font,
                        e1.MarginBounds.Size,
                        System.Drawing.StringFormat.GenericDefault,
                        out charsFitted,      // this will return what we need
                        out linesFilled);

                    // take from the remainingText what we're going to print on this page
                    var fitsOnPage = remainingText.Substring(0, charsFitted);
                    // keep what is not printed on this page
                    remainingText = remainingText.Substring(charsFitted).Trim();

                    // print what fits on the page
                    e1.Graphics.DrawString(
                        fitsOnPage,
                        font,
                        brush,
                        e1.MarginBounds);

                    // if there is still text left, tell the PrintDocument it needs to call
                    // PrintPage again.
                    e1.HasMorePages = remainingText.Length > 0;
                };

                System.Windows.Forms.PrintDialog pd = new System.Windows.Forms.PrintDialog();
                pd.Document = p;
                DialogResult result = pd.ShowDialog();

                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    p.Print();
                }
            }
            catch
            {
                //System.Windows.MessageBox.Show(e2.Message, "Unable to print", MessageBoxButton.OK);
            }
        }
Exemplo n.º 37
0
 // private System.ComponentModel.Container components;
 public Bill()
 {
     InitializeComponent();
     this.prnDialog   = new System.Windows.Forms.PrintDialog();
     this.prnPreview  = new System.Windows.Forms.PrintPreviewDialog();
     this.prnDocument = new System.Drawing.Printing.PrintDocument();
     // The Event of 'PrintPage'
     prnDocument.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(prnDocument_PrintPage);
 }
Exemplo n.º 38
0
 public PubPrintMemo(RichTextBox rtb)
 {
     this.printDoc     = new PubPrintTextMemoDoc(rtb);
     this.ppDialog     = new System.Windows.Forms.PrintPreviewDialog();
     this.oPrintDialog = new System.Windows.Forms.PrintDialog();
     this.oPageSetup   = new System.Windows.Forms.PageSetupDialog();
     oPageSettings     = new PageSettings();
     this.oPrintDialog.AllowSomePages = true;
 }
Exemplo n.º 39
0
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PreviewForm));
     this.arvMain         = new GrapeCity.ActiveReports.Viewer.Win.Viewer();
     this.mnuMain         = new System.Windows.Forms.MainMenu(this.components);
     this.mnuFile         = new System.Windows.Forms.MenuItem();
     this.mnuExport       = new System.Windows.Forms.MenuItem();
     this.mnuSaveDocument = new System.Windows.Forms.MenuItem();
     this.dlgPrint        = new System.Windows.Forms.PrintDialog();
     this.SuspendLayout();
     // arvMain
     this.arvMain.BackColor   = System.Drawing.SystemColors.Control;
     this.arvMain.CurrentPage = 0;
     resources.ApplyResources(this.arvMain, "arvMain");
     this.arvMain.Name         = "arvMain";
     this.arvMain.PreviewPages = 0;
     this.arvMain.Sidebar.ParametersPanel.ContextMenu = null;
     this.arvMain.Sidebar.ParametersPanel.Width       = 180;
     this.arvMain.Sidebar.SearchPanel.ContextMenu     = null;
     this.arvMain.Sidebar.SearchPanel.Width           = 180;
     this.arvMain.Sidebar.ThumbnailsPanel.ContextMenu = null;
     this.arvMain.Sidebar.ThumbnailsPanel.Width       = 180;
     this.arvMain.Sidebar.TocPanel.ContextMenu        = null;
     this.arvMain.Sidebar.TocPanel.Width = 180;
     this.arvMain.Sidebar.Width          = 180;
     // mnuMain
     this.mnuMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
         this.mnuFile
     });
     // mnuFile
     this.mnuFile.Index = 0;
     this.mnuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
         this.mnuExport,
         this.mnuSaveDocument
     });
     this.mnuFile.MergeType = System.Windows.Forms.MenuMerge.MergeItems;
     resources.ApplyResources(this.mnuFile, "mnuFile");
     // mnuExport
     this.mnuExport.Index = 0;
     resources.ApplyResources(this.mnuExport, "mnuExport");
     this.mnuExport.Click += new System.EventHandler(this.mnuExport_Click);
     // mnuSaveDocument
     this.mnuSaveDocument.Index = 1;
     resources.ApplyResources(this.mnuSaveDocument, "mnuSaveDocument");
     this.mnuSaveDocument.Click += new System.EventHandler(this.mnuSaveDocument_Click);
     // dlgPrint
     this.dlgPrint.AllowSomePages = true;
     // PreviewForm
     resources.ApplyResources(this, "$this");
     this.Controls.Add(this.arvMain);
     this.Menu  = this.mnuMain;
     this.Name  = "PreviewForm";
     this.Load += new System.EventHandler(this.PreviewForm_Load);
     this.ResumeLayout(false);
 }
Exemplo n.º 40
0
 private void InitializeComponent()
 {
     this.PrintDialog1 = new System.Windows.Forms.PrintDialog();
     this.SuspendLayout();
     //Form1
     //
     this.ClientSize = new System.Drawing.Size(292, 266);
     this.Name       = "Form1";
     this.Text       = "Form1";
     this.ResumeLayout(false);
 }
 public frmInvoiceReport()
 {
     this.prnDialog   = new System.Windows.Forms.PrintDialog();
     this.prnPreview  = new System.Windows.Forms.PrintPreviewDialog();
     this.prnDocument = new System.Drawing.Printing.PrintDocument();
     // The Event of 'PrintPage'
     prnDocument.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(prnDocument_PrintPage);
     invoiceBLL             = new InvoiceBLL(dbHelper);
     productBLL             = new ProductBLL(dbHelper);
     InitializeComponent();
 }
Exemplo n.º 42
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormRpProcNote));
     this.butCancel    = new OpenDental.UI.Button();
     this.butOK        = new OpenDental.UI.Button();
     this.printDialog1 = new System.Windows.Forms.PrintDialog();
     this.SuspendLayout();
     //
     // butCancel
     //
     this.butCancel.AdjustImageLocation = new System.Drawing.Point(0, 0);
     this.butCancel.Autosize            = true;
     this.butCancel.BtnShape            = OpenDental.UI.enumType.BtnShape.Rectangle;
     this.butCancel.BtnStyle            = OpenDental.UI.enumType.XPStyle.Silver;
     this.butCancel.CornerRadius        = 4F;
     this.butCancel.DialogResult        = System.Windows.Forms.DialogResult.Cancel;
     this.butCancel.Location            = new System.Drawing.Point(510, 338);
     this.butCancel.Name     = "butCancel";
     this.butCancel.Size     = new System.Drawing.Size(75, 26);
     this.butCancel.TabIndex = 0;
     this.butCancel.Text     = "&Cancel";
     this.butCancel.Click   += new System.EventHandler(this.butCancel_Click);
     //
     // butOK
     //
     this.butOK.AdjustImageLocation = new System.Drawing.Point(0, 0);
     this.butOK.Autosize            = true;
     this.butOK.BtnShape            = OpenDental.UI.enumType.BtnShape.Rectangle;
     this.butOK.BtnStyle            = OpenDental.UI.enumType.XPStyle.Silver;
     this.butOK.CornerRadius        = 4F;
     this.butOK.Location            = new System.Drawing.Point(510, 297);
     this.butOK.Name     = "butOK";
     this.butOK.Size     = new System.Drawing.Size(75, 26);
     this.butOK.TabIndex = 1;
     this.butOK.Text     = "&OK";
     this.butOK.Click   += new System.EventHandler(this.butOK_Click);
     //
     // FormRpProcNote
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.CancelButton      = this.butCancel;
     this.ClientSize        = new System.Drawing.Size(605, 386);
     this.Controls.Add(this.butOK);
     this.Controls.Add(this.butCancel);
     this.Icon          = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.MaximizeBox   = false;
     this.MinimizeBox   = false;
     this.Name          = "FormRpProcNote";
     this.ShowInTaskbar = false;
     this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
     this.Text          = "Incomplete Procedure Notes Report";
     this.Load         += new System.EventHandler(this.FormRpProcNote_Load);
     this.ResumeLayout(false);
 }
Exemplo n.º 43
0
        //to save the screenshot
        private void OK_Click(object sender, System.EventArgs e)
        {
            if (CheckBoxClipboard.Checked)
            {
                System.Windows.Forms.Clipboard.SetImage(oResultBitmap);
            }

            if (CheckBoxFile.Checked)
            {
                try
                {
                    //pop out the dialog to specify the file name.
                    System.Windows.Forms.SaveFileDialog ofileDlg = new System.Windows.Forms.SaveFileDialog();
                    ofileDlg.Filter = "JPEG (*.jpg)|*.jpg|PNG (*.png)|*.png|Bitmap (*.bmp)|*.bmp|" + "GIF (*.gif)|*.gif|TIFF (*.tif)|*.tif|All files (*.*)|*.*";

                    //save
                    if (ofileDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        oResultBitmap.Save(ofileDlg.FileName, GetFormatForFile(ofileDlg.FileName));
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Image creation failed:" + "\r" + ex.ToString());
                }
            }

            if (CheckBoxPrinter.Checked)
            {
                try
                {
                    PrintDocument pdoc = new PrintDocument();
                    pdoc.PrintPage += pdoc_PrintPage;

                    System.Windows.Forms.PrintDialog pdlg = new System.Windows.Forms.PrintDialog();
                    pdlg.Document = pdoc;

                    //known issue of MS: Print dialog does not show on 64bits OS.
                    //http://social.msdn.microsoft.com/Forums/en-US/netfx64bit/thread/a707d202-1a8b-43b1-9fff-08aa7ceb200a
                    //*******
                    pdlg.UseEXDialog = true;
                    //******

                    if (pdlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        pdoc.Print();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Exemplo n.º 44
0
        public PrintDataGridView(DataGridView myDataGridView)
        {
            this.myDGV          = myDataGridView;
            this.printDocument1 = new System.Drawing.Printing.PrintDocument();
            this.printDialog1   = new System.Windows.Forms.PrintDialog();

            this.printDocument1.PrintPage   += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage);
            this.printDialog1.AllowSelection = true;
            this.printDialog1.AllowSomePages = true;
            this.printDialog1.Document       = this.printDocument1;
        }
Exemplo n.º 45
0
        public void Print()
        {
            var printDialog = new System.Windows.Forms.PrintDialog();
            var doc         = new PrintDocument();

            printDialog.Document = doc;
            doc.PrintPage       += new PrintPageEventHandler(ProvideContent);
            if (printDialog.ShowDialog() == DialogResult.OK)
            {
                doc.Print();
            }
        }
Exemplo n.º 46
0
        private void printButton_Click(object sender, EventArgs e)
        {
            var printDialog = new swf.PrintDialog();

            printDialog.Document = Control.Document;

            if (printDialog.ShowDialog() == swf.DialogResult.OK)
            {
                Control.Document.PrinterSettings = printDialog.PrinterSettings;
                Control.Document.Print();
            }
        }
Exemplo n.º 47
0
        private void PaymentInvoice()
        {
            if (ChooseReportWindow.Window != null)
            {
                ChooseReportWindow.Window.Close();
            }
            var pivm = new PrintInvoiceViewModel();
            var printDialogWindow = new PrintPreview();

            pivm.InvoiceNumber = SelectedRacuni.Brev;
            pivm.InvoiceDate   = SelectedRacuni.Datum;
            pivm.Name          = SelectedRacuni.Kupci.Ime;
            pivm.Jmbg          = SelectedRacuni.Kupci.Jmbg;
            pivm.City          = SelectedRacuni.Kupci.Mesto;
            pivm.Address       = SelectedRacuni.Kupci.Adresa;

            foreach (var e in SelectedRacuni.RevRobas.Items)
            {
                var vm = new PrintInvoiceLineViewModel();
                vm.Roba   = e.Roba.Naziv;
                vm.Amount = e.Kolic;
                vm.Price  = e.Cena;
                vm.Date   = e.Datum;
                vm.Days   = e.Utro;
                vm.Value  = e.Cena * e.Utro;
                pivm.Items.Add(vm);
            }

            var path = ReportFactory.RunReport(pivm, "ReversStampa", "WpfApplication3.Reports.PaymentInvoiceReportA4.rdlc");

            var pdf = PdfiumViewer.PdfDocument.Load(path);

            printDialogWindow.pdfViewer1.Document = pdf;
            var printpdf = printDialogWindow.pdfViewer1.Document.CreatePrintDocument();
            var pd       = new System.Windows.Forms.PrintDialog();

            pd.Document    = printpdf;
            pd.UseEXDialog = true;
            DialogResult result = pd.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    printpdf.Print();
                }
                catch (InvalidPrinterException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemplo n.º 48
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PrintPreview));
     this.printDialog2         = new System.Windows.Forms.PrintDialog();
     this.ToolBarMain          = new OpenDental.UI.ODToolBar();
     this.imageListMain        = new System.Windows.Forms.ImageList(this.components);
     this.printPreviewControl2 = new System.Windows.Forms.PrintPreviewControl();
     this.SuspendLayout();
     //
     // ToolBarMain
     //
     this.ToolBarMain.Dock         = System.Windows.Forms.DockStyle.Top;
     this.ToolBarMain.ImageList    = this.imageListMain;
     this.ToolBarMain.Location     = new System.Drawing.Point(0, 0);
     this.ToolBarMain.Name         = "ToolBarMain";
     this.ToolBarMain.Size         = new System.Drawing.Size(831, 29);
     this.ToolBarMain.TabIndex     = 5;
     this.ToolBarMain.ButtonClick += new OpenDental.UI.ODToolBarButtonClickEventHandler(this.ToolBarMain_ButtonClick);
     //
     // imageListMain
     //
     this.imageListMain.ImageStream      = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListMain.ImageStream")));
     this.imageListMain.TransparentColor = System.Drawing.Color.Transparent;
     this.imageListMain.Images.SetKeyName(0, "");
     this.imageListMain.Images.SetKeyName(1, "");
     this.imageListMain.Images.SetKeyName(2, "");
     //
     // printPreviewControl2
     //
     this.printPreviewControl2.AutoZoom = false;
     this.printPreviewControl2.Dock     = System.Windows.Forms.DockStyle.Fill;
     this.printPreviewControl2.Location = new System.Drawing.Point(0, 0);
     this.printPreviewControl2.Name     = "printPreviewControl2";
     this.printPreviewControl2.Size     = new System.Drawing.Size(831, 570);
     this.printPreviewControl2.TabIndex = 6;
     //
     // PrintPreview
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.ClientSize        = new System.Drawing.Size(831, 570);
     this.Controls.Add(this.ToolBarMain);
     this.Controls.Add(this.printPreviewControl2);
     this.Icon          = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.Name          = "PrintPreview";
     this.ShowInTaskbar = false;
     this.Text          = "Report";
     this.WindowState   = System.Windows.Forms.FormWindowState.Maximized;
     this.Layout       += new System.Windows.Forms.LayoutEventHandler(this.FormReport_Layout);
     this.Load         += new System.EventHandler(this.FormPrintPreview_Load);
     this.ResumeLayout(false);
 }
        public void Print()
        {
            var dlg = new System.Windows.Forms.PrintDialog();

            System.Drawing.Printing.PrintDocument doc = new System.Drawing.Printing.PrintDocument();
            dlg.Document = doc;
            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                _charsPrinted  = 0;
                doc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(doc_PrintPage);
                doc.Print();
            }
        }
Exemplo n.º 50
0
        public void PrintDocument()
        {
            Visio.Document  doc    = axDrawingControl1.Document;
            Visio.Selection select = doc.Application.ActiveWindow.Selection;

            System.Windows.Forms.PrintDialog printDialog = new System.Windows.Forms.PrintDialog();
            if (printDialog.ShowDialog() == DialogResult.OK)
            {
                var PrinterName = printDialog.PrinterSettings.PrinterName;

                doc.PrintOut(Visio.VisPrintOutRange.visPrintCurrentView, 1, -1, true, PrinterName);
            }
        }
Exemplo n.º 51
0
        /// <summary>
        /// 二、开始打印
        /// </summary>
        private void DoPrint()
        {
            try
            {
                //printDocument.PrinterSettings可以获取或设置计算机默认打印相关属性或参数,如:printDocument.PrinterSettings.PrinterName获得默认打印机打印机名称
                //printDocument.DefaultPageSettings   //可以获取或设置打印页面参数信息、如是纸张大小,是否横向打印等

                //设置文档名
                printDocument.DocumentName = "医惠物联网定位卡";//设置完后可在打印对话框及队列中显示(默认显示document)

                ////设置纸张大小(可以不设置取,取默认设置)
                //PaperSize ps = new PaperSize("A4", 100, 70);
                //ps.RawKind = 150; //如果是自定义纸张,就要大于118,(A4值为9,详细纸张类型与值的对照请看http://msdn.microsoft.com/zh-tw/library/system.drawing.printing.papersize.rawkind(v=vs.85).aspx)
                //printDocument.DefaultPageSettings.PaperSize = ps;

                //打印开始前
                //printDocument.BeginPrint += new PrintEventHandler(printDocument_BeginPrint);
                //打印输出(过程)
                printDocument.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
                //打印结束
                //printDocument.EndPrint += new PrintEventHandler(printDocument_EndPrint);

                //跳出打印对话框,提供打印参数可视化设置,如选择哪个打印机打印此文档等
                System.Windows.Forms.PrintDialog pd = new System.Windows.Forms.PrintDialog();
                pd.Document = printDocument;
                if (DialogResult.OK == pd.ShowDialog()) //如果确认,将会覆盖所有的打印参数设置
                {
                    //页面设置对话框(可以不使用,其实PrintDialog对话框已提供页面设置)
                    PageSetupDialog psd = new PageSetupDialog();
                    psd.Document = printDocument;
                    if (DialogResult.OK == psd.ShowDialog())
                    {
                        //打印预览
                        PrintPreviewDialog ppd = new PrintPreviewDialog();
                        ppd.Document    = printDocument;
                        ppd.WindowState = FormWindowState.Maximized;
                        ppd.PrintPreviewControl.Zoom = 1.0;
                        if (DialogResult.OK == ppd.ShowDialog())
                        {
                            printDocument.Print();          //打印
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "打印出错!", MessageBoxButtons.OK, MessageBoxIcon.Warning,
                                                     MessageBoxDefaultButton.Button1);
                Log.CreateLog(ex);
            }
        }
Exemplo n.º 52
0
        private void btnPrintSetting_Click(object sender, EventArgs e)
        {
            PrintDialog printDialog1 = new System.Windows.Forms.PrintDialog();

            if (printDialog1.ShowDialog() == DialogResult.OK)//弹出选择印表机的窗体
            {
                string strBagPrint = printDialog1.PrinterSettings.PrinterName.ToString();

                Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                cfa.AppSettings.Settings["bagPrint"].Value = strBagPrint;
                cfa.Save();
                //UpdateConfig("bagPrint", strBagPrint);
            }
        }
Exemplo n.º 53
0
        public frmPrintCashMemo()
        {
            InitializeComponent();
            this.prnDialog   = new System.Windows.Forms.PrintDialog();
            this.prnPreview  = new System.Windows.Forms.PrintPreviewDialog();
            this.prnDocument = new System.Drawing.Printing.PrintDocument();
            // The Event of 'PrintPage'
            prnDocument.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(prnDocument_PrintPage);
            Globals gb = new Globals();

            ConnString = gb.ConnString;
            //InvTitleHeight = InvTitleHeight * 2;
            //InvSubTitleHeight = InvSubTitleHeight * 2;
        }
Exemplo n.º 54
0
        /// <summary>
        /// Sets the print document for both the page setup dialog and the print dialog.
        /// </summary>
        /// <param name="printDocument">The document to set.</param>
        public override void SetPrintDocument(System.Drawing.Printing.PrintDocument printDocument)
        {
            if (_pageSetupDialog == null)
            {
                _pageSetupDialog = new System.Windows.Forms.PageSetupDialog();
            }
            if (_printDialog == null)
            {
                _printDialog = new System.Windows.Forms.PrintDialog();
            }

            _pageSetupDialog.Document = printDocument;
            _printDialog.Document     = printDocument;
        }
Exemplo n.º 55
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(RepPreview));
     this.crv              = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
     this.button1          = new System.Windows.Forms.Button();
     this.pageSetupDialog1 = new System.Windows.Forms.PageSetupDialog();
     this.printDialog1     = new System.Windows.Forms.PrintDialog();
     this.SuspendLayout();
     //
     // crv
     //
     this.crv.ActiveViewIndex       = -1;
     this.crv.DisplayBackgroundEdge = false;
     this.crv.DisplayGroupTree      = false;
     this.crv.Dock             = System.Windows.Forms.DockStyle.Fill;
     this.crv.Font             = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
     this.crv.Name             = "crv";
     this.crv.ReportSource     = "";
     this.crv.ShowExportButton = false;
     this.crv.Size             = new System.Drawing.Size(416, 281);
     this.crv.TabIndex         = 0;
     //
     // button1
     //
     this.button1.Location = new System.Drawing.Point(314, 0);
     this.button1.Name     = "button1";
     this.button1.Size     = new System.Drawing.Size(100, 24);
     this.button1.TabIndex = 1;
     this.button1.Text     = "Выбор принтера";
     this.button1.Click   += new System.EventHandler(this.button1_Click);
     //
     // RepPreview
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
     this.ClientSize        = new System.Drawing.Size(416, 281);
     this.Controls.AddRange(new System.Windows.Forms.Control[] {
         this.button1,
         this.crv
     });
     this.Font          = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
     this.Icon          = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.KeyPreview    = true;
     this.Name          = "RepPreview";
     this.ShowInTaskbar = true;
     this.Text          = "Предварительный просмотр документа";
     this.WindowState   = System.Windows.Forms.FormWindowState.Maximized;
     this.KeyDown      += new System.Windows.Forms.KeyEventHandler(this.RepPreview_KeyDown);
     this.ResumeLayout(false);
 }
Exemplo n.º 56
0
        //Perform file and print actions
        private void DoFileAction(object sender)
        {
            frmDiagram active = (frmDiagram)this.ActiveMdiChild;

            //Open
            if (sender == mnuFileOpen || sender == btnOpen)
            {
                active.Open("");
            }

            //Save
            if (sender == mnuFileSave || sender == btnSave)
            {
                active.Save(active.Path);
            }

            //Save as
            if (sender == mnuFileSaveAs)
            {
                active.Save("");
            }

            //Print preview
            if (sender == mnuFilePrintPreview)
            {
                Crainiate.Diagramming.Printing.PrintDocument print = new Crainiate.Diagramming.Printing.PrintDocument(active.Model);
                print.PrintPreview(new Point(100, 100), new Size(800, 600));
                return;
            }

            //Print with settings
            if (sender == mnuFilePrint || sender == btnPrint)
            {
                Crainiate.Diagramming.Printing.PrintDocument print         = new Crainiate.Diagramming.Printing.PrintDocument(active.Model);
                System.Windows.Forms.PrintDialog             printDialogue = new System.Windows.Forms.PrintDialog();
                printDialogue.Document = print;

                if (printDialogue.ShowDialog() == DialogResult.OK)
                {
                    print.Print();
                }
                return;
            }

            if (sender == mnuFileExit)
            {
                this.Close();
            }
        }
Exemplo n.º 57
0
        private void toolStripButtonPrint_Click(object sender, EventArgs e)
        {
            // Create a print dialog.
            System.Windows.Forms.PrintDialog dialog = new System.Windows.Forms.PrintDialog();

            // Set the print dialogs print document.
            dialog.Document = Document;

            // Show the print dialog and check the return status...
            if (dialog.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                // Print the document.
                Document.Print();
            }
        }
Exemplo n.º 58
0
 public void Print(ref DataTable dt)
 {
     if (m_print == null)
     {
         this.dt = dt;
         m_print = new PrintDocument();
         System.Windows.Forms.PrintDialog printDialog1 = new System.Windows.Forms.PrintDialog();
         printDialog1.Document = m_print;
         if (DialogResult.OK == printDialog1.ShowDialog())
         {
             //m_print.DefaultPageSettings.PaperSize = ps;
             m_print.PrintPage += new PrintPageEventHandler(Carton_PrintPage);
             m_print.Print();
         }
     }
 }
Exemplo n.º 59
-2
        static void Main(string[] args)
        {
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile("sample.pdf");

            //Use the default printer to print all the pages
            //doc.PrintDocument.Print();

            //Set the printer and select the pages you want to print

            PrintDialog dialogPrint = new PrintDialog();
            dialogPrint.AllowPrintToFile = true;
            dialogPrint.AllowSomePages = true;
            dialogPrint.PrinterSettings.MinimumPage = 1;
            dialogPrint.PrinterSettings.MaximumPage = doc.Pages.Count;
            dialogPrint.PrinterSettings.FromPage = 1;
            dialogPrint.PrinterSettings.ToPage = doc.Pages.Count;

            if (dialogPrint.ShowDialog() == DialogResult.OK)
            {
                //Set the pagenumber which you choose as the start page to print
                doc.PrintFromPage = dialogPrint.PrinterSettings.FromPage;
                //Set the pagenumber which you choose as the final page to print
                doc.PrintToPage = dialogPrint.PrinterSettings.ToPage;
                //Set the name of the printer which is to print the PDF
                doc.PrinterName = dialogPrint.PrinterSettings.PrinterName;

                PrintDocument printDoc = doc.PrintDocument;
                dialogPrint.Document = printDoc;
                printDoc.Print();
            }
        }
Exemplo n.º 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();
                }
            }
        }