3 using System.Windows.Forms;
6 namespace Cairo.Snippets
17 new CairoSnippetsSwf ();
24 f.ClientSize = new Size (width, height);
27 Splitter split = new Splitter ();
28 split.Dock = DockStyle.Left;
29 split.SplitPosition = width / 2;
30 ListView lv = new ListView ();
31 foreach (string s in Snippets.snippets)
32 lv.Items.Add (new ListViewItem (s));
33 lv.Dock = DockStyle.Left;
34 lv.SelectedIndexChanged += OnSelected;
36 da = new DrawingArea ();
37 da.Dock = DockStyle.Right;
38 f.Controls.AddRange (new Control[] {split, lv, da});
43 void OnClosed (object sender, EventArgs e)
48 void OnSelected (object sender, EventArgs e)
50 ListView lv = sender as ListView;
51 if (lv.SelectedItems.Count > 0)
52 da.Draw (lv.SelectedItems[0].Text, width / 2, height);
56 public class DrawingArea : Panel
59 Snippets snips = new Snippets ();
62 public void Draw (string snippet, int width, int height)
70 protected override void OnPaint (PaintEventArgs e)
72 IntPtr hdc = e.Graphics.GetHdc ();
73 // will only work on win32
74 Win32Surface s = new Win32Surface (hdc);
75 Context cr = new Context (s);
76 Snippets.InvokeSnippet (snips, name, cr, w, h);
77 e.Graphics.ReleaseHdc (hdc);