mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 02:37:03 -07:00
refactoring: extracted new method "ShowPrintOptionsDialog"
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1948 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
d3c3d254b0
commit
6e36209a76
1 changed files with 19 additions and 21 deletions
|
@ -96,17 +96,9 @@ namespace Greenshot.Helpers {
|
|||
/// <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) {
|
||||
DialogResult? printOptionsResult = ShowPrintOptionsDialog();
|
||||
try {
|
||||
if (printOptionsResult == null || printOptionsResult == DialogResult.OK) {
|
||||
printDocument.PrinterSettings.PrinterName = printerName;
|
||||
if (conf.OutputPrintGrayscale) {
|
||||
printDocument.DefaultPageSettings.Color = false;
|
||||
|
@ -131,17 +123,9 @@ namespace Greenshot.Helpers {
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
DialogResult? printOptionsResult = ShowPrintOptionsDialog();
|
||||
try {
|
||||
if (!cancelled) {
|
||||
if (printOptionsResult == null || printOptionsResult == DialogResult.OK) {
|
||||
if (conf.OutputPrintGrayscale) {
|
||||
printDocument.DefaultPageSettings.Color = false;
|
||||
}
|
||||
|
@ -159,6 +143,20 @@ namespace Greenshot.Helpers {
|
|||
return returnPrinterSettings;
|
||||
}
|
||||
|
||||
/// <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 DrawImageForPrint(object sender, PrintPageEventArgs e) {
|
||||
ContentAlignment alignment = conf.OutputPrintCenter ? ContentAlignment.MiddleCenter : ContentAlignment.TopLeft;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue