2006-01-27 Jordi Mas i Hernandez <jordimash@gmail.com>
authorJordi Mas i Hernandez <jordi@mono-cvs.ximian.com>
Fri, 27 Jan 2006 11:28:27 +0000 (11:28 -0000)
committerJordi Mas i Hernandez <jordi@mono-cvs.ximian.com>
Fri, 27 Jan 2006 11:28:27 +0000 (11:28 -0000)
* Adds PrintFontSample.cs

svn path=/trunk/mcs/; revision=56155

mcs/class/System.Drawing/Samples/System.Drawing.Printing/ChangeLog
mcs/class/System.Drawing/Samples/System.Drawing.Printing/PrintFontSample.cs [new file with mode: 0644]

index 67ff343765fd7d8a4c482079d5e48c08359e779e..25d6f39a2044b35a1109966b81deca24a6055751 100644 (file)
@@ -1,3 +1,7 @@
+2006-01-27 Jordi Mas i Hernandez  <jordimash@gmail.com>
+
+       * Adds PrintFontSample.cs
+
 2006-01-15 Jordi Mas i Hernandez  <jordimash@gmail.com>
 
        * Adds PrintingMargins.cs
diff --git a/mcs/class/System.Drawing/Samples/System.Drawing.Printing/PrintFontSample.cs b/mcs/class/System.Drawing/Samples/System.Drawing.Printing/PrintFontSample.cs
new file mode 100644 (file)
index 0000000..d378a60
--- /dev/null
@@ -0,0 +1,58 @@
+//
+// Sample to Print diferent font types and sizes
+//
+
+using System;
+using System.Drawing;
+using System.IO;
+using System.Drawing.Printing;
+
+public class PrintingTextFile
+{
+
+       static private void PrintPageEvent (object sender, PrintPageEventArgs e)
+       {
+               float left = e.MarginBounds.Left;
+               float top = e.MarginBounds.Top;
+
+               Font font = new Font ("Arial", 10);
+               e.Graphics.DrawString("This a sample with font " + font.Name + " size:" + font.Size,
+                       font, new SolidBrush (Color.Red), left, top);
+
+               font = new Font ("Verdana", 16);
+               e.Graphics.DrawString ("This a sample with font " + font.Name + " size:" + font.Size,
+                       font, new SolidBrush (Color.Blue), left, top + 50);
+
+               font = new Font ("Verdana", 22);
+               e.Graphics.DrawString ("This a sample with font " + font.Name + " size:" + font.Size,
+                       font, new SolidBrush (Color.Black), left, top + 150);
+
+               font  = new Font (FontFamily.GenericMonospace, 14);
+               e.Graphics.DrawString ("This a sample with font " + font.Name + " size:" + font.Size,
+                       font, new SolidBrush (Color.Black), left, top + 250);
+
+               font  = new Font ("Arial", 48);
+               e.Graphics.DrawString ("Font " + font.Name + " size:" + font.Size,
+                       font, new SolidBrush (Color.Red), left, top + 300);
+
+               font  = new Font ("Times New Roman", 32);
+               e.Graphics.DrawString ("Another sample font " + font.Name + " size:" + font.Size,
+                       font, new SolidBrush (Color.Black), left, top + 500);
+
+               font  = new Font (FontFamily.GenericSansSerif, 8);
+               e.Graphics.DrawString ("Another sample font " + font.Name + " size:" + font.Size,
+                       font, new SolidBrush (Color.Blue), left, top + 900);
+
+               e.HasMorePages = false;
+       }
+
+
+        public static void Main (string[] args)
+        {
+               PrintDocument p = new PrintDocument ();
+               p.PrintPage += new PrintPageEventHandler (PrintPageEvent);
+                p.Print ();
+        }
+}
+
+