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