Skip to content

Commit 9a01ca0

Browse files
committed
Base class changed to Rectangle & fix DefaultBackgroundColor
Improvement example project
1 parent 25bfda1 commit 9a01ca0

20 files changed

+299
-85
lines changed

Avalonia.WebView2.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Root", "_Root", "{61E7D838
1616
EndProject
1717
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.WebView2.Sample", "src\Avalonia.WebView2.Sample\Avalonia.WebView2.Sample.csproj", "{A08F349B-7924-440B-A3B6-A06A07BD3568}"
1818
EndProject
19+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Avalonia.Ref", "Avalonia.Ref", "{DC6BC752-4767-4682-92C7-3AE2C9BA5C84}"
20+
EndProject
21+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.X11", "src\Avalonia.Ref\Avalonia.X11\Avalonia.X11.csproj", "{47ECFB81-D3BA-4E50-8CCC-774FD482A9E4}"
22+
EndProject
23+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Native", "src\Avalonia.Ref\Avalonia.Native\Avalonia.Native.csproj", "{C3F8BEC7-5365-4C35-8236-BC853A592106}"
24+
EndProject
25+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Desktop", "src\Avalonia.Ref\Avalonia.Desktop\Avalonia.Desktop.csproj", "{F482B647-9FF9-4BCC-B8F7-59ACD76D2B51}"
26+
EndProject
1927
Global
2028
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2129
Debug|Any CPU = Debug|Any CPU
@@ -30,10 +38,27 @@ Global
3038
{A08F349B-7924-440B-A3B6-A06A07BD3568}.Debug|Any CPU.Build.0 = Debug|Any CPU
3139
{A08F349B-7924-440B-A3B6-A06A07BD3568}.Release|Any CPU.ActiveCfg = Release|Any CPU
3240
{A08F349B-7924-440B-A3B6-A06A07BD3568}.Release|Any CPU.Build.0 = Release|Any CPU
41+
{47ECFB81-D3BA-4E50-8CCC-774FD482A9E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42+
{47ECFB81-D3BA-4E50-8CCC-774FD482A9E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
43+
{47ECFB81-D3BA-4E50-8CCC-774FD482A9E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
44+
{47ECFB81-D3BA-4E50-8CCC-774FD482A9E4}.Release|Any CPU.Build.0 = Release|Any CPU
45+
{C3F8BEC7-5365-4C35-8236-BC853A592106}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
46+
{C3F8BEC7-5365-4C35-8236-BC853A592106}.Debug|Any CPU.Build.0 = Debug|Any CPU
47+
{C3F8BEC7-5365-4C35-8236-BC853A592106}.Release|Any CPU.ActiveCfg = Release|Any CPU
48+
{C3F8BEC7-5365-4C35-8236-BC853A592106}.Release|Any CPU.Build.0 = Release|Any CPU
49+
{F482B647-9FF9-4BCC-B8F7-59ACD76D2B51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50+
{F482B647-9FF9-4BCC-B8F7-59ACD76D2B51}.Debug|Any CPU.Build.0 = Debug|Any CPU
51+
{F482B647-9FF9-4BCC-B8F7-59ACD76D2B51}.Release|Any CPU.ActiveCfg = Release|Any CPU
52+
{F482B647-9FF9-4BCC-B8F7-59ACD76D2B51}.Release|Any CPU.Build.0 = Release|Any CPU
3353
EndGlobalSection
3454
GlobalSection(SolutionProperties) = preSolution
3555
HideSolutionNode = FALSE
3656
EndGlobalSection
57+
GlobalSection(NestedProjects) = preSolution
58+
{47ECFB81-D3BA-4E50-8CCC-774FD482A9E4} = {DC6BC752-4767-4682-92C7-3AE2C9BA5C84}
59+
{C3F8BEC7-5365-4C35-8236-BC853A592106} = {DC6BC752-4767-4682-92C7-3AE2C9BA5C84}
60+
{F482B647-9FF9-4BCC-B8F7-59ACD76D2B51} = {DC6BC752-4767-4682-92C7-3AE2C9BA5C84}
61+
EndGlobalSection
3762
GlobalSection(ExtensibilityGlobals) = postSolution
3863
SolutionGuid = {F80CD13F-5A1C-4F58-BDCA-4C2991EE56F4}
3964
EndGlobalSection
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
using System.Reflection;
2+
3+
[assembly: AssemblyVersion("255.255.255.255")]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Avalonia.Controls;
2+
using Avalonia.Platform;
3+
4+
// https://github.com/AvaloniaUI/Avalonia/blob/0.10.13/src/Avalonia.Desktop/AppBuilderDesktopExtensions.cs
5+
6+
namespace Avalonia
7+
{
8+
public static class AppBuilderDesktopExtensions
9+
{
10+
public static TAppBuilder UsePlatformDetect<TAppBuilder>(this TAppBuilder builder)
11+
where TAppBuilder : AppBuilderBase<TAppBuilder>, new()
12+
{
13+
#if WINDOWS
14+
builder.UseWin32();
15+
#else
16+
var os = builder.RuntimePlatform.GetRuntimeInfo().OperatingSystem;
17+
18+
// We don't have the ability to load every assembly right now, so we are
19+
// stuck with manual configuration here
20+
// Helpers are extracted to separate methods to take the advantage of the fact
21+
// that CLR doesn't try to load dependencies before referencing method is jitted
22+
// Additionally, by having a hard reference to each assembly,
23+
// we verify that the assemblies are in the final .deps.json file
24+
// so .NET Core knows where to load the assemblies from,.
25+
switch (os)
26+
{
27+
case OperatingSystemType.WinNT:
28+
builder.UseWin32();
29+
break;
30+
case OperatingSystemType.OSX:
31+
builder.UseAvaloniaNative();
32+
break;
33+
default:
34+
builder.UseX11();
35+
break;
36+
}
37+
#endif
38+
builder.UseSkia();
39+
return builder;
40+
}
41+
}
42+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net6.0;net6.0-windows</TargetFrameworks>
5+
<SignAssembly>true</SignAssembly>
6+
<DelaySign>false</DelaySign>
7+
<AssemblyOriginatorKeyFile>..\avalonia.snk</AssemblyOriginatorKeyFile>
8+
<!--https://github.com/AvaloniaUI/Avalonia/blob/0.10.10/build/SharedVersion.props#L18-->
9+
<IsTrimmable>true</IsTrimmable>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<Compile Include="..\AssemblyInfo.Version.Max.cs">
14+
<LinkBase>Properties</LinkBase>
15+
</Compile>
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<PackageReference Include="Avalonia.Win32" />
20+
<PackageReference Include="Avalonia.Skia" />
21+
</ItemGroup>
22+
23+
<ItemGroup Condition=" !$(TargetFramework.Contains('-windows')) ">
24+
<PackageReference Include="Avalonia.X11" />
25+
<PackageReference Include="Avalonia.Native" />
26+
</ItemGroup>
27+
28+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net6.0;net6.0-windows</TargetFrameworks>
5+
<SignAssembly>true</SignAssembly>
6+
<DelaySign>false</DelaySign>
7+
<AssemblyOriginatorKeyFile>..\avalonia.snk</AssemblyOriginatorKeyFile>
8+
<!--https://github.com/AvaloniaUI/Avalonia/blob/0.10.10/build/SharedVersion.props#L18-->
9+
<IsTrimmable>true</IsTrimmable>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<Compile Include="..\AssemblyInfo.Version.Max.cs">
14+
<LinkBase>Properties</LinkBase>
15+
</Compile>
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<PackageReference Include="Avalonia" />
20+
</ItemGroup>
21+
22+
</Project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#if !WINDOWS
2+
3+
using System;
4+
using Avalonia.Controls;
5+
6+
namespace Avalonia
7+
{
8+
public static class AvaloniaNativePlatformExtensions
9+
{
10+
public static T UseAvaloniaNative<T>(this T builder) where T : AppBuilderBase<T>, new()
11+
{
12+
throw new PlatformNotSupportedException();
13+
}
14+
}
15+
}
16+
17+
#endif
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<SignAssembly>true</SignAssembly>
6+
<DelaySign>false</DelaySign>
7+
<AssemblyOriginatorKeyFile>..\avalonia.snk</AssemblyOriginatorKeyFile>
8+
<!--https://github.com/AvaloniaUI/Avalonia/blob/0.10.10/build/SharedVersion.props#L18-->
9+
<IsTrimmable>true</IsTrimmable>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<Compile Include="..\AssemblyInfo.Version.Max.cs">
14+
<LinkBase>Properties</LinkBase>
15+
</Compile>
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<PackageReference Include="Avalonia" />
20+
</ItemGroup>
21+
22+
</Project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#if !WINDOWS
2+
3+
using System;
4+
using Avalonia.Controls;
5+
6+
namespace Avalonia
7+
{
8+
public static class AvaloniaX11PlatformExtensions
9+
{
10+
public static T UseX11<T>(this T builder) where T : AppBuilderBase<T>, new()
11+
{
12+
throw new PlatformNotSupportedException();
13+
}
14+
}
15+
}
16+
17+
#endif

src/Avalonia.Ref/avalonia.snk

596 Bytes
Binary file not shown.

src/Avalonia.WebView2.Sample/App.xaml.cs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
using Avalonia.Markup.Xaml;
2-
using AvaloniaWebView2 = Avalonia.Controls.WebView2;
3-
41
namespace Avalonia.WebView2.Sample;
52

63
public class App : Application
@@ -21,23 +18,9 @@ public override void OnFrameworkInitializationCompleted()
2118
base.OnFrameworkInitializationCompleted();
2219
}
2320

24-
public static bool AvailableWebView2 { get; private set; }
25-
26-
public static string? WebView2VersionString { get; private set; }
27-
2821
static void InitWebView2()
2922
{
30-
try
31-
{
32-
WebView2VersionString = CoreWebView2Environment.GetAvailableBrowserVersionString();
33-
if (!string.IsNullOrEmpty(WebView2VersionString)) AvailableWebView2 = true;
34-
}
35-
catch (WebView2RuntimeNotFoundException)
36-
{
37-
38-
}
39-
40-
if (AvailableWebView2)
23+
if (AvaloniaWebView2.IsSupported)
4124
{
4225
AvaloniaWebView2.DefaultCreationProperties = new()
4326
{

0 commit comments

Comments
 (0)