public void Dispose() { if (d_surface != null) { d_surface.Destroy(); } }
// Create a new surface of the appropriate size to store our scribbles private void ScribbleConfigure(object o, ConfigureEventArgs args) { Widget widget = o as Widget; if (surface != null) { surface.Destroy(); } var allocation = widget.Allocation; surface = widget.Window.CreateSimilarSurface(Cairo.Content.Color, allocation.Width, allocation.Height); var cr = new Cairo.Context(surface); cr.SetSourceRGB(1, 1, 1); cr.Paint(); ((IDisposable)cr).Dispose(); // We've handled the configure event, no need for further processing. args.RetVal = true; }