Esempio n. 1
0
        /// <summary>
        /// Create a new OffScreen Chromium Browser. If you use <see cref="CefSharp.JavascriptBinding.JavascriptBindingSettings.LegacyBindingEnabled"/> = true then you must
        /// set <paramref name="automaticallyCreateBrowser"/> to false and call <see cref="CreateBrowser"/> after the objects are registered.
        /// The underlying Chromium Embedded Framework(CEF) Browser is created asynchronouly, to subscribe to the <see cref="BrowserInitialized"/> event it is recommended
        /// that you set <paramref name="automaticallyCreateBrowser"/> to false, subscribe to the event and then call <see cref="CreateBrowser(IWindowInfo, IBrowserSettings)"/>
        /// to ensure you are subscribe to the event before it's fired (Issue https://github.com/cefsharp/CefSharp/issues/3552).
        /// </summary>
        /// <param name="address">Initial address (url) to load</param>
        /// <param name="browserSettings">The browser settings to use. If null, the default settings are used.</param>
        /// <param name="requestContext">See <see cref="RequestContext" /> for more details. Defaults to null</param>
        /// <param name="automaticallyCreateBrowser">automatically create the underlying Browser</param>
        /// <param name="onAfterBrowserCreated">
        /// Use as an alternative to the <see cref="BrowserInitialized"/> event. If the underlying Chromium Embedded Framework (CEF) browser is created successfully,
        /// this action is guranteed to be called after the browser created where as the <see cref="BrowserInitialized"/> event may be called before
        /// you have a chance to subscribe to the event as the CEF Browser is created async. (Issue https://github.com/cefsharp/CefSharp/issues/3552).
        /// </param>
        /// <exception cref="System.InvalidOperationException">Cef::Initialize() failed</exception>
        public ChromiumWebBrowser(string address = "", IBrowserSettings browserSettings = null,
                                  IRequestContext requestContext          = null, bool automaticallyCreateBrowser = true,
                                  Action <IBrowser> onAfterBrowserCreated = null)
        {
            if (!Cef.IsInitialized)
            {
                var settings = new CefSettings();

                if (!Cef.Initialize(settings))
                {
                    throw new InvalidOperationException(CefInitializeFailedErrorMessage);
                }
            }

            RequestContext = requestContext;

            Cef.AddDisposable(this);
            Address = address;
            onAfterBrowserCreatedDelegate = onAfterBrowserCreated;

            managedCefBrowserAdapter = ManagedCefBrowserAdapter.Create(this, true);

            if (automaticallyCreateBrowser)
            {
                CreateBrowser(null, browserSettings);
            }

            RenderHandler = new DefaultRenderHandler(this);
        }
Esempio n. 2
0
        /// <summary>
        /// Create a new offscreen Chromium with the initial URL of "about:blank".
        /// </summary>
        /// <param name="browserSettings">The browser settings to use.  If null, the default settings are used.</param>
        public ChromiumWebBrowser(BrowserSettings browserSettings = null)
        {
            Cef.AddDisposable(this);

            managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this);
            managedCefBrowserAdapter.CreateOffscreenBrowser(browserSettings ?? new BrowserSettings());
        }
