Author: joncham
Date: 2006-01-13 09:13:57 -0500 (Fri, 13 Jan 2006)
New Revision: 55505
Added:
trunk/winforms/printing/
trunk/winforms/printing/Makefile
trunk/winforms/printing/swf-printing.cs
Log:
Added test for printing functionality.
Added: trunk/winforms/printing/Makefile
===================================================================
--- trunk/winforms/printing/Makefile 2006-01-13 13:46:00 UTC (rev 55504)
+++ trunk/winforms/printing/Makefile 2006-01-13 14:13:57 UTC (rev 55505)
@@ -0,0 +1,11 @@
+all: mono
+
+mono: swf-printing.cs
+ mcs -debug swf-printing.cs /r:System.Windows.Forms.dll
/r:System.Drawing.dll
+
+dotnet: swf-printing.cs
+ csc swf-printing.cs /r:System.Windows.Forms.dll /r:System.Drawing.dll
+
+clean:
+ rm swf-printing.exe -r -f
+ rm -f swf-printing.exe.mdb
\ No newline at end of file
Property changes on: trunk/winforms/printing/Makefile
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/winforms/printing/swf-printing.cs
===================================================================
--- trunk/winforms/printing/swf-printing.cs 2006-01-13 13:46:00 UTC (rev
55504)
+++ trunk/winforms/printing/swf-printing.cs 2006-01-13 14:13:57 UTC (rev
55505)
@@ -0,0 +1,87 @@
+using System;
+using System.Drawing;
+using System.Drawing.Printing;
+using System.Windows.Forms;
+
+namespace print_tester
+{
+ public class Form1 : System.Windows.Forms.Form
+ {
+ private PrintDocument printDoc = new PrintDocument();
+ private PageSettings pgSettings = new PageSettings();
+ private PrinterSettings prtSettings = new PrinterSettings();
+
+ public Form1()
+ {
+ MenuItem fileMenuItem = new MenuItem("&File");
+ MenuItem filePageSetupMenuItem = new MenuItem("Page
Set&up...",
+ new EventHandler(filePageSetupMenuItem_Click));
+ MenuItem filePrintPreviewMenuItem = new MenuItem("Print
Pre&view",
+ new
EventHandler(filePrintPreviewMenuItem_Click));
+ MenuItem filePrintMenuItem = new MenuItem("&Print...",
+ new EventHandler(filePrintMenuItem_Click),
Shortcut.CtrlP);
+
+ fileMenuItem.MenuItems.Add(filePageSetupMenuItem);
+ fileMenuItem.MenuItems.Add(filePrintPreviewMenuItem);
+ fileMenuItem.MenuItems.Add(filePrintMenuItem);
+
+ this.Menu = new MainMenu();
+ this.Menu.MenuItems.Add(fileMenuItem);
+ printDoc.PrintPage += new PrintPageEventHandler(
+ printDoc_PrintPage);
+ }
+
+ // -------------- event handlers
------------------------------------
+ private void filePrintMenuItem_Click(Object sender ,
+ EventArgs e)
+ {
+
+ printDoc.DefaultPageSettings = pgSettings;
+ PrintDialog dlg = new PrintDialog();
+ dlg.Document = printDoc;
+ if (dlg.ShowDialog() == DialogResult.OK)
+ {
+ printDoc.Print();
+ }
+ }
+
+ private void filePrintPreviewMenuItem_Click(Object sender ,
+ EventArgs e)
+ {
+ PrintPreviewDialog dlg = new PrintPreviewDialog();
+ dlg.Document = printDoc;
+ dlg.ShowDialog();
+ }
+
+ private void filePageSetupMenuItem_Click(Object sender ,
+ EventArgs e)
+ {
+ PageSetupDialog pageSetupDialog = new PageSetupDialog();
+ pageSetupDialog.PageSettings = pgSettings;
+ pageSetupDialog.PrinterSettings = prtSettings;
+ pageSetupDialog.AllowOrientation = true;
+ pageSetupDialog.AllowMargins = true;
+ pageSetupDialog.ShowDialog();
+ }
+
+ private void printDoc_PrintPage(Object sender ,
+ PrintPageEventArgs e)
+ {
+ String textToPrint = ".NET Printing is easy";
+ Font printFont = new Font("Courier New", 12);
+ int leftMargin = e.MarginBounds.Left;
+ int topMargin = e.MarginBounds.Top;
+ e.Graphics.DrawString(textToPrint, printFont,
Brushes.Black,
+ leftMargin, topMargin);
+ }
+
+ //-------------- end of event handlers
-----------------------------
+
+ [STAThread]
+ static void Main()
+ {
+ Application.Run(new Form1());
+ }
+
+ }
+}
\ No newline at end of file
Property changes on: trunk/winforms/printing/swf-printing.cs
___________________________________________________________________
Name: svn:executable
+ *
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches