Ejemplo n.º 1
0
        /// <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 ret = null;
            if (printDialog.ShowDialog() == DialogResult.OK) {
                bool cancelled = false;
                printOptionsDialog = new PrintOptionsDialog();
                if (conf.OutputPrintPromptOptions) {
                    DialogResult result = printOptionsDialog.ShowDialog();
                    if(result != DialogResult.OK) {
                        cancelled = true;
                    }
                }
                try {
                    if(!cancelled) {
                        printDocument.Print();
                        ret = printDialog.PrinterSettings;
                    }
                } catch(Exception e) {
                    LOG.Error("An error ocurred while trying to print", e);
                    ILanguage lang = Language.GetInstance();
                    MessageBox.Show(lang.GetString(LangKey.print_error), lang.GetString(LangKey.error));
                }

            }
            image.Dispose();
            image = null;
            return ret;
        }
Ejemplo n.º 2
0
 /// <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 PrintTo(string printerName)
 {
     PrinterSettings returnPrinterSettings = null;
     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.PrinterSettings.PrinterName = printerName;
             printDocument.Print();
             returnPrinterSettings = printDocument.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;
 }
Ejemplo n.º 3
0
 /**
  * This Dispose is called from the Dispose and the Destructor.
  * When disposing==true all non-managed resources should be freed too!
  */
 protected void Dispose(bool disposing)
 {
     if (disposing) {
         if(image != null) image.Dispose();
         if(printDocument != null) printDocument.Dispose();
         if(printDialog != null) printDialog.Dispose();
         if(printOptionsDialog != null) printOptionsDialog.Dispose();
     }
     image = null;
     printDocument = null;
     printDialog = null;
     printOptionsDialog = null;
 }
Ejemplo n.º 4
0
		/// <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;
		}