Beispiel #1
0
        public void Initialise()
        {
            browser = new ChromiumWebBrowser(url, automaticallyCreateBrowser: false);
            browser.RenderHandler = RenderHandler;
            var size = RenderHandler.GetViewRect();

            // General browser config
            var windowInfo = new WindowInfo()
            {
                Width  = size.Width,
                Height = size.Height,
            };

            windowInfo.SetAsWindowless(IntPtr.Zero);

            // WindowInfo gets ignored sometimes, be super sure:
            browser.BrowserInitialized += (sender, args) => { browser.Size = new Size(size.Width, size.Height); };

            var browserSettings = new BrowserSettings()
            {
                WindowlessFrameRate = 60,
            };

            // Ready, boot up the browser
            browser.CreateBrowser(windowInfo, browserSettings);

            browserSettings.Dispose();
            windowInfo.Dispose();
        }
        public AvaloniaRenderingSurface()
        {
            if (Parent != null)
            {
                WindowInfo = CreateWrapper();
            }
            AttachedToVisualTree += (sender, args) =>
            {
                WindowInfo?.Dispose();
                WindowInfo = CreateWrapper();
            };
            DetachedFromVisualTree += (sender, args) =>
            {
                WindowInfo?.Dispose();
                WindowInfo = null;
            };

            _boundsSubscription = this.GetObservable(BoundsProperty).Subscribe(args =>
            {
                var oldBounds = this.Bounds;
                var newBounds = args;
                Resize?.Invoke(new ResizeEventArgs((int)newBounds.Size.Width, (int)newBounds.Size.Height));
            });

            InitializeComponent();
        }
        public IWindowInfo UpdateWindowInfo(GraphicsMode mode)
        {
            WindowInfo?.Dispose();

            WindowInfo = Utilities.CreateWindowsWindowInfo(Handle);

            WindowInfoUpdated?.Invoke(this, EventArgs.Empty);

            return(WindowInfo);
        }
Beispiel #4
0
        public void BeginRender()
        {
            EndRender();

            var cefWindowInfo = new WindowInfo();

            cefWindowInfo.SetAsWindowless(IntPtr.Zero);
            cefWindowInfo.Width  = _target.Width;
            cefWindowInfo.Height = _target.Height;

            var cefBrowserSettings = new BrowserSettings();

            cefBrowserSettings.WindowlessFrameRate = _target.MaxFrameRate;
            _browser.CreateBrowser(cefWindowInfo, cefBrowserSettings);

            cefBrowserSettings.Dispose();
            cefWindowInfo.Dispose();
        }
Beispiel #5
0
        public void BeginRender(int width, int height, string url, int maxFrameRate = 30)
        {
            EndRender();

            var cefWindowInfo = new WindowInfo();

            cefWindowInfo.SetAsWindowless(IntPtr.Zero);
            cefWindowInfo.Width  = width;
            cefWindowInfo.Height = height;

            var cefBrowserSettings = new BrowserSettings();

            cefBrowserSettings.WindowlessFrameRate = maxFrameRate;
            _browser.CreateBrowser(cefWindowInfo, cefBrowserSettings);

            cefBrowserSettings.Dispose();
            cefWindowInfo.Dispose();

            urlToLoad = url;
        }
 public void Dispose()
 {
     WindowInfo?.Dispose();
 }
 public override void Destroy()
 {
     Context.Dispose();
     WindowInfo.Dispose();
 }