Esempio n. 3
0
        /// <summary>
        /// Required for designer support - this method cannot be inlined as the designer
        /// will attempt to load libcef.dll and will subsiquently throw an exception.
        /// TODO: Still not happy with this method name, need something better
        /// </summary>
        private void InitializeFieldsAndCefIfRequired()
        {
            if (!_initialized)
            {
                if (!Cef.IsInitialized && !Cef.Initialize(_settings))
                {
                    throw new InvalidOperationException("Cef::Initialize() failed");
                }

                Cef.AddDisposable(this);


                if (ResourceRequestHandlerFactory == null)
                {
                    ResourceRequestHandlerFactory = new ResourceRequestHandlerFactory();
                }

                if (_browserSettings == null)
                {
                    _browserSettings = new BrowserSettings();
                }

                _managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, false);

                _initialized = true;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Create a new OffScreen Chromium Browser. If you use <see cref="CefSharpSettings.LegacyJavascriptBindingEnabled"/> = true then you must
        /// set <paramref name="automaticallyCreateBrowser"/> to false and call <see cref="CreateBrowser"/> after the objects are registered.
        /// </summary>
        /// <param name="address">Initial address (url) to load</param>
        /// <param name="browserSettings">The browser settings to use. If null, the default settings are used.</param>
        /// <param name="requestContext">See <see cref="RequestContext" /> for more details. Defaults to null</param>
        /// <param name="automaticallyCreateBrowser">automatically create the underlying Browser</param>
        /// <exception cref="System.InvalidOperationException">Cef::Initialize() failed</exception>
        public ChromiumWebBrowser(string address = "", BrowserSettings browserSettings = null,
                                  RequestContext requestContext = null, bool automaticallyCreateBrowser = true)
        {
            if (!Cef.IsInitialized)
            {
                var settings = new CefSettings();
                settings.WindowlessRenderingEnabled = true;

                if (!Cef.Initialize(settings))
                {
                    throw new InvalidOperationException("Cef::Initialize() failed");
                }
            }

            ResourceHandlerFactory = new DefaultResourceHandlerFactory();
            BrowserSettings        = browserSettings ?? new BrowserSettings();
            RequestContext         = requestContext;

            Cef.AddDisposable(this);
            Address = address;

            managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, true);

            if (automaticallyCreateBrowser)
            {
                CreateBrowser(IntPtr.Zero);
            }

            RenderHandler = new DefaultRenderHandler(this);
        }
Esempio n. 5
0
        private void InitializeFieldsAndCefIfRequired()
        {
            if (!initialized)
            {
                if (!Cef.IsInitialized && !Cef.Initialize(new CefSettings()))
                {
                    throw new InvalidOperationException("Cef::Initialize() failed");
                }

                Cef.AddDisposable(this);

                if (FocusHandler == null)
                {
                    //If the WinForms UI thread and the CEF UI thread are one in the same
                    //then we don't need the FocusHandler, it's only required when using
                    //MultiThreadedMessageLoop (the default)
                    if (!Cef.CurrentlyOnThread(CefThreadIds.TID_UI))
                    {
                        FocusHandler = new DefaultFocusHandler();
                    }
                }

                if (browserSettings == null)
                {
                    browserSettings = new BrowserSettings(frameworkCreated: true);
                }

                managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, false);

                initialized = true;
            }
        }
Esempio n. 6
0
        private void InitializeFieldsAndCefIfRequired()
        {
            if (!initialized)
            {
                if (!Cef.IsInitialized && !Cef.Initialize())
                {
                    throw new InvalidOperationException("Cef::Initialize() failed");
                }

                Cef.AddDisposable(this);

                if (FocusHandler == null)
                {
                    FocusHandler = new DefaultFocusHandler(this);
                }

                if (ResourceHandlerFactory == null)
                {
                    ResourceHandlerFactory = new DefaultResourceHandlerFactory();
                }

                if (BrowserSettings == null)
                {
                    BrowserSettings = new BrowserSettings();
                }

                managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, false);

                initialized = true;
            }
        }
        private void InitializeFieldsAndCefIfRequired()
        {
            if (!initialized)
            {
                if (!Cef.IsInitialized && !Cef.Initialize(new CefSettings()))
                {
                    throw new InvalidOperationException("Cef::Initialize() failed");
                }

                Cef.AddDisposable(this);

                if (FocusHandler == null)
                {
                    FocusHandler = new DefaultFocusHandler();
                }

                if (browserSettings == null)
                {
                    browserSettings = new BrowserSettings(frameworkCreated: true);
                }

                managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, false);

                initialized = true;
            }
        }
