static void Main(string[] args) { win = new RenderWindow(new VideoMode(1366, 768), ""); win.SetFramerateLimit(60); BrowserManager.StartBrowserManagerService(); win.Resized += (sender, e) => { }; win.Closed += (sender, e) => { win.Close(); BrowserManager.EndBrowserManagerService(); }; win.MouseButtonPressed += new EventHandler <MouseButtonEventArgs>(win_MouseButtonPressed); win.MouseButtonReleased += new EventHandler <MouseButtonEventArgs>(win_MouseButtonReleased); win.MouseMoved += new EventHandler <MouseMoveEventArgs>(win_MouseMoved); win.KeyPressed += new EventHandler <KeyEventArgs>(win_KeyPressed); BrowserManager.NewTab(0, @"http://www.reddit.com", 300, 400, 0, 0); BrowserManager.NewTab(1, @"http://www.youtube.com", 300, 400, 400, 0); BrowserManager.NewTab(2, @"http://m.wikipedia.org", 300, 400, 0, 400); while (win.IsOpen()) { win.DispatchEvents(); win.Clear(); BrowserManager.Draw(win); win.Display(); } }
static void win_MouseButtonPressed(object sender, MouseButtonEventArgs e) { try { BrowserManager.MouseDown(e.X, e.Y, e.Button); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void win_MouseButtonReleased(object sender, MouseButtonEventArgs e) { try { BrowserManager.MouseUp(); } catch { } }
static void win_MouseMoved(object sender, MouseMoveEventArgs e) { try { BrowserManager.MouseMove(e.X, e.Y); } catch { } }
/// <summary> /// Ends the Browser Manager. Use this when closing your application. /// </summary> public static void EndBrowserManagerService() { if (BrowserManager.Running) // Stops the browser manager. { BrowserManager.Close(); } BrowserManager.awesomiumContext = null; // Release the sync context. }
public static SynchronizationContext awesomiumContext = null; // Used to synchronize multiple tabs. /// <summary> /// Starts the Browser Manager on another thread. Without this, no web services are available. /// </summary> public static void StartBrowserManagerService() { if (!BrowserManager.Running) { new System.Threading.Thread(() => { Awesomium.Core.WebCore.Started += (s, e) => { BrowserManager.awesomiumContext = System.Threading.SynchronizationContext.Current; Console.WriteLine("Starting Synchronization Context for Browser"); }; BrowserManager.Start(); }).Start(); } }
static void win_KeyPressed(object sender, KeyEventArgs e) { BrowserManager.InjectKey(e.Code, win.InternalGetMousePosition().X, win.InternalGetMousePosition().Y); }