public static void Print(IPrintable printable, string filename, int width, int height) { filename = ShowDialog(filename); if (filename == null) { return; } string extension = Path.GetExtension(filename).ToLower(); if (File.Exists(filename)) { File.Delete(filename); } BasicImageFormat format = BasicImageFormat.GetFromExtension(extension); if (format == null) { MessageBox.Show("Could not find the specified file format: " + extension); } IGraphics graphics = format.CreateGraphics(filename, width, height); printable.Print(graphics, width, height); graphics.Close(); graphics.Dispose(); }
public void Close() { g.Close(); }