Beispiel #1
0
        private void btnProperties_Click(object sender, EventArgs e)
        {
            string buttonPressed    = (sender as Button).Name;
            string buttonIndex      = buttonPressed[buttonPressed.Length - 1].ToString();
            int    pdfDocumentIndex = -1;

            if (int.TryParse(buttonIndex, out pdfDocumentIndex))
            {
                pdfDocumentIndex--;
                if (pdfDocumentIndex > -1 && pdfDocumentIndex < 5)
                {
                    if (pdfPrintPropertiesForms[pdfDocumentIndex] == null)
                    {
                        pdfPrintPropertiesForms[pdfDocumentIndex] = new PDFPrintPropertiesForm(cmbxPrinterNames.SelectedItem.ToString(), pdfDocumentIndex);
                        if (_printerInfo == null)
                        {
                            _printerInfo = PdfPrintTest.GetPrinterInfo(cmbxPrinterNames.SelectedItem.ToString());
                        }
                        pdfPrintPropertiesForms[pdfDocumentIndex].ApplyPrinterInfo(_printerInfo);
                        pdfPrintPropertiesForms[pdfDocumentIndex].ShowDialog();
                    }
                    else
                    {
                        pdfPrintPropertiesForms[pdfDocumentIndex].ShowDialog();
                    }
                }
            }
        }
Beispiel #2
0
        private void AddPdfDocumentIfNeeded(Control textBoxWithPdfFileName, int index, List <SinglePdfDocumentPrintSettings> documents)
        {
            string fileName = textBoxWithPdfFileName.Text.Trim();

            if (!string.IsNullOrEmpty(fileName))
            {
                if (!File.Exists(fileName))
                {
                    MessageBox.Show(string.Format("File {0} doesn't exist.", fileName));
                    textBoxWithPdfFileName.Focus();
                }
                else
                {
                    if (pdfPrintPropertiesForms[index] == null)
                    {
                        pdfPrintPropertiesForms[index] = new PDFPrintPropertiesForm(cmbxPrinterNames.SelectedItem.ToString(), index);
                    }
                    var pdfDocument = pdfPrintPropertiesForms[index].GetSinglePdfDocumentPrintSettings(fileName);
                    if (pdfDocument != null)
                    {
                        documents.Add(pdfDocument);
                    }
                }
            }
        }