/// <summary>
        /// displays options dialog (if not disabled via settings) and windows
        /// print dialog.
        /// </summary>
        /// <returns>printer settings if actually printed, or null if print was cancelled or has failed</returns>
        public PrinterSettings PrintWithDialog()
        {
            PrinterSettings returnPrinterSettings = null;

            if (printDialog.ShowDialog() == DialogResult.OK)
            {
                bool cancelled = false;
                if (conf.OutputPrintPromptOptions)
                {
                    using (PrintOptionsDialog printOptionsDialog = new PrintOptionsDialog()) {
                        DialogResult result = printOptionsDialog.ShowDialog();
                        if (result != DialogResult.OK)
                        {
                            cancelled = true;
                        }
                    }
                }
                try {
                    if (!cancelled)
                    {
                        printDocument.Print();
                        returnPrinterSettings = printDialog.PrinterSettings;
                    }
                } catch (Exception e) {
                    LOG.Error("An error ocurred while trying to print", e);
                    MessageBox.Show(Language.GetString(LangKey.print_error), Language.GetString(LangKey.error));
                }
            }
            image.Dispose();
            image = null;
            return(returnPrinterSettings);
        }
Exemple #2
0
        /// <summary>
        /// Main method
        /// </summary>
        private void PrintPlan()
        {
            using (PrintDocument doc = new PrintDocument())
            {
                doc.DocumentName = $"Skill Plan for {m_character.Name} ({m_plan.Name})";
                doc.PrintPage   += doc_PrintPage;

                //Display the options
                using (PrintOptionsDialog prdlg = new PrintOptionsDialog(m_settings, doc))
                {
                    if (prdlg.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    doc.PrinterSettings.PrinterName = prdlg.PrinterName;

                    // Display the preview
                    using (PrintPreviewDialog pd = new PrintPreviewDialog())
                    {
                        pd.Document = doc;
                        pd.ShowDialog();
                    }
                }
            }
        }
        /// <summary>
        /// display print options dialog (if the user has not configured Greenshot not to)
        /// </summary>
        /// <returns>result of the print dialog, or null if the dialog has not been displayed by config</returns>
        private DialogResult?ShowPrintOptionsDialog()
        {
            DialogResult?ret = null;

            if (conf.OutputPrintPromptOptions)
            {
                using (PrintOptionsDialog printOptionsDialog = new PrintOptionsDialog()) {
                    ret = printOptionsDialog.ShowDialog();
                }
            }
            return(ret);
        }
        void GetImageForPrint(object sender, PrintPageEventArgs e)
        {
            PrintOptionsDialog pod = new PrintOptionsDialog();

            pod.ShowDialog();

            ContentAlignment alignment = pod.AllowPrintCenter ? ContentAlignment.MiddleCenter : ContentAlignment.TopLeft;

            RectangleF   pageRect  = e.PageSettings.PrintableArea;
            GraphicsUnit gu        = GraphicsUnit.Pixel;
            RectangleF   imageRect = image.GetBounds(ref gu);

            // rotate the image if it fits the page better
            if (pod.AllowPrintRotate)
            {
                if ((pageRect.Width > pageRect.Height && imageRect.Width < imageRect.Height) ||
                    (pageRect.Width < pageRect.Height && imageRect.Width > imageRect.Height))
                {
                    image.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    imageRect = image.GetBounds(ref gu);
                    if (alignment.Equals(ContentAlignment.TopLeft))
                    {
                        alignment = ContentAlignment.TopRight;
                    }
                }
            }
            RectangleF printRect = new RectangleF(0, 0, imageRect.Width, imageRect.Height);;

            // scale the image to fit the page better
            if (pod.AllowPrintEnlarge || pod.AllowPrintShrink)
            {
                SizeF resizedRect = ScaleHelper.GetScaledSize(imageRect.Size, pageRect.Size, false);
                if ((pod.AllowPrintShrink && resizedRect.Width < printRect.Width) ||
                    pod.AllowPrintEnlarge && resizedRect.Width > printRect.Width)
                {
                    printRect.Size = resizedRect;
                }
            }
            // align the image
            printRect = ScaleHelper.GetAlignedRectangle(printRect, new RectangleF(0, 0, pageRect.Width, pageRect.Height), alignment);

            e.Graphics.DrawImage(image, printRect, imageRect, GraphicsUnit.Pixel);
        }
Exemple #5
0
        /// <summary>
        /// Main method
        /// </summary>
        private void PrintPlan()
        {
            PrintDocument doc = new PrintDocument();

            doc.DocumentName = String.Format(CultureConstants.DefaultCulture, "Skill Plan for {0} ({1})", m_character.Name, m_plan.Name);
            doc.PrintPage   += doc_PrintPage;

            //Display the options
            using (PrintOptionsDialog prdlg = new PrintOptionsDialog(m_settings, doc))
            {
                if (prdlg.ShowDialog() == DialogResult.OK)
                {
                    doc.PrinterSettings.PrinterName = prdlg.PrinterName;

                    // Display the preview
                    using (PrintPreviewDialog pd = new PrintPreviewDialog())
                    {
                        pd.Document = doc;
                        pd.ShowDialog();
                    }
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Main method
        /// </summary>
        private void PrintPlan()
        {
            PrintDocument doc = new PrintDocument();

            doc.DocumentName = "Skill Plan for " + m_character.Name + " (" + m_plan.Name + ")";
            doc.PrintPage   += new PrintPageEventHandler(doc_PrintPage);

            //Display the options
            using (PrintOptionsDialog prdlg = new PrintOptionsDialog(m_settings, doc))
            {
                if (prdlg.ShowDialog() == DialogResult.OK)
                {
                    doc.PrinterSettings.PrinterName = prdlg.PrinterName;

                    // Display the preview
                    using (PrintPreviewDialog pd = new PrintPreviewDialog())
                    {
                        pd.Document = doc;
                        pd.ShowDialog();
                    }
                }
            }
        }