[Mono-dev] Snippets in mcs

Daniel Morgan monodanmorg at yahoo.com
Fri Jul 7 12:02:55 EDT 2006


John,
 
This is awesome!  I love seeing snippets, examples, and samples in mcs.  I wish we did this with other class libraries.
 
I remember trying gtk+ back in 1998.  I liked how it actually included examples to play with.  This sure cuts the learning curve in half.
 
So, if mono release tarballs, rpms, debs, and installers include these "snippets", it would make mono rock!
 
Daniel

----- Forwarded Message ----
From: "John Luke (jluke at cfl.rr.com)" <mono-patches-list at lists.ximian.com>
To: mono-patches at lists.ximian.com; ximian.monolist at gmail.com; mono-patches-list at googlegroups.com
Sent: Friday, July 7, 2006 12:07:48 AM
Subject: [Mono-patches] r62338 - trunk/mcs/class/Mono.Cairo/snippets


Author: jluke
Date: 2006-07-07 00:07:47 -0400 (Fri, 07 Jul 2006)
New Revision: 62338

Added:
   trunk/mcs/class/Mono.Cairo/snippets/SnippetsPdf.cs
   trunk/mcs/class/Mono.Cairo/snippets/SnippetsPs.cs
   trunk/mcs/class/Mono.Cairo/snippets/SnippetsSvg.cs
Modified:
   trunk/mcs/class/Mono.Cairo/snippets/
Log:
add svg, pdf, and ps snippets tests



Property changes on: trunk/mcs/class/Mono.Cairo/snippets
___________________________________________________________________
Name: svn:ignore
   - *.png
*.exe
*.mdb

   + *.png
*.exe
*.mdb
*.svg
*.ps
*.pdf


Added: trunk/mcs/class/Mono.Cairo/snippets/SnippetsPdf.cs
===================================================================
--- trunk/mcs/class/Mono.Cairo/snippets/SnippetsPdf.cs    2006-07-07 03:45:15 UTC (rev 62337)
+++ trunk/mcs/class/Mono.Cairo/snippets/SnippetsPdf.cs    2006-07-07 04:07:47 UTC (rev 62338)
@@ -0,0 +1,31 @@
+using System;
+using Cairo;
+
+namespace Cairo.Snippets
+{
+    public class CairoSnippetsPDF
+    {
+        public static int IMAGE_WIDTH = 256;
+        public static int IMAGE_HEIGHT = 256;
+
+        public static double LINE_WIDTH = 0.04;
+
+        public static void Main(string[] args)
+        {
+            // call the snippets
+            Snippets snip = new Snippets();
+            Surface surface = new PdfSurface("snippets.pdf", IMAGE_WIDTH, IMAGE_WIDTH);
+            Context cr = new Context(surface);
+
+            foreach (string snippet in Snippets.snippets)
+            {
+                cr.Save();
+                Snippets.InvokeSnippet(snip, snippet, cr, IMAGE_WIDTH, IMAGE_HEIGHT);
+                cr.ShowPage ();
+                cr.Restore();
+            }
+            surface.Finish ();
+        }
+    }
+}
+

Added: trunk/mcs/class/Mono.Cairo/snippets/SnippetsPs.cs
===================================================================
--- trunk/mcs/class/Mono.Cairo/snippets/SnippetsPs.cs    2006-07-07 03:45:15 UTC (rev 62337)
+++ trunk/mcs/class/Mono.Cairo/snippets/SnippetsPs.cs    2006-07-07 04:07:47 UTC (rev 62338)
@@ -0,0 +1,28 @@
+using System;
+using Cairo;
+
+namespace Cairo.Snippets
+{
+    public class CairoSnippetsPS
+    {
+        public static int IMAGE_WIDTH = 256;
+        public static int IMAGE_HEIGHT = 256;
+
+        public static void Main(string[] args)
+        {
+            // call the snippets
+            Snippets snip = new Snippets();
+            Surface surface = new PSSurface("snippets.ps", IMAGE_WIDTH, IMAGE_WIDTH);
+            Context cr = new Context(surface);
+            foreach (string snippet in Snippets.snippets)
+            {
+                cr.Save();
+                Snippets.InvokeSnippet(snip, snippet, cr, IMAGE_WIDTH, IMAGE_HEIGHT);
+                cr.ShowPage();
+                cr.Restore();
+            }
+            surface.Finish ();
+        }
+    }
+}
+

Added: trunk/mcs/class/Mono.Cairo/snippets/SnippetsSvg.cs
===================================================================
--- trunk/mcs/class/Mono.Cairo/snippets/SnippetsSvg.cs    2006-07-07 03:45:15 UTC (rev 62337)
+++ trunk/mcs/class/Mono.Cairo/snippets/SnippetsSvg.cs    2006-07-07 04:07:47 UTC (rev 62338)
@@ -0,0 +1,32 @@
+using System;
+using Cairo;
+
+namespace Cairo.Snippets
+{
+    public class CairoSnippetsSVG
+    {
+        public static int IMAGE_WIDTH = 256;
+        public static int IMAGE_HEIGHT = 256;
+
+        public static double LINE_WIDTH = 0.04;
+
+        public static void Main(string[] args)
+        {
+            // call the snippets
+            Snippets snip = new Snippets();
+            foreach (string snippet in Snippets.snippets)
+            {
+                string filename = "./" + snippet + ".svg";
+                Surface surface = new SvgSurface(filename, IMAGE_WIDTH, IMAGE_WIDTH);
+                Context cr = new Context(surface);
+            
+                cr.Save();
+                Snippets.InvokeSnippet(snip, snippet, cr, IMAGE_WIDTH, IMAGE_HEIGHT);
+                cr.ShowPage();
+                cr.Restore();
+                surface.Finish ();
+            }
+        }
+    }
+}
+

_______________________________________________
Mono-patches maillist  -  Mono-patches at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-patches



More information about the Mono-devel-list mailing list