public static void Save(this ICladogramRenderer cladogramRenderer, string filePath) { SizeF bounds = cladogramRenderer.Size; using (GdiCanvas canvas = new GdiCanvas((int)bounds.Width, (int)bounds.Height)) { canvas.Clear(Color.FromArgb(54, 57, 63)); cladogramRenderer.Render(canvas); canvas.Save(filePath); } }
private Control CreateChildCanvas() { ICanvas createdControl = null; ////////////////////// // Try creating a SlimDX canvas. bool success = false; if (RunOptions.ForceGdiRendering) { Trace.WriteLine("Video Render - Forcing use of GDI rendering due to run option."); } else if (DesignerHelper.IsInDesignMode(this)) { // NOTE: (jmk) probably shouldn't happen at runtime, but I have it in here just in case something goes berserk. Trace.WriteLine("Video Render - Forcing use of GDI rendering due to being in design mode."); } else { try { createdControl = new SlimDXCanvas(); createdControl.Initialize(); success = true; } catch (Exception ex) { Trace.WriteLine("Video Render - DirectX canvas initialization failed! Will attempt to fall back to windows(GDI) rendering. Error was: " + ex.ToString()); if (createdControl != null) { createdControl.Destroy(); } } // We don't care what went wrong. } ///////////////////// // If necessary, try a GDI/windows-native canvas. if (!success) { createdControl = new GdiCanvas(); createdControl.Initialize(); } return((Control)createdControl); }