Removed surface disposing, and making sure the PrintHelper itself is disposed correctly. Disposing the surface is not allowed in a destination, e.g. this would rip the surface away right from under the editor :)

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2503 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2013-02-20 09:16:28 +00:00
commit 0e86fa409c
2 changed files with 90 additions and 92 deletions

View file

@ -106,15 +106,21 @@ namespace Greenshot.Destinations {
/// <param name="captureDetails"></param>
/// <returns>ExportInformation</returns>
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
PrinterSettings printerSettings = null;
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
PrinterSettings printerSettings = null;
if (!string.IsNullOrEmpty(printerName)) {
printerSettings = new PrintHelper(surface, captureDetails).PrintTo(printerName);
using (PrintHelper printHelper = new PrintHelper(surface, captureDetails)) {
printerSettings = printHelper.PrintTo(printerName);
}
} else if (!manuallyInitiated) {
PrinterSettings settings = new PrinterSettings();
printerSettings = new PrintHelper(surface, captureDetails).PrintTo(settings.PrinterName);
using (PrintHelper printHelper = new PrintHelper(surface, captureDetails)) {
printerSettings = printHelper.PrintTo(settings.PrinterName);
}
} else {
printerSettings = new PrintHelper(surface, captureDetails).PrintWithDialog();
using (PrintHelper printHelper = new PrintHelper(surface, captureDetails)) {
printerSettings = printHelper.PrintWithDialog();
}
}
if (printerSettings != null) {
exportInformation.ExportMade = true;