private static async void Screenshot(string filename) { // Create the offscreen Chromium browser. using (var browser = new CefSharp.OffScreen.ChromiumWebBrowser()) { browser.LoadHtml("<html><head></head><body></body></html>", "http://rendering/"); browser.LoadHtml(Monster.ValloricStatBlock(), "http://rendering/"); saveFilename = filename; await Task.Delay(500); int width = 0; int height = 0; while (width == 0) { width = BrowserInfo.BrowserWidth(browser); System.Threading.Thread.Sleep(100); } while (height == 0) { height = BrowserInfo.BrowserHeight(browser); System.Threading.Thread.Sleep(100); } browser.Size = new Size(width, height); await Task.Delay(500); await browser.ScreenshotAsync().ContinueWith(DisplayBitmap); } }
public void ShowMonster() { this.Text = Monster.CreatureName; Clear(); if (b.IsLoading) { b.Stop(); while (b.IsLoading) { System.Threading.Thread.Sleep(100); } } if (PreviewTemplateSelector.Text == "Valloric's Statblock") { b.LoadHtml(Monster.ValloricStatBlock(), "http://rendering/"); } }