/// <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); }
/// <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()); }
/// <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; } }
/// <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); }
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; } }
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; } }
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; } }
/// <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); }
/// <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(); }
public ChromiumWebBrowser(string address) { Cef.AddDisposable(this); Address = address; Dock = DockStyle.Fill; FocusHandler = new DefaultFocusHandler(this); }
public FormReceipt() { InitializeComponent(); if (!Cef.IsInitialized) { Cef.Initialize(settings); } Cef.AddDisposable(this); }
/// <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); }
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); }
protected void Initialize() { Application.ApplicationExit += OnApplicationExit; Cef.AddDisposable(this); // Dock = DockStyle.Fill; FocusHandler = new DefaultFocusHandler(this); ResourceHandler = new DefaultResourceHandler(); managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this); }
public ChromiumWebBrowser(string address) { Cef.AddDisposable(this); Address = address; Dock = DockStyle.Fill; FocusHandler = new DefaultFocusHandler(this); ResourceHandler = new DefaultResourceHandler(); managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, false); }
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; }
/// <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); }
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()); }
/// <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); }
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; } }
/// <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); }
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)); }
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)); } }
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; }
public ChromiumWebBrowser(string address) { Cef.AddDisposable(this); Address = address; }
public WebView(string address) { Cef.AddDisposable(this); Address = address; }
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); }