예제 #1
0
 /// <summary>
 /// Sets UITexture to renderTexture and changes browser size to match renderTexture size
 /// </summary>
 /// <param name="renderTexture"></param>
 public void Resize(Texture2D renderTexture)
 {
     UITexture     = renderTexture;
     _browserSize  = new Size(renderTexture.Width, renderTexture.Height);
     _browser.Size = _browserSize;
     _inputHandler = new WrapperInputHandler(_browser, Position);
 }
예제 #2
0
        public void Load(IntPtr windowHandle, Texture2D renderTexture, XPoint position, string url)
        {
            _currentUrl  = url;
            UITexture    = renderTexture;
            _browserSize = new Size(renderTexture.Width, renderTexture.Height);

            var settings = new CefSettings();

            var osVersion = Environment.OSVersion;

            //Disable GPU for Windows 7
            if (osVersion.Version.Major == 6 && osVersion.Version.Minor == 1)
            {
                // Disable GPU in WPF and Offscreen examples until #1634 has been resolved
                settings.CefCommandLineArgs.Add("disable-gpu", "1");
            }

            _initTimer.Start();

            if (!Cef.IsInitialized)
            {
                //Perform dependency check to make sure all relevant resources are in our output directory.
                Cef.Initialize(settings, true, null);
            }

            _graphics = Graphics.FromHwnd(windowHandle);

            // Leave last argument false, otherwise an exception will be thrown when registering callbacks
            _browser = new ChromiumWebBrowser("", null, null, false);

            // Register callbacks for Javascript to use
            _instructionRegistry.RegisterBrowser(_browser);

            // _browser.ConsoleMessage += _browser_ConsoleMessage;

            _browser.Size = _browserSize;

            _browser.LoadError           += _browser_LoadError;
            _browser.BrowserInitialized  += _browser_BrowserInitialized;
            _browser.LoadingStateChanged += _browser_LoadingStateChanged;

            _browser.CreateBrowser(windowHandle);

            Position      = position;
            _inputHandler = new WrapperInputHandler(_browser, Position);
            _initInputHandlers(windowHandle);
        }
예제 #3
0
 /// <summary>
 /// Must be set is browser rendering position within the window is changed
 /// </summary>
 /// <param name="newPosition"></param>
 public void Move(XPoint newPosition)
 {
     Position      = newPosition;
     _inputHandler = new WrapperInputHandler(_browser, Position);
 }