diff --git a/CefSharp.MinimalExample.Wpf/App.xaml.cs b/CefSharp.MinimalExample.Wpf/App.xaml.cs
index 1668715..a516982 100644
--- a/CefSharp.MinimalExample.Wpf/App.xaml.cs
+++ b/CefSharp.MinimalExample.Wpf/App.xaml.cs
@@ -40,5 +40,17 @@ namespace CefSharp.MinimalExample.Wpf
Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);
}
}
+
+ public static void RunUIThread(Action action)
+ {
+ if (Current.CheckAccess())
+ {
+ action?.Invoke();
+ }
+ else
+ {
+ Current.Dispatcher.BeginInvoke(action);
+ }
+ }
}
}
diff --git a/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj b/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj
index e389f60..c5fa7e3 100644
--- a/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj
+++ b/CefSharp.MinimalExample.Wpf/CefSharp.MinimalExample.Wpf.csproj
@@ -103,12 +103,17 @@
..\packages\CefSharp.Wpf.107.1.120\lib\net452\CefSharp.Wpf.dll
True
+
+ ..\packages\log4net.2.0.15\lib\net45\log4net.dll
+
..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.19\lib\net45\Microsoft.Xaml.Behaviors.dll
+
+
4.0
diff --git a/CefSharp.MinimalExample.Wpf/MainWindow.xaml b/CefSharp.MinimalExample.Wpf/MainWindow.xaml
index e0d7b2c..cc63a66 100644
--- a/CefSharp.MinimalExample.Wpf/MainWindow.xaml
+++ b/CefSharp.MinimalExample.Wpf/MainWindow.xaml
@@ -1,13 +1,13 @@
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:wpf="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
+ xmlns:cef="clr-namespace:CefSharp;assembly=CefSharp.Core"
+ xmlns:behaviours="clr-namespace:CefSharp.MinimalExample.Wpf.Behaviours"
+ xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
+ Title="{Binding Path=Title, ElementName=Browser, Converter={StaticResource TitleConverter}}"
+ FocusManager.FocusedElement="{Binding ElementName=Browser}"
+ WindowState="Maximized">
@@ -23,6 +23,10 @@
+
+
+
+
@@ -30,32 +34,52 @@
-
-
-
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Address="https://www.google.com">
-
+
-
+
@@ -74,9 +98,12 @@
- Chromium: , CEF: , CefSharp: , Environment:
+ Chromium: , CEF:
+ , CefSharp:
+ , Environment:
+
-
+
\ No newline at end of file
diff --git a/CefSharp.MinimalExample.Wpf/MainWindow.xaml.cs b/CefSharp.MinimalExample.Wpf/MainWindow.xaml.cs
index bc19c9c..7310db4 100644
--- a/CefSharp.MinimalExample.Wpf/MainWindow.xaml.cs
+++ b/CefSharp.MinimalExample.Wpf/MainWindow.xaml.cs
@@ -7,6 +7,63 @@ namespace CefSharp.MinimalExample.Wpf
public MainWindow()
{
InitializeComponent();
+ Browser.FrameLoadStart += BrowserOnFrameLoadStart;
+ Browser.FrameLoadEnd += BrowserOnFrameLoadEnd;
+ }
+
+ private void BrowserOnFrameLoadEnd(object sender, FrameLoadEndEventArgs e)
+ {
+ }
+
+ private void BrowserOnFrameLoadStart(object sender, FrameLoadStartEventArgs e)
+ {
+ }
+
+ private void JsBtn_OnClick(object sender, RoutedEventArgs e)
+ {
+ object[] args = new object[2];
+ args[0] = JsArgs1Tb.Text;
+ args[1] = JsArgs2Tb.Text;
+ if (HasValueCb.IsChecked ?? false)
+ {
+ ExecuteJs(JsTb.Text, (HasArgsCb.IsChecked ?? false) ? args : null);
+ }
+ else
+ {
+ ExecuteJsNoValue(JsTb.Text, (HasArgsCb.IsChecked ?? false) ? args : null);
+ }
+ }
+
+ private void ExecuteJsNoValue(string js, object[] args = null)
+ {
+ if (!string.IsNullOrEmpty(js))
+ {
+ js = args == null ? js : WebBrowserExtensions.GetScriptForJavascriptMethodWithArgs(js, args);
+ Browser.ExecuteScriptAsync(js);
+ }
+ else
+ {
+ JsResultTb.Text = "js is empty!";
+ }
+ }
+
+ private void ExecuteJs(string js, object[] args = null)
+ {
+ if (!string.IsNullOrEmpty(js))
+ {
+ js = args == null ? js : WebBrowserExtensions.GetScriptForJavascriptMethodWithArgs(js, args);
+ Browser.EvaluateScriptAsync(js).ContinueWith(o =>
+ {
+ App.RunUIThread(() =>
+ {
+ JsResultTb.Text = (o?.Result?.Success ?? false) ? o?.Result?.Result?.ToString() : o?.Result?.Message;
+ });
+ });
+ }
+ else
+ {
+ JsResultTb.Text = "js is empty!";
+ }
}
}
}
diff --git a/CefSharp.MinimalExample.Wpf/packages.config b/CefSharp.MinimalExample.Wpf/packages.config
index 26dde4e..8563492 100644
--- a/CefSharp.MinimalExample.Wpf/packages.config
+++ b/CefSharp.MinimalExample.Wpf/packages.config
@@ -5,4 +5,5 @@
+
\ No newline at end of file