private void OnPrint_Click(object sender, EventArgs e) { var printSettingsPreviewFolder = FileLocationUtilities.GetDirectoryDistributedWithApplication("printer settings images"); var printSettingsSamplePrefix = Path.Combine(printSettingsPreviewFolder, _model.PageLayout.SizeAndOrientation + "-" + (isBooklet() ? "Booklet-" : "")); string printSettingsSampleName = null; if (SIL.PlatformUtilities.Platform.IsLinux) { printSettingsSampleName = printSettingsSamplePrefix + "Linux-" + LocalizationManager.UILanguageId + ".png"; if (!RobustFile.Exists(printSettingsSampleName)) { printSettingsSampleName = printSettingsSamplePrefix + "Linux-en.png"; } } if (printSettingsSampleName == null || !RobustFile.Exists(printSettingsSampleName)) { printSettingsSampleName = printSettingsSamplePrefix + LocalizationManager.UILanguageId + ".png"; } if (!RobustFile.Exists(printSettingsSampleName)) { printSettingsSampleName = printSettingsSamplePrefix + "en" + ".png"; } if (RobustFile.Exists(printSettingsSampleName)) { // We display the _previewBox to show sample print settings. We need to get rid of it when the // print dialog goes away. For Windows, the only way I've found to know when that happens is // that the main Bloom form gets activated again. For Linux, waiting for process spawned off // to print the pdf file to finish seems to be the only way to know it's safe to hide the // sample print settings. (On Linux/Mono, the form activates almost as soon as the print // dialog appears.) #if __MonoCS__ _pdfViewer.PrintFinished += FormActivatedAfterPrintDialog; #else var form = FindForm(); form.Activated += FormActivatedAfterPrintDialog; #endif _previewBox.Image = Image.FromFile(printSettingsSampleName); _previewBox.Bounds = GetPreviewBounds(); _previewBox.SizeMode = PictureBoxSizeMode.Zoom; _previewBox.BringToFront(); // prevents BL-6001 _previewBox.Show(); if (!Settings.Default.DontShowPrintNotification) { using (var dlg = new SamplePrintNotification()) { dlg.StartPosition = FormStartPosition.CenterParent; #if __MonoCS__ _pdfViewer.PrintFinished -= FormActivatedAfterPrintDialog; dlg.ShowDialog(this); _pdfViewer.PrintFinished += FormActivatedAfterPrintDialog; #else form.Activated -= FormActivatedAfterPrintDialog; // not wanted when we close the dialog. dlg.ShowDialog(this); form.Activated += FormActivatedAfterPrintDialog; #endif if (dlg.StopShowing) { Settings.Default.DontShowPrintNotification = true; Settings.Default.Save(); } } } } _pdfViewer.Print(); Logger.WriteEvent("Calling Print on PDF Viewer"); _model.ReportAnalytics("Print PDF"); }
private void OnPrint_Click(object sender, EventArgs e) { var printSettingsPreviewFolder = FileLocator.GetDirectoryDistributedWithApplication("printer settings images"); var printSettingsSamplePrefix = Path.Combine(printSettingsPreviewFolder, _model.PageLayout.SizeAndOrientation + "-" + (isBooklet() ? "Booklet-" : "")); string printSettingsSampleName = null; if (SIL.PlatformUtilities.Platform.IsLinux) { printSettingsSampleName = printSettingsSamplePrefix + "Linux-" + LocalizationManager.UILanguageId + ".png"; if (!RobustFile.Exists(printSettingsSampleName)) printSettingsSampleName = printSettingsSamplePrefix + "Linux-en.png"; } if (printSettingsSampleName == null || !RobustFile.Exists(printSettingsSampleName)) printSettingsSampleName = printSettingsSamplePrefix + LocalizationManager.UILanguageId + ".png"; if (!RobustFile.Exists(printSettingsSampleName)) printSettingsSampleName = printSettingsSamplePrefix + "en" + ".png"; if (RobustFile.Exists(printSettingsSampleName)) { // We display the _previewBox to show sample print settings. We need to get rid of it when the // print dialog goes away. For Windows, the only way I've found to know when that happens is // that the main Bloom form gets activated again. For Linux, waiting for process spawned off // to print the pdf file to finish seems to be the only way to know it's safe to hide the // sample print settings. (On Linux/Mono, the form activates almost as soon as the print // dialog appears.) #if __MonoCS__ _pdfViewer.PrintFinished += FormActivatedAfterPrintDialog; #else var form = FindForm(); form.Activated += FormActivatedAfterPrintDialog; #endif _previewBox.Image = Image.FromFile(printSettingsSampleName); _previewBox.Bounds = GetPreviewBounds(); _previewBox.SizeMode = PictureBoxSizeMode.Zoom; _previewBox.Show(); if (!Settings.Default.DontShowPrintNotification) { using (var dlg = new SamplePrintNotification()) { #if __MonoCS__ _pdfViewer.PrintFinished -= FormActivatedAfterPrintDialog; dlg.ShowDialog(this); _pdfViewer.PrintFinished += FormActivatedAfterPrintDialog; #else form.Activated -= FormActivatedAfterPrintDialog; // not wanted when we close the dialog. dlg.ShowDialog(this); form.Activated += FormActivatedAfterPrintDialog; #endif if (dlg.StopShowing) { Settings.Default.DontShowPrintNotification = true; Settings.Default.Save(); } } } } _pdfViewer.Print(); Logger.WriteEvent("Calling Print on PDF Viewer"); _model.ReportAnalytics("Print PDF"); }