From a49ba2d3a1e9ac587100d13b5bd3d52642650003 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Tue, 26 Apr 2005 21:45:19 +0000 Subject: [PATCH] Update svn path=/trunk/gtk-sharp/; revision=43627 --- doc/en/Gtk.DotNet/Graphics.xml | 37 +++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/doc/en/Gtk.DotNet/Graphics.xml b/doc/en/Gtk.DotNet/Graphics.xml index 9b81242a9..c994ec10d 100644 --- a/doc/en/Gtk.DotNet/Graphics.xml +++ b/doc/en/Gtk.DotNet/Graphics.xml @@ -28,11 +28,42 @@ - Gets a Graphics context for a drawable. + Gets a context for a a a - + Use this method to obtain a System.Drawing.Graphics context from a Gtk drawable. + + + Both pixmaps () and windows () are drawables (). + +The following example shows how to create a custom widget that renders a mesh. This example overrides the OnExposeEvent method and uses calls to do the actual drawing: + + +using System.Drawing; +using Gtk; + +class PrettyGraphic : DrawingArea { + + public PrettyGraphic () + { + SetSizeRequest (200, 200); + } + + protected override bool OnExposeEvent (Gdk.EventExpose args) + { + using (Graphics g = Gtk.DotNet.Graphics.FromDrawable (args.Window)){ + Pen p = new Pen (Color.Blue, 1.0f); + + for (int i = 0; i < 600; i += 60) + for (int j = 0; j < 600; j += 60) + g.DrawLine (p, i, 0, 0, j); + } + return true; + } +} + + - + \ No newline at end of file