Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4547 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
10 changed files with 83 additions and 71 deletions
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Daniel |
||||
* Date: 26.07.2009 |
||||
* Time: 15:00 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using ICSharpCode.Core; |
||||
using System; |
||||
using System.Drawing.Printing; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Util |
||||
{ |
||||
/// <summary>
|
||||
/// Allows printing using the IPrintable interface.
|
||||
/// </summary>
|
||||
public class WindowsFormsPrinting |
||||
{ |
||||
public static void Print(IPrintable printable) |
||||
{ |
||||
using (PrintDocument pdoc = printable.PrintDocument) { |
||||
if (pdoc != null) { |
||||
using (PrintDialog ppd = new PrintDialog()) { |
||||
ppd.Document = pdoc; |
||||
ppd.AllowSomePages = true; |
||||
if (ppd.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainWin32Window) == DialogResult.OK) { // fixed by Roger Rubin
|
||||
pdoc.Print(); |
||||
} |
||||
} |
||||
} else { |
||||
MessageService.ShowError("${res:ICSharpCode.SharpDevelop.Commands.Print.CreatePrintDocumentError}"); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static void PrintPreview(IPrintable printable) |
||||
{ |
||||
using (PrintDocument pdoc = printable.PrintDocument) { |
||||
if (pdoc != null) { |
||||
PrintPreviewDialog ppd = new PrintPreviewDialog(); |
||||
ppd.TopMost = true; |
||||
ppd.Document = pdoc; |
||||
ppd.Show(WorkbenchSingleton.MainWin32Window); |
||||
} else { |
||||
MessageService.ShowError("${res:ICSharpCode.SharpDevelop.Commands.Print.CreatePrintDocumentError}"); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue