示例#1
0
        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();
            }
        }
示例#2
0
 static void win_MouseButtonPressed(object sender, MouseButtonEventArgs e)
 {
     try {
         BrowserManager.MouseDown(e.X, e.Y, e.Button);
     }
     catch (Exception ex) { Console.WriteLine(ex.Message); }
 }
示例#3
0
 static void win_MouseButtonReleased(object sender, MouseButtonEventArgs e)
 {
     try
     {
         BrowserManager.MouseUp();
     }
     catch { }
 }
示例#4
0
 static void win_MouseMoved(object sender, MouseMoveEventArgs e)
 {
     try
     {
         BrowserManager.MouseMove(e.X, e.Y);
     }
     catch { }
 }
示例#5
0
        /// <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.
        }
示例#6
0
        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();
            }
        }
示例#7
0
 static void win_KeyPressed(object sender, KeyEventArgs e)
 {
     BrowserManager.InjectKey(e.Code, win.InternalGetMousePosition().X, win.InternalGetMousePosition().Y);
 }