mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 13:10:00 -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>
|
/// <returns>printer settings if actually printed, or null if print was cancelled or has failed</returns>
|
||||||
public PrinterSettings PrintTo(string printerName) {
|
public PrinterSettings PrintTo(string printerName) {
|
||||||
PrinterSettings returnPrinterSettings = null;
|
PrinterSettings returnPrinterSettings = null;
|
||||||
bool cancelled = false;
|
DialogResult? printOptionsResult = ShowPrintOptionsDialog();
|
||||||
if (conf.OutputPrintPromptOptions) {
|
try {
|
||||||
using (PrintOptionsDialog printOptionsDialog = new PrintOptionsDialog()) {
|
if (printOptionsResult == null || printOptionsResult == DialogResult.OK) {
|
||||||
DialogResult result = printOptionsDialog.ShowDialog();
|
|
||||||
if (result != DialogResult.OK) {
|
|
||||||
cancelled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if (!cancelled) {
|
|
||||||
printDocument.PrinterSettings.PrinterName = printerName;
|
printDocument.PrinterSettings.PrinterName = printerName;
|
||||||
if (conf.OutputPrintGrayscale) {
|
if (conf.OutputPrintGrayscale) {
|
||||||
printDocument.DefaultPageSettings.Color = false;
|
printDocument.DefaultPageSettings.Color = false;
|
||||||
|
@ -131,17 +123,9 @@ namespace Greenshot.Helpers {
|
||||||
public PrinterSettings PrintWithDialog() {
|
public PrinterSettings PrintWithDialog() {
|
||||||
PrinterSettings returnPrinterSettings = null;
|
PrinterSettings returnPrinterSettings = null;
|
||||||
if (printDialog.ShowDialog() == DialogResult.OK) {
|
if (printDialog.ShowDialog() == DialogResult.OK) {
|
||||||
bool cancelled = false;
|
DialogResult? printOptionsResult = ShowPrintOptionsDialog();
|
||||||
if (conf.OutputPrintPromptOptions) {
|
|
||||||
using (PrintOptionsDialog printOptionsDialog = new PrintOptionsDialog()) {
|
|
||||||
DialogResult result = printOptionsDialog.ShowDialog();
|
|
||||||
if (result != DialogResult.OK) {
|
|
||||||
cancelled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
if (!cancelled) {
|
if (printOptionsResult == null || printOptionsResult == DialogResult.OK) {
|
||||||
if (conf.OutputPrintGrayscale) {
|
if (conf.OutputPrintGrayscale) {
|
||||||
printDocument.DefaultPageSettings.Color = false;
|
printDocument.DefaultPageSettings.Color = false;
|
||||||
}
|
}
|
||||||
|
@ -159,6 +143,20 @@ namespace Greenshot.Helpers {
|
||||||
return returnPrinterSettings;
|
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) {
|
void DrawImageForPrint(object sender, PrintPageEventArgs e) {
|
||||||
ContentAlignment alignment = conf.OutputPrintCenter ? ContentAlignment.MiddleCenter : ContentAlignment.TopLeft;
|
ContentAlignment alignment = conf.OutputPrintCenter ? ContentAlignment.MiddleCenter : ContentAlignment.TopLeft;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue