From c0d667fc7a482072bcca1ea37d8f99f7b1e3fda9 Mon Sep 17 00:00:00 2001 From: amaitland Date: Mon, 2 Jul 2018 19:43:42 +1000 Subject: [PATCH 1/2] WinForms - SetFocus to ChromiumWebBrowser when browser has initialized You can now type directly into the Google search box --- CefSharp.MinimalExample.WinForms/BrowserForm.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CefSharp.MinimalExample.WinForms/BrowserForm.cs b/CefSharp.MinimalExample.WinForms/BrowserForm.cs index 1d6312d..4305333 100644 --- a/CefSharp.MinimalExample.WinForms/BrowserForm.cs +++ b/CefSharp.MinimalExample.WinForms/BrowserForm.cs @@ -26,6 +26,7 @@ namespace CefSharp.MinimalExample.WinForms }; toolStripContainer.ContentPanel.Controls.Add(browser); + browser.IsBrowserInitializedChanged += OnIsBrowserInitializedChanged; browser.LoadingStateChanged += OnLoadingStateChanged; browser.ConsoleMessage += OnBrowserConsoleMessage; browser.StatusMessage += OnBrowserStatusMessage; @@ -37,6 +38,16 @@ namespace CefSharp.MinimalExample.WinForms DisplayOutput(version); } + private void OnIsBrowserInitializedChanged(object sender, IsBrowserInitializedChangedEventArgs e) + { + if(e.IsBrowserInitialized) + { + var b = ((ChromiumWebBrowser)sender); + + this.InvokeOnUiThreadIfRequired(() => b.Focus()); + } + } + private void OnBrowserConsoleMessage(object sender, ConsoleMessageEventArgs args) { DisplayOutput(string.Format("Line: {0}, Source: {1}, Message: {2}", args.Line, args.Source, args.Message)); From 726c328f6a268f5eb13a28d758ed183a853f05bb Mon Sep 17 00:00:00 2001 From: amaitland Date: Fri, 13 Jul 2018 10:48:52 +1000 Subject: [PATCH 2/2] Winforms/WPF Example - Enable WebRTC Example of setting a command line argument --- CefSharp.MinimalExample.WinForms/Program.cs | 4 ++++ CefSharp.MinimalExample.Wpf/App.xaml.cs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CefSharp.MinimalExample.WinForms/Program.cs b/CefSharp.MinimalExample.WinForms/Program.cs index 31b22d6..0e33b59 100644 --- a/CefSharp.MinimalExample.WinForms/Program.cs +++ b/CefSharp.MinimalExample.WinForms/Program.cs @@ -22,6 +22,10 @@ namespace CefSharp.MinimalExample.WinForms CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache") }; + //Example of setting a command line argument + //Enables WebRTC + settings.CefCommandLineArgs.Add("enable-media-stream", "1"); + //Perform dependency check to make sure all relevant resources are in our output directory. Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null); diff --git a/CefSharp.MinimalExample.Wpf/App.xaml.cs b/CefSharp.MinimalExample.Wpf/App.xaml.cs index adaf068..9412ea8 100644 --- a/CefSharp.MinimalExample.Wpf/App.xaml.cs +++ b/CefSharp.MinimalExample.Wpf/App.xaml.cs @@ -14,6 +14,10 @@ namespace CefSharp.MinimalExample.Wpf CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache") }; + //Example of setting a command line argument + //Enables WebRTC + settings.CefCommandLineArgs.Add("enable-media-stream", "1"); + //Perform dependency check to make sure all relevant resources are in our output directory. Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null); }