void RenderRectangle(Rectangle rectangle, string filename) { var provider = new FileImageProvider(filename); rectangle.Provider = provider; var image = provider.GetImage(); if (image != null) { var renderer = _preview.GetRenderer(_layout.Value); rectangle.Render(image, renderer); renderer.Cleanup(); provider.Release(); } else { // Console.WriteLine("Couldn't load: " + filename); // Error dialog here. } }