Esempio n. 8
0
        private void InitializeFieldsAndCefIfRequired()
        {
            if (!initialized)
            {
                if (!Cef.IsInitialized && !Cef.Initialize())
                {
                    throw new InvalidOperationException("Cef::Initialize() failed");
                }

                Cef.AddDisposable(this);

                if (ResourceHandlerFactory == null)
                {
                    ResourceHandlerFactory = new DefaultResourceHandlerFactory();
                }

                if (BrowserSettings == null)
                {
                    BrowserSettings = new BrowserSettings();
                }

                // To allow cross-origin request.
                // This prevents the error: no 'access-control-allow-origin' header is present on the requested resource for XHR requests.
                BrowserSettings.FileAccessFromFileUrls      = CefState.Enabled;
                BrowserSettings.UniversalAccessFromFileUrls = CefState.Enabled;
                BrowserSettings.WebSecurity = CefState.Enabled;

                managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, false);

                initialized = true;
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Create a new OffScreen Chromium Browser. If you use <see cref="CefSharp.JavascriptBinding.JavascriptBindingSettings.LegacyBindingEnabled"/> = true then you must
        /// set <paramref name="automaticallyCreateBrowser"/> to false and call <see cref="CreateBrowser"/> after the objects are registered.
        /// </summary>
        /// <param name="address">Initial address (url) to load</param>
        /// <param name="browserSettings">The browser settings to use. If null, the default settings are used.</param>
        /// <param name="requestContext">See <see cref="RequestContext" /> for more details. Defaults to null</param>
        /// <param name="automaticallyCreateBrowser">automatically create the underlying Browser</param>
        /// <exception cref="System.InvalidOperationException">Cef::Initialize() failed</exception>
        public ChromiumWebBrowser(string address = "", BrowserSettings browserSettings = null,
                                  IRequestContext requestContext = null, bool automaticallyCreateBrowser = true)
        {
            if (!Cef.IsInitialized)
            {
                var settings = new CefSettings();

                if (!Cef.Initialize(settings))
                {
                    throw new InvalidOperationException("Cef::Initialize() failed");
                }
            }

            RequestContext = requestContext;

            Cef.AddDisposable(this);
            Address = address;

            managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, true);

            if (automaticallyCreateBrowser)
            {
                CreateBrowser(null, browserSettings);
            }

            RenderHandler = new DefaultRenderHandler(this);
        }
Esempio n. 10
0
        /// <summary>
        /// Create a new OffScreen Chromium Browser
        /// </summary>
        /// <param name="address">Initial address (url) to load</param>
        /// <param name="browserSettings">The browser settings to use. If null, the default settings are used.</param>
        /// <param name="requestContext">See <see cref="RequestContext" /> for more details. Defaults to null</param>
        /// <param name="automaticallyCreateBrowser">automatically create the underlying Browser</param>
        /// <exception cref="System.InvalidOperationException">Cef::Initialize() failed</exception>
        public ChromiumWebBrowser(string address = "", BrowserSettings browserSettings = null,
                                  RequestContext requestContext = null, bool automaticallyCreateBrowser = true)
        {
            if (!Cef.IsInitialized && !Cef.Initialize())
            {
                throw new InvalidOperationException("Cef::Initialize() failed");
            }

            ResourceHandlerFactory = new DefaultResourceHandlerFactory();
            BrowserSettings        = browserSettings ?? new BrowserSettings();
            RequestContext         = requestContext;

            Cef.AddDisposable(this);
            Address = address;

            managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, true);

            if (automaticallyCreateBrowser)
            {
                CreateBrowser(IntPtr.Zero);
            }

            BitmapBuffer  = new BitmapBuffer(BitmapLock);
            PopupBuffer   = new BitmapBuffer(BitmapLock);
            popupPosition = new Point();
            popupSize     = new Size();
        }
Esempio n. 11
0
        public ChromiumWebBrowser(string address)
        {
            Cef.AddDisposable(this);
            Address = address;

            Dock = DockStyle.Fill;

            FocusHandler = new DefaultFocusHandler(this);
        }
Esempio n. 12
0
        public FormReceipt()
        {
            InitializeComponent();
            if (!Cef.IsInitialized)
            {
                Cef.Initialize(settings);
            }

            Cef.AddDisposable(this);
        }
Esempio n. 13
0
        /// <summary>
        /// Create a new OffScreen Chromium Browser
        /// </summary>
        /// <param name="address">Initial address (url) to load</param>
        /// <param name="browserSettings">The browser settings to use. If null, the default settings are used.</param>
        public ChromiumWebBrowser(string address, BrowserSettings browserSettings = null)
        {
            ResourceHandler = new DefaultResourceHandler();

            Cef.AddDisposable(this);
            Address = address;

            managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, true);
            managedCefBrowserAdapter.CreateOffscreenBrowser(IntPtr.Zero, browserSettings ?? new BrowserSettings(), address);
        }
