Skip to content

Commit 24888a2

Browse files
authored
Merge 2c5626a into d0486b3
2 parents d0486b3 + 2c5626a commit 24888a2

24 files changed

+96
-17
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "CefSharp.Wpf.HwndHost"]
2+
path = CefSharp.Wpf.HwndHost
3+
url = https://github.com/cefsharp/CefSharp.Wpf.HwndHost.git

CefSharp.Wpf.Example/App.xaml.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
using CefSharp.Example;
77
using CefSharp.Example.Handlers;
88
using CefSharp.Wpf.Example.Handlers;
9-
9+
#if CEFSHARP_WPF_HWNDHOST
10+
using CefSharp.Wpf.HwndHost;
11+
#endif
1012
namespace CefSharp.Wpf.Example
1113
{
1214
public partial class App : Application

CefSharp.Wpf.Example/CefSharp.Wpf.Example.netcore.csproj

+15-1
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@
3535
<SelfContained Condition="'$(Configuration)' == 'Debug'">false</SelfContained>
3636
</PropertyGroup>
3737

38+
<PropertyGroup Condition="'False'">
39+
<DefineConstants>$(DefineConstants);CEFSHARP_WPF_HWNDHOST</DefineConstants>
40+
</PropertyGroup>
3841
<ItemGroup>
3942
<ProjectReference Include="..\CefSharp.Core\CefSharp.Core.netcore.csproj" />
4043
<ProjectReference Include="..\CefSharp.Example\CefSharp.Example.netcore.csproj" />
41-
<ProjectReference Include="..\CefSharp.Wpf\CefSharp.Wpf.netcore.csproj" />
4244
<ProjectReference Include="..\CefSharp\CefSharp.netcore.csproj" />
4345
<PackageReference Include="chromiumembeddedframework.runtime" Version="129.0.11" />
4446
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
@@ -49,6 +51,18 @@
4951
<PackageReference Include="MaterialDesignThemes" Version="4.8.0" />
5052
</ItemGroup>
5153

54+
<Choose>
55+
<When Condition="$(DefineConstants.Contains(CEFSHARP_WPF_HWNDHOST))">
56+
<ItemGroup>
57+
<ProjectReference Include="..\CefSharp.Wpf.HwndHost\CefSharp.Wpf.HwndHost\CefSharp.Wpf.HwndHost.csproj" />
58+
</ItemGroup>
59+
</When>
60+
<Otherwise>
61+
<ItemGroup>
62+
<ProjectReference Include="..\CefSharp.Wpf\CefSharp.Wpf.netcore.csproj" />
63+
</ItemGroup>
64+
</Otherwise>
65+
</Choose>
5266
<ItemGroup>
5367
<None Include="crash_reporter.cfg">
5468
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

CefSharp.Wpf.Example/ChangeParentWindow.xaml.cs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
44

55
using System.Windows;
6+
using CefSharp.Wpf.Example.Controls;
67

78
namespace CefSharp.Wpf.Example
89
{

CefSharp.Wpf.Example/Controls/ChromiumWebBrowserWithScreenshotSupport.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public Task<InteropBitmap> TakeScreenshot(Size screenshotSize, int? frameRate =
9797

9898
return screenshotTaskCompletionSource.Task;
9999
}
100-
100+
#if ! CEFSHARP_WPF_HWNDHOST
101101
protected override CefSharp.Structs.Rect GetViewRect()
102102
{
103103
if (isTakingScreenshot)
@@ -161,7 +161,7 @@ protected override void OnPaint(bool isPopup, Structs.Rect dirtyRect, IntPtr buf
161161
base.OnPaint(isPopup, dirtyRect, buffer, width, height);
162162
}
163163
}
164-
164+
#endif
165165
private void TakeScreenshot()
166166
{
167167
var uiThreadTaskScheduler = TaskScheduler.FromCurrentSynchronizationContext();

CefSharp.Wpf.Example/Controls/NonReloadingTabControl.cs

+2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
using System.Windows.Automation.Peers;
55
using System.Windows.Controls;
66
using System.Windows.Controls.Primitives;
7+
#if ! CEFSHARP_WPF_HWNDHOST
78
using TabControlAutomationPeer = CefSharp.Wpf.Experimental.Accessibility.TabControlAutomationPeer;
9+
#endif
810

911
namespace CefSharp.Wpf.Example.Controls
1012
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
#if CEFSHARP_WPF_HWNDHOST
7+
using CefSharp.Wpf.HwndHost;
8+
#endif
9+
namespace CefSharp.Wpf.Example.Controls
10+
{
11+
public class ChromiumWebBrowser :
12+
#if CEFSHARP_WPF_HWNDHOST
13+
CefSharp.Wpf.HwndHost.ChromiumWebBrowser
14+
#else
15+
CefSharp.Wpf.ChromiumWebBrowser
16+
#endif
17+
{
18+
public ChromiumWebBrowser(string initialAddress) : base(initialAddress){ }
19+
public ChromiumWebBrowser() { }
20+
}
21+
}

CefSharp.Wpf.Example/Handlers/DisplayHandler.cs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//
33
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
44

5+
using CefSharp.Wpf.Example.Controls;
56
using CefSharp.Wpf.Example.Views;
67
using System;
78
using System.Windows;

CefSharp.Wpf.Example/Handlers/JsDialogHandler.cs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
44

55
using System.Windows;
6+
using CefSharp.Wpf.Example.Controls;
67

78
namespace CefSharp.Wpf.Example.Handlers
89
{

CefSharp.Wpf.Example/Handlers/MenuHandler.cs

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
44

55
using System;
6+
#if ! CEFSHARP_WPF_HWNDHOST
67
using CefSharp.Wpf.Handler;
78

89
namespace CefSharp.Wpf.Example.Handlers
@@ -46,3 +47,5 @@ protected override void ExecuteCommand(IBrowser browser, ContextMenuExecuteModel
4647
}
4748
}
4849
}
50+
51+
#endif

CefSharp.Wpf.Example/JavascriptCallbackMainWindow.xaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Window x:Class="CefSharp.Wpf.Example.JavascriptCallbackMainWindow"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:wpf="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
4+
xmlns:wpf="clr-namespace:CefSharp.Wpf.Example.Controls"
55
Title="JavascriptCallbackMainWindow" WindowState="Maximized">
66
<Grid>
77
<Grid.RowDefinitions>
@@ -12,10 +12,10 @@
1212
</Grid.RowDefinitions>
1313
<wpf:ChromiumWebBrowser Grid.Row="0"
1414
x:Name="BrowserOne"
15-
Address="custom://cefsharp/JavascriptCallbackTest.html" BorderBrush="Red" BorderThickness="1"/>
15+
Address="custom://cefsharp/JavascriptCallbackTest.html" />
1616
<wpf:ChromiumWebBrowser Grid.Row="1"
1717
x:Name="BrowserTwo"
18-
Address="test://cefsharp/JavascriptCallbackTest.html" BorderBrush="Red" BorderThickness="1"/>
18+
Address="test://cefsharp/JavascriptCallbackTest.html"/>
1919
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center">
2020
<Button Content="Execute Callback Immediately" Click="ExecuteCallbackImmediatelyClick" Margin="0, 0, 10, 0"/>
2121
<Button Content="Execute Callback In 3 Seconds" Click="ExecuteCallbackInThreeSeconds"/>

CefSharp.Wpf.Example/JavascriptCallbackMainWindow.xaml.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ public partial class JavascriptCallbackMainWindow : Window
1515
public JavascriptCallbackMainWindow()
1616
{
1717
InitializeComponent();
18-
18+
#if ! CEFSHARP_WPF_HWNDHOST
19+
BrowserTwo.BorderBrush = BrowserOne.BorderBrush = System.Windows.Media.Brushes.Red;
20+
BrowserTwo.BorderThickness = BrowserOne.BorderThickness = new Thickness(1);
21+
#endif
1922
boundObjectOne = new JavascriptCallbackBoundObject(BrowserOne);
2023
boundObjectTwo = new JavascriptCallbackBoundObject(BrowserTwo);
2124

CefSharp.Wpf.Example/MainWindow.xaml.cs

+4
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,12 @@ private void CustomCommandBinding(object sender, ExecutedRoutedEventArgs e)
133133
}
134134
else if (param == "ToggleAudioMute")
135135
{
136+
#if CEFSHARP_WPF_HWNDHOST
137+
throw new NotImplementedException();
138+
#else
136139
var cmd = browserViewModel.WebBrowser.ToggleAudioMuteCommand;
137140
cmd.Execute(null);
141+
#endif
138142
}
139143
else if (param == "ClearHttpAuthCredentials")
140144
{

CefSharp.Wpf.Example/SimpleMainWindow.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Window x:Class="CefSharp.Wpf.Example.SimpleMainWindow"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:wpf="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
4+
xmlns:wpf="clr-namespace:CefSharp.Wpf.Example.Controls"
55
Title="SimpleMainWindow" WindowState="Maximized">
66
<Grid>
77
<Grid.RowDefinitions>

CefSharp.Wpf.Example/SpawnBrowsersWindow.xaml.cs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Threading.Tasks;
22
using System.Windows;
33
using System.Windows.Controls;
4+
using CefSharp.Wpf.Example.Controls;
45

56
namespace CefSharp.Wpf.Example
67
{

CefSharp.Wpf.Example/StandardTabControlWindow.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
x:Class="CefSharp.Wpf.Example.StandardTabControlWindow"
5-
xmlns:cefSharp="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
5+
xmlns:cefSharp="clr-namespace:CefSharp.Wpf.Example.Controls"
66
Title="TabControl Test Window" Height="594" Width="651">
77
<Grid>
88
<TabControl ItemsSource="{Binding Tabs}">

CefSharp.Wpf.Example/StandardTabControlWindow.xaml.cs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.Generic;
22
using System.Linq;
33
using System.Windows;
4+
using CefSharp.Wpf.Example.Controls;
45

56
namespace CefSharp.Wpf.Example
67
{

CefSharp.Wpf.Example/TouchKeyboardWin10MainWindow.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Window x:Class="CefSharp.Wpf.Example.TouchKeyboardWin10MainWindow"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:wpf="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
4+
xmlns:wpf="clr-namespace:CefSharp.Wpf.Example.Controls"
55
Title="SimpleMainWindow" WindowState="Maximized">
66
<Grid>
77
<Grid.RowDefinitions>

CefSharp.Wpf.Example/TouchKeyboardWin10MainWindow.xaml.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Windows;
66
using CefSharp.Enums;
77
using Microsoft.Windows.Input.TouchKeyboard;
8-
8+
#if ! CEFSHARP_WPF_HWNDHOST
99
namespace CefSharp.Wpf.Example
1010
{
1111
/// <summary>
@@ -56,3 +56,5 @@ private void BrowserVirtualKeyboardRequested(object sender, VirtualKeyboardReque
5656
}
5757
}
5858
}
59+
60+
#endif

CefSharp.Wpf.Example/ViewModels/BrowserTabViewModel.cs

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
using System.Windows;
1010
using System.Windows.Input;
1111
using CefSharp.Example;
12+
#if CEFSHARP_WPF_HWNDHOST
13+
using CefSharp.Wpf.HwndHost;
14+
#endif
1215

1316
namespace CefSharp.Wpf.Example.ViewModels
1417
{

CefSharp.Wpf.Example/Views/BrowserTabView.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
7-
xmlns:cefSharp="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
7+
xmlns:cefSharp="clr-namespace:CefSharp.Wpf.Example.Controls"
88
xmlns:local="clr-namespace:CefSharp.Wpf.Example.ViewModels"
99
xmlns:system="clr-namespace:System;assembly=mscorlib"
1010
mc:Ignorable="d"

CefSharp.Wpf.Example/Views/BrowserTabView.xaml.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
using CefSharp.Fluent;
1717
using CefSharp.Wpf.Example.Handlers;
1818
using CefSharp.Wpf.Example.ViewModels;
19+
#if ! CEFSHARP_WPF_HWNDHOST
1920
using CefSharp.Wpf.Experimental;
2021
using CefSharp.Wpf.Experimental.Accessibility;
22+
#endif
2123

2224
namespace CefSharp.Wpf.Example.Views
2325
{
@@ -31,9 +33,9 @@ public BrowserTabView()
3133
InitializeComponent();
3234

3335
DataContextChanged += OnDataContextChanged;
34-
36+
#if ! CEFSHARP_WPF_HWNDHOST
3537
browser.UsePopupMouseTransform();
36-
38+
#endif
3739
//browser.BrowserSettings.BackgroundColor = Cef.ColorSetARGB(0, 255, 255, 255);
3840

3941
//Please remove the comments below to use the Experimental WpfImeKeyboardHandler.
@@ -182,7 +184,7 @@ public BrowserTabView()
182184
}
183185
}).Build();
184186
*/
185-
187+
#if ! CEFSHARP_WPF_HWNDHOST
186188
browser.MenuHandler = new MenuHandler(addDevtoolsMenuItems:true);
187189

188190
//Enable experimental Accessibility support
@@ -195,7 +197,7 @@ public BrowserTabView()
195197
//browser.GetBrowserHost().SetAccessibilityState(CefState.Enabled);
196198
}
197199
};
198-
200+
#endif
199201
browser.DownloadHandler = DownloadHandler
200202
.Create()
201203
.CanDownload((chromiumWebBrowser, browser, url, requestMethod) =>

CefSharp.Wpf.HwndHost

Submodule CefSharp.Wpf.HwndHost added at 2a03055

CefSharp3.netcore.sln

+14
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CefSharp.Core.netcore", "Ce
7373
EndProject
7474
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CefSharp.Core.Runtime.RefAssembly.netcore", "CefSharp.Core.Runtime.RefAssembly\CefSharp.Core.Runtime.RefAssembly.netcore.csproj", "{A4AFD158-0B6F-4579-AE79-EC386C8BEA58}"
7575
EndProject
76+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp.Wpf.HwndHost", "..\CefSharp.Wpf.HwndHost\CefSharp.Wpf.HwndHost\CefSharp.Wpf.HwndHost.csproj", "{94AF2E6A-6508-451F-BF4A-56B9C0AB1993}"
77+
EndProject
7678
Global
7779
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7880
Debug|arm64 = Debug|arm64
@@ -243,6 +245,18 @@ Global
243245
{A4AFD158-0B6F-4579-AE79-EC386C8BEA58}.Release|x64.Build.0 = Release|Any CPU
244246
{A4AFD158-0B6F-4579-AE79-EC386C8BEA58}.Release|x86.ActiveCfg = Release|Any CPU
245247
{A4AFD158-0B6F-4579-AE79-EC386C8BEA58}.Release|x86.Build.0 = Release|Any CPU
248+
{94AF2E6A-6508-451F-BF4A-56B9C0AB1993}.Debug|arm64.ActiveCfg = Debug|x64
249+
{94AF2E6A-6508-451F-BF4A-56B9C0AB1993}.Debug|arm64.Build.0 = Debug|x64
250+
{94AF2E6A-6508-451F-BF4A-56B9C0AB1993}.Debug|x64.ActiveCfg = Debug|x64
251+
{94AF2E6A-6508-451F-BF4A-56B9C0AB1993}.Debug|x64.Build.0 = Debug|x64
252+
{94AF2E6A-6508-451F-BF4A-56B9C0AB1993}.Debug|x86.ActiveCfg = Debug|x64
253+
{94AF2E6A-6508-451F-BF4A-56B9C0AB1993}.Debug|x86.Build.0 = Debug|x64
254+
{94AF2E6A-6508-451F-BF4A-56B9C0AB1993}.Release|arm64.ActiveCfg = Release|x64
255+
{94AF2E6A-6508-451F-BF4A-56B9C0AB1993}.Release|arm64.Build.0 = Release|x64
256+
{94AF2E6A-6508-451F-BF4A-56B9C0AB1993}.Release|x64.ActiveCfg = Release|x64
257+
{94AF2E6A-6508-451F-BF4A-56B9C0AB1993}.Release|x64.Build.0 = Release|x64
258+
{94AF2E6A-6508-451F-BF4A-56B9C0AB1993}.Release|x86.ActiveCfg = Release|x64
259+
{94AF2E6A-6508-451F-BF4A-56B9C0AB1993}.Release|x86.Build.0 = Release|x64
246260
EndGlobalSection
247261
GlobalSection(SolutionProperties) = preSolution
248262
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)