Esempio n. 14
0
        public ChromiumWebBrowser()
        {
            if (!Cef.IsInitialized && !Cef.Initialize())
            {
                throw new InvalidOperationException("Cef::Initialize() failed");
            }

            Cef.AddDisposable(this);
            Focusable        = true;
            FocusVisualStyle = null;
            IsTabStop        = true;

            Dispatcher.BeginInvoke((Action)(() => WebBrowser = this));

            Loaded += OnLoaded;

            GotKeyboardFocus  += OnGotKeyboardFocus;
            LostKeyboardFocus += OnLostKeyboardFocus;

            IsVisibleChanged += OnIsVisibleChanged;

            ToolTip            = toolTip = new ToolTip();
            toolTip.StaysOpen  = true;
            toolTip.Visibility = Visibility.Collapsed;
            toolTip.Closed    += OnTooltipClosed;


            BackCommand       = new DelegateCommand(Back, () => CanGoBack);
            ForwardCommand    = new DelegateCommand(Forward, () => CanGoForward);
            ReloadCommand     = new DelegateCommand(Reload, () => CanReload);
            PrintCommand      = new DelegateCommand(Print);
            ZoomInCommand     = new DelegateCommand(ZoomIn);
            ZoomOutCommand    = new DelegateCommand(ZoomOut);
            ZoomResetCommand  = new DelegateCommand(ZoomReset);
            ViewSourceCommand = new DelegateCommand(ViewSource);
            CleanupCommand    = new DelegateCommand(Dispose);
            StopCommand       = new DelegateCommand(Stop);
            CutCommand        = new DelegateCommand(Cut);
            CopyCommand       = new DelegateCommand(Copy);
            PasteCommand      = new DelegateCommand(Paste);
            SelectAllCommand  = new DelegateCommand(SelectAll);
            UndoCommand       = new DelegateCommand(Undo);
            RedoCommand       = new DelegateCommand(Redo);

            managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, true);

            disposables.Add(managedCefBrowserAdapter);
            disposables.Add(new DisposableEventWrapper(this, ActualHeightProperty, OnActualSizeChanged));
            disposables.Add(new DisposableEventWrapper(this, ActualWidthProperty, OnActualSizeChanged));

            ResourceHandler = new DefaultResourceHandler();
            BrowserSettings = new BrowserSettings();

            PresentationSource.AddSourceChangedHandler(this, PresentationSourceChangedHandler);
        }
Esempio n. 15
0
        protected void Initialize()
        {
            Application.ApplicationExit += OnApplicationExit;
            Cef.AddDisposable(this);
            // Dock = DockStyle.Fill;

            FocusHandler    = new DefaultFocusHandler(this);
            ResourceHandler = new DefaultResourceHandler();

            managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this);
        }
Esempio n. 16
0
        public ChromiumWebBrowser(string address)
        {
            Cef.AddDisposable(this);
            Address = address;

            Dock = DockStyle.Fill;

            FocusHandler    = new DefaultFocusHandler(this);
            ResourceHandler = new DefaultResourceHandler();

            managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, false);
        }
Esempio n. 17
0
        public ChromiumWebBrowser(string address)
        {
            Cef.AddDisposable(this);
            Address = address;

            Paint += OnPaint;

            //Redraw on Resize so Cef is notified and updates accordingly
            SetStyle(ControlStyles.ResizeRedraw, true);

            Dock = DockStyle.Fill;
        }
Esempio n. 18
0
        /// <summary>
        /// Create a new OffScreen Chromium Browser
        /// </summary>
        /// <param name="address">Initial address (url) to load</param>
        /// <param name="browserSettings">The browser settings to use. If null, the default settings are used.</param>
        public ChromiumWebBrowser(string address, BrowserSettings browserSettings = null)
        {
            if (!Cef.IsInitialized && !Cef.Initialize())
            {
                throw new InvalidOperationException("Cef::Initialize() failed");
            }

            ResourceHandler = new DefaultResourceHandler();

            Cef.AddDisposable(this);
            Address = address;

            managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, true);
            managedCefBrowserAdapter.CreateOffscreenBrowser(IntPtr.Zero, browserSettings ?? new BrowserSettings(), address);
        }
Esempio n. 19
0
        public static IDisposable UseCef()
        {
            if (Cef.IsInitialized)
            {
                return(null);
            }
            var scan     = Task.Run(PlugInManager.Scan); //异步扫描
            var settings = CreateCefSettings();

            SupportAnyCpu(settings);
            Cef.Initialize(settings);
            scan.Wait();
            Cef.AddDisposable(scan.Result);
            return(new Disposable());
        }
Esempio n. 20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ChromiumWebBrowser"/> class.
        /// </summary>
        /// <param name="address">The address.</param>
        /// <exception cref="System.InvalidOperationException">Cef::Initialize() failed</exception>
        public ChromiumWebBrowser(string address)
        {
            if (!Cef.IsInitialized && !Cef.Initialize())
            {
                throw new InvalidOperationException("Cef::Initialize() failed");
            }

            Cef.AddDisposable(this);
            Address = address;

            Dock = DockStyle.Fill;

            FocusHandler           = new DefaultFocusHandler(this);
            ResourceHandlerFactory = new DefaultResourceHandlerFactory();
            BrowserSettings        = new BrowserSettings();

            managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, false);
        }
Esempio n. 21
0
        public Blinkki()
        {
            InitializeComponent();
            Cef.EnableHighDPISupport();
            Cef.AddDisposable(this);

            CefSettings settings = new CefSettings();

            settings.CachePath = System.IO.Path.GetTempPath();

            //settings.CefCommandLineArgs.Add("enable-npapi", "1");
            settings.Locale    = CultureInfo.CurrentCulture.Name;
            settings.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0";

            Cef.Initialize(settings);

            dockPanel.DocumentStyle = DocumentStyle.DockingWindow;
            //dockPanel.DocumentTabStripLocation = DocumentTabStripLocation.Bottom;

            dockPanel.Theme = new WeifenLuo.WinFormsUI.Docking.VS2012LightTheme();
            DockPaneStripSkin dockPaneSkin = new DockPaneStripSkin();

            dockPaneSkin.DocumentGradient.DockStripGradient.LinearGradientMode = LinearGradientMode.Vertical;
            dockPaneSkin.DocumentGradient.DockStripGradient.StartColor         = Color.Silver;
            dockPaneSkin.DocumentGradient.DockStripGradient.EndColor           = Color.White;

            dockPaneSkin.DocumentGradient.ActiveTabGradient.StartColor = Color.White;
            dockPaneSkin.DocumentGradient.ActiveTabGradient.EndColor   = Color.White;
            dockPaneSkin.DocumentGradient.ActiveTabGradient.TextColor  = Color.FromArgb(32, 32, 32);
            //dockPaneSkin.DocumentGradient.ActiveTabGradient.LinearGradientMode = System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal;
            dockPaneSkin.DocumentGradient.InactiveTabGradient.LinearGradientMode = LinearGradientMode.Vertical;
            dockPaneSkin.DocumentGradient.InactiveTabGradient.StartColor         = Color.Silver;
            dockPaneSkin.DocumentGradient.InactiveTabGradient.EndColor           = Color.WhiteSmoke;
            dockPaneSkin.DocumentGradient.InactiveTabGradient.TextColor          = Color.White;

            dockPanel.ShowDocumentIcon = true;

            Font theFont = new Font("SegoeUI", 10.0F, FontStyle.Regular);

            foreach (Control theControl in (GetAllControls(this)))
            {
                theControl.Font = theFont;
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Create a new OffScreen Chromium Browser. If you use <see cref="CefSharp.JavascriptBinding.JavascriptBindingSettings.LegacyBindingEnabled"/> = true then you must
        /// set <paramref name="automaticallyCreateBrowser"/> to false and call <see cref="CreateBrowser"/> after the objects are registered.
        /// </summary>
        /// <param name="address">Initial address (url) to load</param>
        /// <param name="browserSettings">The browser settings to use. If null, the default settings are used.</param>
        /// <param name="requestContext">See <see cref="RequestContext" /> for more details. Defaults to null</param>
        /// <param name="automaticallyCreateBrowser">automatically create the underlying Browser</param>
        /// <exception cref="System.InvalidOperationException">Cef::Initialize() failed</exception>
        public ChromiumWebBrowser(string address, IBrowserSettings browserSettings, IRequestContext requestContext, bool automaticallyCreateBrowser, IRenderTarget renderer)
        {
            if (!Cef.IsInitialized)
            {
                throw new InvalidOperationException("Cef IS NOT INITIALIZED");
            }

            RequestContext = requestContext;
            _renderTarget  = renderer;
            Cef.AddDisposable(this);
            Address = address;

            managedCefBrowserAdapter = ManagedCefBrowserAdapter.Create(this, true);

            if (automaticallyCreateBrowser)
            {
                CreateBrowser(null, browserSettings);
            }
        }
        /// <summary>
        /// Create a new OffScreen Chromium Browser.
        /// </summary>
        /// <param name="height">Height of browser</param>
        /// <param name="address">Initial address (url) to load</param>
        /// <param name="browserSettings">The browser settings to use. If null, the default settings are used.</param>
        /// <param name="requestcontext">See <see cref="RequestContext"/> for more details. Defaults to null</param>
        /// <param name="width">Width of browser</param>
        public ChromiumWebBrowserController(int width = 1366, int height = 768, string address = "",
                                            RequestContext requestcontext = null, BrowserSettings browserSettings = null)
        {
            if (!Cef.IsInitialized && !Cef.Initialize())
            {
                throw new InvalidOperationException("Cef::Initialize() failed");
            }

            size = new Size(width, height);
            ResourceHandlerFactory = new DefaultResourceHandlerFactory();
            BrowserSettings        = browserSettings ?? new BrowserSettings();
            RequestContext         = requestcontext;

            Cef.AddDisposable(this);
            Address = address;

            managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, true);
            managedCefBrowserAdapter.CreateOffscreenBrowser(IntPtr.Zero, BrowserSettings, RequestContext, address);
        }
Esempio n. 24
0
        public ChromiumWebBrowser()
        {
            Cef.AddDisposable(this);
            Focusable        = true;
            FocusVisualStyle = null;
            IsTabStop        = true;

            Dispatcher.BeginInvoke((Action)(() => WebBrowser = this));

            Loaded   += OnLoaded;
            Unloaded += OnUnloaded;

            GotKeyboardFocus  += OnGotKeyboardFocus;
            LostKeyboardFocus += OnLostKeyboardFocus;

            IsVisibleChanged += OnIsVisibleChanged;

            ToolTip            = toolTip = new ToolTip();
            toolTip.StaysOpen  = true;
            toolTip.Visibility = Visibility.Collapsed;
            toolTip.Closed    += OnTooltipClosed;


            BackCommand       = new DelegateCommand(Back, () => CanGoBack);
            ForwardCommand    = new DelegateCommand(Forward, () => CanGoForward);
            ReloadCommand     = new DelegateCommand(Reload, () => CanReload);
            PrintCommand      = new DelegateCommand(Print);
            ZoomInCommand     = new DelegateCommand(ZoomIn);
            ZoomOutCommand    = new DelegateCommand(ZoomOut);
            ZoomResetCommand  = new DelegateCommand(ZoomReset);
            ViewSourceCommand = new DelegateCommand(ViewSource);
            CleanupCommand    = new DelegateCommand(Dispose);
            StopCommand       = new DelegateCommand(Stop);

            managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this);
            managedCefBrowserAdapter.CreateOffscreenBrowser(BrowserSettings ?? new BrowserSettings());

            disposables.Add(managedCefBrowserAdapter);

            disposables.Add(new DisposableEventWrapper(this, ActualHeightProperty, OnActualSizeChanged));
            disposables.Add(new DisposableEventWrapper(this, ActualWidthProperty, OnActualSizeChanged));
        }
Esempio n. 25
0
        private void web_view_Shown(object sender, EventArgs e)
        {
            if (Cef.IsInitialized)
            {
                AddBrowserToPanel(CefBrowser(this.url));
            }
            else
            {
                Cef.EnableHighDPISupport();
                Cef.AddDisposable(this);

                CefSettings settings = new CefSettings();
                settings.CachePath = System.IO.Path.GetTempPath();

                //settings.CefCommandLineArgs.Add("enable-npapi", "1");
                settings.Locale    = CultureInfo.CurrentCulture.Name;
                settings.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0";

                Cef.Initialize(settings);
                AddBrowserToPanel(CefBrowser(this.url));
            }
        }
Esempio n. 26
0
        public Blaze()
        {
            InitializeComponent();
            Cef.EnableHighDPISupport();
            Cef.AddDisposable(this);

            CefSettings settings = new CefSettings();

            settings.CachePath = System.IO.Path.GetTempPath();

            //settings.CefCommandLineArgs.Add("enable-npapi", "1");
            settings.Locale    = CultureInfo.CurrentCulture.Name;
            settings.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0";

            Cef.Initialize(settings);

            dockPanel.DocumentStyle = DocumentStyle.DockingWindow;
            dockPanel.Theme         = new WeifenLuo.WinFormsUI.Docking.VS2015LightTheme();
            DockPaneStripSkin dockPaneSkin = new DockPaneStripSkin();

            dockPaneSkin.DocumentGradient.DockStripGradient.LinearGradientMode = LinearGradientMode.Vertical;
            dockPaneSkin.DocumentGradient.DockStripGradient.StartColor         = Color.Silver;
            dockPaneSkin.DocumentGradient.DockStripGradient.EndColor           = Color.White;

            dockPaneSkin.DocumentGradient.ActiveTabGradient.StartColor = Color.White;
            dockPaneSkin.DocumentGradient.ActiveTabGradient.EndColor   = Color.White;
            dockPaneSkin.DocumentGradient.ActiveTabGradient.TextColor  = Color.FromArgb(32, 32, 32);

            dockPaneSkin.DocumentGradient.InactiveTabGradient.LinearGradientMode = LinearGradientMode.Vertical;
            dockPaneSkin.DocumentGradient.InactiveTabGradient.StartColor         = Color.Silver;
            dockPaneSkin.DocumentGradient.InactiveTabGradient.EndColor           = Color.WhiteSmoke;
            dockPaneSkin.DocumentGradient.InactiveTabGradient.TextColor          = Color.White;



            dockPanel.ShowDocumentIcon = true;
        }
Esempio n. 27
0
 public ChromiumWebBrowser(string address)
 {
     Cef.AddDisposable(this);
     Address = address;
 }
Esempio n. 28
0
 public WebView(string address)
 {
     Cef.AddDisposable(this);
     Address = address;
 }
Esempio n. 29
0
        public ChromiumWebBrowser()
        {
            if (!Cef.IsInitialized && !Cef.Initialize())
            {
                throw new InvalidOperationException("Cef::Initialize() failed");
            }

            BitmapFactory = new BitmapFactory();

            Cef.AddDisposable(this);
            Focusable        = true;
            FocusVisualStyle = null;
            IsTabStop        = true;

            Dispatcher.BeginInvoke((Action)(() => WebBrowser = this));

            Loaded      += OnLoaded;
            SizeChanged += OnActualSizeChanged;

            GotKeyboardFocus  += OnGotKeyboardFocus;
            LostKeyboardFocus += OnLostKeyboardFocus;

            // Drag Drop events
            DragEnter += OnDragEnter;
            DragOver  += OnDragOver;
            DragLeave += OnDragLeave;
            Drop      += OnDrop;

            IsVisibleChanged += OnIsVisibleChanged;

            ToolTip            = toolTip = new ToolTip();
            toolTip.StaysOpen  = true;
            toolTip.Visibility = Visibility.Collapsed;
            toolTip.Closed    += OnTooltipClosed;

            BackCommand       = new DelegateCommand(this.Back, () => CanGoBack);
            ForwardCommand    = new DelegateCommand(this.Forward, () => CanGoForward);
            ReloadCommand     = new DelegateCommand(this.Reload, () => !IsLoading);
            PrintCommand      = new DelegateCommand(this.Print);
            ZoomInCommand     = new DelegateCommand(ZoomIn);
            ZoomOutCommand    = new DelegateCommand(ZoomOut);
            ZoomResetCommand  = new DelegateCommand(ZoomReset);
            ViewSourceCommand = new DelegateCommand(this.ViewSource);
            CleanupCommand    = new DelegateCommand(Dispose);
            StopCommand       = new DelegateCommand(this.Stop);
            CutCommand        = new DelegateCommand(this.Cut);
            CopyCommand       = new DelegateCommand(this.Copy);
            PasteCommand      = new DelegateCommand(this.Paste);
            SelectAllCommand  = new DelegateCommand(this.SelectAll);
            UndoCommand       = new DelegateCommand(this.Undo);
            RedoCommand       = new DelegateCommand(this.Redo);

            managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, true);

            ResourceHandlerFactory = new DefaultResourceHandlerFactory();
            BrowserSettings        = new BrowserSettings();

            PresentationSource.AddSourceChangedHandler(this, PresentationSourceChangedHandler);

            RenderOptions.SetBitmapScalingMode(this, BitmapScalingMode.NearestNeighbor);
        }