committed by
GitHub
164 changed files with 4073 additions and 512 deletions
@ -1,6 +1,7 @@ |
|||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="HarfBuzzSharp" Version="2.6.1.7" /> |
<PackageReference Include="HarfBuzzSharp" Version="2.8.2-preview.171" /> |
||||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.6.1.7" /> |
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2-preview.171" /> |
||||
|
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.WebAssembly" Version="2.8.2-preview.171"/> |
||||
</ItemGroup> |
</ItemGroup> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -1,6 +1,7 @@ |
|||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="SkiaSharp" Version="2.80.2" /> |
<PackageReference Include="SkiaSharp" Version="2.88.0-preview.171" /> |
||||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.80.2" /> |
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.88.0-preview.171" /> |
||||
|
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.88.0-preview.171"/> |
||||
</ItemGroup> |
</ItemGroup> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -0,0 +1,10 @@ |
|||||
|
<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true"> |
||||
|
<Found Context="routeData"> |
||||
|
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> |
||||
|
</Found> |
||||
|
<NotFound> |
||||
|
<LayoutView Layout="@typeof(MainLayout)"> |
||||
|
<p>Sorry, there's nothing at this address.</p> |
||||
|
</LayoutView> |
||||
|
</NotFound> |
||||
|
</Router> |
||||
@ -0,0 +1,14 @@ |
|||||
|
using Avalonia.Web.Blazor; |
||||
|
|
||||
|
namespace ControlCatalog.Web; |
||||
|
|
||||
|
public partial class App |
||||
|
{ |
||||
|
protected override void OnParametersSet() |
||||
|
{ |
||||
|
WebAppBuilder.Configure<ControlCatalog.App>() |
||||
|
.SetupWithSingleViewLifetime(); |
||||
|
|
||||
|
base.OnParametersSet(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,38 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> |
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>net6.0</TargetFramework> |
||||
|
<Nullable>enable</Nullable> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<BlazorLinkerDescriptor Include="LinkerConfig.xml" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<!-- In debug, make builds faster by reducing optimizations --> |
||||
|
<PropertyGroup Condition="'$(Configuration)' == 'Debug'"> |
||||
|
<WasmNativeStrip>false</WasmNativeStrip> |
||||
|
<EmccCompileOptimizationFlag>-O1</EmccCompileOptimizationFlag> |
||||
|
<RunAOTCompilation>false</RunAOTCompilation> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> |
||||
|
<Optimize>true</Optimize> |
||||
|
<WasmNativeStrip>true</WasmNativeStrip> |
||||
|
<EmccCompileOptimizationFlag>-O3</EmccCompileOptimizationFlag> |
||||
|
<EmccLinkOptimizationFlag>-O3</EmccLinkOptimizationFlag> |
||||
|
<RunAOTCompilation>false</RunAOTCompilation> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.0"/> |
||||
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.0" PrivateAssets="all"/> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<Import Project="..\..\src\Web\Avalonia.Web.Blazor\Avalonia.Web.Blazor.targets" /> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\src\Web\Avalonia.Web.Blazor\Avalonia.Web.Blazor.csproj"/> |
||||
|
<ProjectReference Include="..\ControlCatalog\ControlCatalog.csproj"/> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,28 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!-- |
||||
|
This file specifies which parts of the BCL or Blazor packages must not be |
||||
|
stripped by the IL Linker even if they aren't referenced by user code. |
||||
|
--> |
||||
|
<linker> |
||||
|
<assembly fullname="mscorlib"> |
||||
|
<!-- |
||||
|
Preserve the methods in WasmRuntime because its methods are called by |
||||
|
JavaScript client-side code to implement timers. |
||||
|
Fixes: https://github.com/dotnet/blazor/issues/239 |
||||
|
--> |
||||
|
<type fullname="System.Threading.WasmRuntime"/> |
||||
|
</assembly> |
||||
|
|
||||
|
<assembly fullname="System.Core"> |
||||
|
<!-- |
||||
|
System.Linq.Expressions* is required by Json.NET and any |
||||
|
expression.Compile caller. The assembly isn't stripped. |
||||
|
--> |
||||
|
<type fullname="System.Linq.Expressions*"/> |
||||
|
</assembly> |
||||
|
<!-- |
||||
|
In this example, the app's entry point assembly is listed. The assembly |
||||
|
isn't stripped by the IL Linker. |
||||
|
--> |
||||
|
<assembly fullname="ControlCatalog" preserve="All" /> |
||||
|
</linker> |
||||
@ -0,0 +1,5 @@ |
|||||
|
@page "/" |
||||
|
|
||||
|
@using Avalonia.Web.Blazor |
||||
|
|
||||
|
<AvaloniaView /> |
||||
@ -0,0 +1,29 @@ |
|||||
|
using System; |
||||
|
using System.Net.Http; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using ControlCatalog.Web; |
||||
|
|
||||
|
public class Program |
||||
|
{ |
||||
|
public static async Task Main(string[] args) |
||||
|
{ |
||||
|
await CreateHostBuilder(args).Build().RunAsync(); |
||||
|
} |
||||
|
|
||||
|
public static WebAssemblyHostBuilder CreateHostBuilder(string[] args) |
||||
|
{ |
||||
|
var builder = WebAssemblyHostBuilder.CreateDefault(args); |
||||
|
|
||||
|
builder.RootComponents.Add<App>("#app"); |
||||
|
|
||||
|
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); |
||||
|
|
||||
|
return builder; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
@ -0,0 +1,30 @@ |
|||||
|
{ |
||||
|
"iisSettings": { |
||||
|
"windowsAuthentication": false, |
||||
|
"anonymousAuthentication": true, |
||||
|
"iisExpress": { |
||||
|
"applicationUrl": "http://localhost:13961", |
||||
|
"sslPort": 44319 |
||||
|
} |
||||
|
}, |
||||
|
"profiles": { |
||||
|
"ControlCatalog.Web - IIS Express": { |
||||
|
"commandName": "IISExpress", |
||||
|
"launchBrowser": true, |
||||
|
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", |
||||
|
"environmentVariables": { |
||||
|
"ASPNETCORE_ENVIRONMENT": "Development" |
||||
|
} |
||||
|
}, |
||||
|
"ControlCatalog.Web": { |
||||
|
"commandName": "Project", |
||||
|
"dotnetRunMessages": "true", |
||||
|
"launchBrowser": true, |
||||
|
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", |
||||
|
"applicationUrl": "https://localhost:5001;http://localhost:5000", |
||||
|
"environmentVariables": { |
||||
|
"ASPNETCORE_ENVIRONMENT": "Development" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
@inherits LayoutComponentBase |
||||
|
|
||||
|
<div class="page"> |
||||
|
<div class="main"> |
||||
|
@Body |
||||
|
</div> |
||||
|
</div> |
||||
@ -0,0 +1,70 @@ |
|||||
|
.page { |
||||
|
position: relative; |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
} |
||||
|
|
||||
|
.main { |
||||
|
flex: 1; |
||||
|
} |
||||
|
|
||||
|
.sidebar { |
||||
|
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); |
||||
|
} |
||||
|
|
||||
|
.top-row { |
||||
|
background-color: #f7f7f7; |
||||
|
border-bottom: 1px solid #d6d5d5; |
||||
|
justify-content: flex-end; |
||||
|
height: 3.5rem; |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
} |
||||
|
|
||||
|
.top-row ::deep a, .top-row .btn-link { |
||||
|
white-space: nowrap; |
||||
|
margin-left: 1.5rem; |
||||
|
} |
||||
|
|
||||
|
.top-row a:first-child { |
||||
|
overflow: hidden; |
||||
|
text-overflow: ellipsis; |
||||
|
} |
||||
|
|
||||
|
@media (max-width: 640.98px) { |
||||
|
.top-row:not(.auth) { |
||||
|
display: none; |
||||
|
} |
||||
|
|
||||
|
.top-row.auth { |
||||
|
justify-content: space-between; |
||||
|
} |
||||
|
|
||||
|
.top-row a, .top-row .btn-link { |
||||
|
margin-left: 0; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@media (min-width: 641px) { |
||||
|
.page { |
||||
|
flex-direction: row; |
||||
|
} |
||||
|
|
||||
|
.sidebar { |
||||
|
width: 250px; |
||||
|
height: 100vh; |
||||
|
position: sticky; |
||||
|
top: 0; |
||||
|
} |
||||
|
|
||||
|
.top-row { |
||||
|
position: sticky; |
||||
|
top: 0; |
||||
|
z-index: 1; |
||||
|
} |
||||
|
|
||||
|
.main > div { |
||||
|
padding-left: 2rem !important; |
||||
|
padding-right: 1.5rem !important; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
@using System.Net.Http |
||||
|
@using System.Net.Http.Json |
||||
|
@using Microsoft.AspNetCore.Components.Forms |
||||
|
@using Microsoft.AspNetCore.Components.Routing |
||||
|
@using Microsoft.AspNetCore.Components.Web |
||||
|
@using Microsoft.AspNetCore.Components.Web.Virtualization |
||||
|
@using Microsoft.AspNetCore.Components.WebAssembly.Http |
||||
|
@using Microsoft.JSInterop |
||||
|
@using ControlCatalog.Web |
||||
|
@using ControlCatalog.Web.Shared |
||||
|
@using SkiaSharp |
||||
@ -0,0 +1,90 @@ |
|||||
|
html, body { |
||||
|
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; |
||||
|
margin: 0; |
||||
|
height: 100vh; |
||||
|
overflow: hidden; |
||||
|
touch-action: none; |
||||
|
} |
||||
|
|
||||
|
a, .btn-link { |
||||
|
color: #0366d6; |
||||
|
} |
||||
|
|
||||
|
.btn-primary { |
||||
|
color: #fff; |
||||
|
background-color: #1b6ec2; |
||||
|
border-color: #1861ac; |
||||
|
} |
||||
|
|
||||
|
.content { |
||||
|
padding-top: 1.1rem; |
||||
|
} |
||||
|
|
||||
|
.valid.modified:not([type=checkbox]) { |
||||
|
outline: 1px solid #26b050; |
||||
|
} |
||||
|
|
||||
|
.invalid { |
||||
|
outline: 1px solid red; |
||||
|
} |
||||
|
|
||||
|
.validation-message { |
||||
|
color: red; |
||||
|
} |
||||
|
|
||||
|
#blazor-error-ui { |
||||
|
background: lightyellow; |
||||
|
bottom: 0; |
||||
|
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); |
||||
|
display: none; |
||||
|
left: 0; |
||||
|
padding: 0.6rem 1.25rem 0.7rem 1.25rem; |
||||
|
position: fixed; |
||||
|
width: 100%; |
||||
|
z-index: 1000; |
||||
|
} |
||||
|
|
||||
|
#blazor-error-ui .dismiss { |
||||
|
cursor: pointer; |
||||
|
position: absolute; |
||||
|
right: 0.75rem; |
||||
|
top: 0.5rem; |
||||
|
} |
||||
|
|
||||
|
.canvas-container { |
||||
|
opacity:1; |
||||
|
background-color:#ccc; |
||||
|
position:fixed; |
||||
|
width:100%; |
||||
|
height:100%; |
||||
|
top:0px; |
||||
|
left:0px; |
||||
|
z-index:500; |
||||
|
} |
||||
|
|
||||
|
canvas |
||||
|
{ |
||||
|
opacity:1; |
||||
|
background-color:#ccc; |
||||
|
position:fixed; |
||||
|
width:100%; |
||||
|
height:100%; |
||||
|
top:0px; |
||||
|
left:0px; |
||||
|
z-index:500; |
||||
|
} |
||||
|
|
||||
|
#app, .page { |
||||
|
height: 100%; |
||||
|
} |
||||
|
|
||||
|
.overlay{ |
||||
|
opacity:0.0; |
||||
|
background-color:#ccc; |
||||
|
position:fixed; |
||||
|
width:100vw; |
||||
|
height:100vh; |
||||
|
top:0px; |
||||
|
left:0px; |
||||
|
z-index:1000; |
||||
|
} |
||||
|
After Width: | Height: | Size: 172 KiB |
@ -0,0 +1,23 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html> |
||||
|
|
||||
|
<head> |
||||
|
<meta charset="utf-8" /> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> |
||||
|
<title>Avalonia Sample</title> |
||||
|
<base href="/" /> |
||||
|
<link href="css/app.css" rel="stylesheet" /> |
||||
|
</head> |
||||
|
|
||||
|
<body> |
||||
|
<div id="app">Powered by Avalonia</div> |
||||
|
|
||||
|
<div id="blazor-error-ui"> |
||||
|
An unhandled error has occurred. |
||||
|
<a href="" class="reload">Reload</a> |
||||
|
<a class="dismiss">🗙</a> |
||||
|
</div> |
||||
|
<script src="js/app.js"></script> |
||||
|
<script src="_framework/blazor.webassembly.js"></script> |
||||
|
</body> |
||||
|
</html> |
||||
@ -0,0 +1 @@ |
|||||
|
|
||||
@ -1,36 +0,0 @@ |
|||||
using System.Reflection; |
|
||||
using System.Runtime.CompilerServices; |
|
||||
using System.Runtime.InteropServices; |
|
||||
|
|
||||
// General Information about an assembly is controlled through the following
|
|
||||
// set of attributes. Change these attribute values to modify the information
|
|
||||
// associated with an assembly.
|
|
||||
[assembly: AssemblyTitle("WindowsInteropTest")] |
|
||||
[assembly: AssemblyDescription("")] |
|
||||
[assembly: AssemblyConfiguration("")] |
|
||||
[assembly: AssemblyCompany("")] |
|
||||
[assembly: AssemblyProduct("WindowsInteropTest")] |
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")] |
|
||||
[assembly: AssemblyTrademark("")] |
|
||||
[assembly: AssemblyCulture("")] |
|
||||
|
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
|
||||
// to COM components. If you need to access a type in this assembly from
|
|
||||
// COM, set the ComVisible attribute to true on that type.
|
|
||||
[assembly: ComVisible(false)] |
|
||||
|
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|
||||
[assembly: Guid("c7a69145-60b6-4882-97d6-a3921dd43978")] |
|
||||
|
|
||||
// Version information for an assembly consists of the following four values:
|
|
||||
//
|
|
||||
// Major Version
|
|
||||
// Minor Version
|
|
||||
// Build Number
|
|
||||
// Revision
|
|
||||
//
|
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
|
||||
// by using the '*' as shown below:
|
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
|
||||
[assembly: AssemblyVersion("1.0.0.0")] |
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")] |
|
||||
@ -1,189 +1,19 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
<Project Sdk="Microsoft.NET.Sdk"> |
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> |
|
||||
<PropertyGroup> |
<PropertyGroup> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|
||||
<ProjectGuid>{C7A69145-60B6-4882-97D6-A3921DD43978}</ProjectGuid> |
|
||||
<OutputType>WinExe</OutputType> |
<OutputType>WinExe</OutputType> |
||||
<AppDesignerFolder>Properties</AppDesignerFolder> |
<TargetFramework>net461</TargetFramework> |
||||
<RootNamespace>WindowsInteropTest</RootNamespace> |
|
||||
<AssemblyName>WindowsInteropTest</AssemblyName> |
<UseWPF>true</UseWPF> |
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> |
<UseWindowsForms>true</UseWindowsForms> |
||||
<FileAlignment>512</FileAlignment> |
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> |
|
||||
</PropertyGroup> |
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|
||||
<PlatformTarget>x86</PlatformTarget> |
|
||||
<DebugSymbols>true</DebugSymbols> |
|
||||
<DebugType>full</DebugType> |
|
||||
<Optimize>false</Optimize> |
|
||||
<OutputPath>bin\Debug\</OutputPath> |
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|
||||
<ErrorReport>prompt</ErrorReport> |
|
||||
<WarningLevel>4</WarningLevel> |
|
||||
</PropertyGroup> |
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
|
||||
<DebugType>pdbonly</DebugType> |
|
||||
<Optimize>true</Optimize> |
|
||||
<OutputPath>bin\Release\</OutputPath> |
|
||||
<DefineConstants>TRACE</DefineConstants> |
|
||||
<ErrorReport>prompt</ErrorReport> |
|
||||
<WarningLevel>4</WarningLevel> |
|
||||
</PropertyGroup> |
|
||||
<ItemGroup> |
|
||||
<Reference Include="PresentationCore" /> |
|
||||
<Reference Include="PresentationFramework" /> |
|
||||
<Reference Include="System" /> |
|
||||
<Reference Include="System.Core" /> |
|
||||
<Reference Include="System.Xaml" /> |
|
||||
<Reference Include="System.Xml.Linq" /> |
|
||||
<Reference Include="System.Data.DataSetExtensions" /> |
|
||||
<Reference Include="Microsoft.CSharp" /> |
|
||||
<Reference Include="System.Data" /> |
|
||||
<Reference Include="System.Deployment" /> |
|
||||
<Reference Include="System.Drawing" /> |
|
||||
<Reference Include="System.Net.Http" /> |
|
||||
<Reference Include="System.Windows.Forms" /> |
|
||||
<Reference Include="System.Xml" /> |
|
||||
<Reference Include="WindowsBase" /> |
|
||||
</ItemGroup> |
|
||||
<ItemGroup> |
|
||||
<Compile Include="EmbedToWinFormsDemo.cs"> |
|
||||
<SubType>Form</SubType> |
|
||||
</Compile> |
|
||||
<Compile Include="EmbedToWinFormsDemo.Designer.cs"> |
|
||||
<DependentUpon>EmbedToWinFormsDemo.cs</DependentUpon> |
|
||||
</Compile> |
|
||||
<Compile Include="EmbedToWpfDemo.xaml.cs"> |
|
||||
<DependentUpon>EmbedToWpfDemo.xaml</DependentUpon> |
|
||||
</Compile> |
|
||||
<Compile Include="SelectorForm.cs"> |
|
||||
<SubType>Form</SubType> |
|
||||
</Compile> |
|
||||
<Compile Include="SelectorForm.Designer.cs"> |
|
||||
<DependentUpon>SelectorForm.cs</DependentUpon> |
|
||||
</Compile> |
|
||||
<Compile Include="Program.cs" /> |
|
||||
<Compile Include="Properties\AssemblyInfo.cs" /> |
|
||||
<EmbeddedResource Include="EmbedToWinFormsDemo.resx"> |
|
||||
<DependentUpon>EmbedToWinFormsDemo.cs</DependentUpon> |
|
||||
</EmbeddedResource> |
|
||||
<EmbeddedResource Include="Properties\Resources.resx"> |
|
||||
<Generator>ResXFileCodeGenerator</Generator> |
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> |
|
||||
<SubType>Designer</SubType> |
|
||||
</EmbeddedResource> |
|
||||
<Compile Include="Properties\Resources.Designer.cs"> |
|
||||
<AutoGen>True</AutoGen> |
|
||||
<DependentUpon>Resources.resx</DependentUpon> |
|
||||
</Compile> |
|
||||
<EmbeddedResource Include="SelectorForm.resx"> |
|
||||
<DependentUpon>SelectorForm.cs</DependentUpon> |
|
||||
</EmbeddedResource> |
|
||||
<None Include="Properties\Settings.settings"> |
|
||||
<Generator>SettingsSingleFileGenerator</Generator> |
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput> |
|
||||
</None> |
|
||||
<Compile Include="Properties\Settings.Designer.cs"> |
|
||||
<AutoGen>True</AutoGen> |
|
||||
<DependentUpon>Settings.settings</DependentUpon> |
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput> |
|
||||
</Compile> |
|
||||
</ItemGroup> |
|
||||
<ItemGroup> |
|
||||
<None Include="App.config" /> |
|
||||
</ItemGroup> |
|
||||
<ItemGroup> |
<ItemGroup> |
||||
<ProjectReference Include="..\..\..\src\Avalonia.Animation\Avalonia.Animation.csproj"> |
<ProjectReference Include="..\..\..\src\Windows\Avalonia.Win32.Interop\Avalonia.Win32.Interop.csproj" /> |
||||
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project> |
|
||||
<Name>Avalonia.Animation</Name> |
|
||||
</ProjectReference> |
|
||||
<ProjectReference Include="..\..\..\src\Avalonia.Base\Avalonia.Base.csproj"> |
|
||||
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project> |
|
||||
<Name>Avalonia.Base</Name> |
|
||||
</ProjectReference> |
|
||||
<ProjectReference Include="..\..\..\src\Avalonia.Controls.DataGrid\Avalonia.Controls.DataGrid.csproj"> |
|
||||
<Project>{3278f3a9-9509-4a3f-a15b-bdc8b5bff632}</Project> |
|
||||
<Name>Avalonia.Controls.DataGrid</Name> |
|
||||
</ProjectReference> |
|
||||
<ProjectReference Include="..\..\..\src\Avalonia.Controls\Avalonia.Controls.csproj"> |
|
||||
<Project>{d2221c82-4a25-4583-9b43-d791e3f6820c}</Project> |
|
||||
<Name>Avalonia.Controls</Name> |
|
||||
</ProjectReference> |
|
||||
<ProjectReference Include="..\..\..\src\Avalonia.DesignerSupport\Avalonia.DesignerSupport.csproj"> |
|
||||
<Project>{799a7bb5-3c2c-48b6-85a7-406a12c420da}</Project> |
|
||||
<Name>Avalonia.DesignerSupport</Name> |
|
||||
</ProjectReference> |
|
||||
<ProjectReference Include="..\..\..\src\Avalonia.DesktopRuntime\Avalonia.DesktopRuntime.csproj"> |
|
||||
<Project>{878fefe0-cd14-41cb-90b0-dbcb163e8f15}</Project> |
|
||||
<Name>Avalonia.DesktopRuntime</Name> |
|
||||
</ProjectReference> |
|
||||
<ProjectReference Include="..\..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj"> |
|
||||
<Project>{7062ae20-5dcc-4442-9645-8195bdece63e}</Project> |
|
||||
<Name>Avalonia.Diagnostics</Name> |
|
||||
</ProjectReference> |
|
||||
<ProjectReference Include="..\..\..\src\Avalonia.Input\Avalonia.Input.csproj"> |
|
||||
<Project>{62024b2d-53eb-4638-b26b-85eeaa54866e}</Project> |
|
||||
<Name>Avalonia.Input</Name> |
|
||||
</ProjectReference> |
|
||||
<ProjectReference Include="..\..\..\src\Avalonia.Interactivity\Avalonia.Interactivity.csproj"> |
|
||||
<Project>{6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b}</Project> |
|
||||
<Name>Avalonia.Interactivity</Name> |
|
||||
</ProjectReference> |
|
||||
<ProjectReference Include="..\..\..\src\Avalonia.Layout\Avalonia.Layout.csproj"> |
|
||||
<Project>{42472427-4774-4c81-8aff-9f27b8e31721}</Project> |
|
||||
<Name>Avalonia.Layout</Name> |
|
||||
</ProjectReference> |
|
||||
<ProjectReference Include="..\..\..\src\Avalonia.Visuals\Avalonia.Visuals.csproj"> |
|
||||
<Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project> |
|
||||
<Name>Avalonia.Visuals</Name> |
|
||||
</ProjectReference> |
|
||||
<ProjectReference Include="..\..\..\src\Avalonia.Styling\Avalonia.Styling.csproj"> |
|
||||
<Project>{f1baa01a-f176-4c6a-b39d-5b40bb1b148f}</Project> |
|
||||
<Name>Avalonia.Styling</Name> |
|
||||
</ProjectReference> |
|
||||
<ProjectReference Include="..\..\..\src\Avalonia.Themes.Default\Avalonia.Themes.Default.csproj"> |
|
||||
<Project>{3e10a5fa-e8da-48b1-ad44-6a5b6cb7750f}</Project> |
|
||||
<Name>Avalonia.Themes.Default</Name> |
|
||||
</ProjectReference> |
|
||||
<ProjectReference Include="..\..\..\src\Markup\Avalonia.Markup.Xaml\Avalonia.Markup.Xaml.csproj"> |
|
||||
<Project>{3e53a01a-b331-47f3-b828-4a5717e77a24}</Project> |
|
||||
<Name>Avalonia.Markup.Xaml</Name> |
|
||||
</ProjectReference> |
|
||||
<ProjectReference Include="..\..\..\src\Markup\Avalonia.Markup\Avalonia.Markup.csproj"> |
|
||||
<Project>{6417e941-21bc-467b-a771-0de389353ce6}</Project> |
|
||||
<Name>Avalonia.Markup</Name> |
|
||||
</ProjectReference> |
|
||||
<ProjectReference Include="..\..\..\src\Skia\Avalonia.Skia\Avalonia.Skia.csproj"> |
|
||||
<Project>{7d2d3083-71dd-4cc9-8907-39a0d86fb322}</Project> |
|
||||
<Name>Avalonia.Skia</Name> |
|
||||
</ProjectReference> |
|
||||
<ProjectReference Include="..\..\..\src\Windows\Avalonia.Direct2D1\Avalonia.Direct2D1.csproj"> |
|
||||
<Project>{3e908f67-5543-4879-a1dc-08eace79b3cd}</Project> |
|
||||
<Name>Avalonia.Direct2D1</Name> |
|
||||
</ProjectReference> |
|
||||
<ProjectReference Include="..\..\..\src\Windows\Avalonia.Win32.Interop\Avalonia.Win32.Interop.csproj"> |
|
||||
<Project>{cbc4ff2f-92d4-420b-be21-9fe0b930b04e}</Project> |
|
||||
<Name>Avalonia.Win32.Interop</Name> |
|
||||
</ProjectReference> |
|
||||
<ProjectReference Include="..\..\..\src\Windows\Avalonia.Win32\Avalonia.Win32.csproj"> |
|
||||
<Project>{811a76cf-1cf6-440f-963b-bbe31bd72a82}</Project> |
|
||||
<Name>Avalonia.Win32</Name> |
|
||||
</ProjectReference> |
|
||||
<ProjectReference Include="..\..\ControlCatalog\ControlCatalog.csproj"> |
<ProjectReference Include="..\..\ControlCatalog\ControlCatalog.csproj"> |
||||
<Project>{d0a739b9-3c68-4ba6-a328-41606954b6bd}</Project> |
<Project>{d0a739b9-3c68-4ba6-a328-41606954b6bd}</Project> |
||||
<Name>ControlCatalog</Name> |
<Name>ControlCatalog</Name> |
||||
</ProjectReference> |
</ProjectReference> |
||||
</ItemGroup> |
</ItemGroup> |
||||
<ItemGroup> |
|
||||
<Page Include="EmbedToWpfDemo.xaml"> |
|
||||
<SubType>Designer</SubType> |
|
||||
<Generator>MSBuild:Compile</Generator> |
|
||||
</Page> |
|
||||
</ItemGroup> |
|
||||
<Import Project="..\..\..\build\Rx.props" /> |
<Import Project="..\..\..\build\Rx.props" /> |
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
|
||||
<Import Project="..\..\..\build\LegacyProject.targets" /> |
|
||||
</Project> |
</Project> |
||||
|
|||||
@ -1,6 +1,5 @@ |
|||||
Compat issues with assembly Avalonia.Animation: |
Compat issues with assembly Avalonia.Animation: |
||||
MembersMustExist : Member 'public System.Threading.Tasks.Task Avalonia.Animation.Animation.RunAsync(Avalonia.Animation.Animatable, Avalonia.Animation.IClock)' does not exist in the implementation but it does exist in the contract. |
|
||||
InterfacesShouldHaveSameMembers : Interface member 'public System.Threading.Tasks.Task Avalonia.Animation.IAnimation.RunAsync(Avalonia.Animation.Animatable, Avalonia.Animation.IClock)' is present in the contract but not in the implementation. |
InterfacesShouldHaveSameMembers : Interface member 'public System.Threading.Tasks.Task Avalonia.Animation.IAnimation.RunAsync(Avalonia.Animation.Animatable, Avalonia.Animation.IClock)' is present in the contract but not in the implementation. |
||||
MembersMustExist : Member 'public System.Threading.Tasks.Task Avalonia.Animation.IAnimation.RunAsync(Avalonia.Animation.Animatable, Avalonia.Animation.IClock)' does not exist in the implementation but it does exist in the contract. |
MembersMustExist : Member 'public System.Threading.Tasks.Task Avalonia.Animation.IAnimation.RunAsync(Avalonia.Animation.Animatable, Avalonia.Animation.IClock)' does not exist in the implementation but it does exist in the contract. |
||||
InterfacesShouldHaveSameMembers : Interface member 'public System.Threading.Tasks.Task Avalonia.Animation.IAnimation.RunAsync(Avalonia.Animation.Animatable, Avalonia.Animation.IClock, System.Threading.CancellationToken)' is present in the implementation but not in the contract. |
InterfacesShouldHaveSameMembers : Interface member 'public System.Threading.Tasks.Task Avalonia.Animation.IAnimation.RunAsync(Avalonia.Animation.Animatable, Avalonia.Animation.IClock, System.Threading.CancellationToken)' is present in the implementation but not in the contract. |
||||
Total Issues: 4 |
Total Issues: 3 |
||||
|
|||||
@ -0,0 +1,60 @@ |
|||||
|
using System; |
||||
|
using System.Runtime.InteropServices; |
||||
|
|
||||
|
namespace Avalonia.X11 |
||||
|
{ |
||||
|
internal static class ICELib |
||||
|
{ |
||||
|
private const string LibIce = "libICE.so.6"; |
||||
|
|
||||
|
[DllImport(LibIce, CallingConvention = CallingConvention.StdCall)] |
||||
|
public static extern int IceAddConnectionWatch( |
||||
|
IntPtr watchProc, |
||||
|
IntPtr clientData |
||||
|
); |
||||
|
|
||||
|
[DllImport(LibIce, CallingConvention = CallingConvention.StdCall)] |
||||
|
public static extern void IceRemoveConnectionWatch( |
||||
|
IntPtr watchProc, |
||||
|
IntPtr clientData |
||||
|
); |
||||
|
|
||||
|
[DllImport(LibIce, CallingConvention = CallingConvention.StdCall)] |
||||
|
public static extern IceProcessMessagesStatus IceProcessMessages( |
||||
|
IntPtr iceConn, |
||||
|
out IntPtr replyWait, |
||||
|
out bool replyReadyRet |
||||
|
); |
||||
|
|
||||
|
[DllImport(LibIce, CallingConvention = CallingConvention.StdCall)] |
||||
|
public static extern IntPtr IceSetErrorHandler( |
||||
|
IntPtr handler |
||||
|
); |
||||
|
|
||||
|
[DllImport(LibIce, CallingConvention = CallingConvention.StdCall)] |
||||
|
public static extern IntPtr IceSetIOErrorHandler( |
||||
|
IntPtr handler |
||||
|
); |
||||
|
|
||||
|
public enum IceProcessMessagesStatus |
||||
|
{ |
||||
|
IceProcessMessagesIoError = 1 |
||||
|
} |
||||
|
|
||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
||||
|
public delegate void IceErrorHandler( |
||||
|
IntPtr iceConn, |
||||
|
bool swap, |
||||
|
int offendingMinorOpcode, |
||||
|
ulong offendingSequence, |
||||
|
int errorClass, |
||||
|
int severity, |
||||
|
IntPtr values |
||||
|
); |
||||
|
|
||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
||||
|
public delegate void IceIOErrorHandler( |
||||
|
IntPtr iceConn |
||||
|
); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,133 @@ |
|||||
|
using System; |
||||
|
using System.Runtime.InteropServices; |
||||
|
|
||||
|
namespace Avalonia.X11 |
||||
|
{ |
||||
|
internal static unsafe class SMLib |
||||
|
{ |
||||
|
private const string LibSm = "libSM.so.6"; |
||||
|
|
||||
|
[DllImport(LibSm, CharSet = CharSet.Ansi)] |
||||
|
public static extern IntPtr SmcOpenConnection( |
||||
|
[MarshalAs(UnmanagedType.LPWStr)] string networkId, |
||||
|
IntPtr content, |
||||
|
int xsmpMajorRev, |
||||
|
int xsmpMinorRev, |
||||
|
ulong mask, |
||||
|
ref SmcCallbacks callbacks, |
||||
|
[MarshalAs(UnmanagedType.LPWStr)] [Out] |
||||
|
out string previousId, |
||||
|
[MarshalAs(UnmanagedType.LPWStr)] [Out] |
||||
|
out string clientIdRet, |
||||
|
int errorLength, |
||||
|
[Out] char[] errorStringRet); |
||||
|
|
||||
|
[DllImport(LibSm, CallingConvention = CallingConvention.StdCall)] |
||||
|
public static extern int SmcCloseConnection( |
||||
|
IntPtr smcConn, |
||||
|
int count, |
||||
|
string[] reasonMsgs |
||||
|
); |
||||
|
|
||||
|
[DllImport(LibSm, CallingConvention = CallingConvention.StdCall)] |
||||
|
public static extern void SmcSaveYourselfDone( |
||||
|
IntPtr smcConn, |
||||
|
bool success |
||||
|
); |
||||
|
|
||||
|
[DllImport(LibSm, CallingConvention = CallingConvention.StdCall)] |
||||
|
public static extern int SmcInteractRequest( |
||||
|
IntPtr smcConn, |
||||
|
SmDialogValue dialogType, |
||||
|
IntPtr interactProc, |
||||
|
IntPtr clientData |
||||
|
); |
||||
|
|
||||
|
[DllImport(LibSm, CallingConvention = CallingConvention.StdCall)] |
||||
|
public static extern void SmcInteractDone( |
||||
|
IntPtr smcConn, |
||||
|
bool success |
||||
|
); |
||||
|
|
||||
|
[DllImport(LibSm, CallingConvention = CallingConvention.StdCall)] |
||||
|
public static extern IntPtr SmcGetIceConnection( |
||||
|
IntPtr smcConn |
||||
|
); |
||||
|
|
||||
|
[DllImport(LibSm, CallingConvention = CallingConvention.StdCall)] |
||||
|
public static extern IntPtr SmcSetErrorHandler( |
||||
|
IntPtr handler |
||||
|
); |
||||
|
|
||||
|
public enum SmDialogValue |
||||
|
{ |
||||
|
SmDialogError = 0 |
||||
|
} |
||||
|
|
||||
|
[StructLayout(LayoutKind.Sequential)] |
||||
|
public struct SmcCallbacks |
||||
|
{ |
||||
|
public IntPtr SaveYourself; |
||||
|
private readonly IntPtr Unused0; |
||||
|
public IntPtr Die; |
||||
|
private readonly IntPtr Unused1; |
||||
|
public IntPtr SaveComplete; |
||||
|
private readonly IntPtr Unused2; |
||||
|
public IntPtr ShutdownCancelled; |
||||
|
private readonly IntPtr Unused3; |
||||
|
} |
||||
|
|
||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
||||
|
public delegate void IceWatchProc( |
||||
|
IntPtr iceConn, |
||||
|
IntPtr clientData, |
||||
|
bool opening, |
||||
|
IntPtr* watchData |
||||
|
); |
||||
|
|
||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
||||
|
public delegate void SmcDieProc( |
||||
|
IntPtr smcConn, |
||||
|
IntPtr clientData |
||||
|
); |
||||
|
|
||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
||||
|
public delegate void SmcInteractProc( |
||||
|
IntPtr smcConn, |
||||
|
IntPtr clientData |
||||
|
); |
||||
|
|
||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
||||
|
public delegate void SmcSaveCompleteProc( |
||||
|
IntPtr smcConn, |
||||
|
IntPtr clientData |
||||
|
); |
||||
|
|
||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
||||
|
public delegate void SmcSaveYourselfProc( |
||||
|
IntPtr smcConn, |
||||
|
IntPtr clientData, |
||||
|
int saveType, |
||||
|
bool shutdown, |
||||
|
int interactStyle, |
||||
|
bool fast |
||||
|
); |
||||
|
|
||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
||||
|
public delegate void SmcShutdownCancelledProc( |
||||
|
IntPtr smcConn, |
||||
|
IntPtr clientData |
||||
|
); |
||||
|
|
||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
||||
|
public delegate void SmcErrorHandler( |
||||
|
IntPtr smcConn, |
||||
|
bool swap, |
||||
|
int offendingMinorOpcode, |
||||
|
ulong offendingSequence, |
||||
|
int errorClass, |
||||
|
int severity, |
||||
|
IntPtr values |
||||
|
); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,259 @@ |
|||||
|
#nullable enable |
||||
|
using System; |
||||
|
using System.Collections.Concurrent; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using Avalonia.Controls.ApplicationLifetimes; |
||||
|
using Avalonia.Logging; |
||||
|
using Avalonia.Platform; |
||||
|
using Avalonia.Threading; |
||||
|
|
||||
|
namespace Avalonia.X11 |
||||
|
{ |
||||
|
internal unsafe class X11PlatformLifetimeEvents : IDisposable, IPlatformLifetimeEventsImpl |
||||
|
{ |
||||
|
private readonly AvaloniaX11Platform _platform; |
||||
|
private const ulong SmcSaveYourselfProcMask = 1L; |
||||
|
private const ulong SmcDieProcMask = 2L; |
||||
|
private const ulong SmcSaveCompleteProcMask = 4L; |
||||
|
private const ulong SmcShutdownCancelledProcMask = 8L; |
||||
|
|
||||
|
private static readonly ConcurrentDictionary<IntPtr, X11PlatformLifetimeEvents> s_nativeToManagedMapper = |
||||
|
new ConcurrentDictionary<IntPtr, X11PlatformLifetimeEvents>(); |
||||
|
|
||||
|
private static readonly SMLib.SmcSaveYourselfProc s_saveYourselfProcDelegate = SmcSaveYourselfHandler; |
||||
|
private static readonly SMLib.SmcDieProc s_dieDelegate = SmcDieHandler; |
||||
|
|
||||
|
private static readonly SMLib.SmcShutdownCancelledProc |
||||
|
s_shutdownCancelledDelegate = SmcShutdownCancelledHandler; |
||||
|
|
||||
|
private static readonly SMLib.SmcSaveCompleteProc s_saveCompleteDelegate = SmcSaveCompleteHandler; |
||||
|
private static readonly SMLib.SmcInteractProc s_smcInteractDelegate = StaticInteractHandler; |
||||
|
private static readonly SMLib.SmcErrorHandler s_smcErrorHandlerDelegate = StaticErrorHandler; |
||||
|
private static readonly ICELib.IceErrorHandler s_iceErrorHandlerDelegate = StaticErrorHandler; |
||||
|
private static readonly ICELib.IceIOErrorHandler s_iceIoErrorHandlerDelegate = StaticIceIOErrorHandler; |
||||
|
private static readonly SMLib.IceWatchProc s_iceWatchProcDelegate = IceWatchHandler; |
||||
|
|
||||
|
private static SMLib.SmcCallbacks s_callbacks = new SMLib.SmcCallbacks() |
||||
|
{ |
||||
|
ShutdownCancelled = Marshal.GetFunctionPointerForDelegate(s_shutdownCancelledDelegate), |
||||
|
Die = Marshal.GetFunctionPointerForDelegate(s_dieDelegate), |
||||
|
SaveYourself = Marshal.GetFunctionPointerForDelegate(s_saveYourselfProcDelegate), |
||||
|
SaveComplete = Marshal.GetFunctionPointerForDelegate(s_saveCompleteDelegate) |
||||
|
}; |
||||
|
|
||||
|
private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource(); |
||||
|
private readonly IntPtr _currentIceConn; |
||||
|
private readonly IntPtr _currentSmcConn; |
||||
|
|
||||
|
private bool _saveYourselfPhase; |
||||
|
|
||||
|
internal X11PlatformLifetimeEvents(AvaloniaX11Platform platform) |
||||
|
{ |
||||
|
_platform = platform; |
||||
|
|
||||
|
if (ICELib.IceAddConnectionWatch( |
||||
|
Marshal.GetFunctionPointerForDelegate(s_iceWatchProcDelegate), |
||||
|
IntPtr.Zero) == 0) |
||||
|
{ |
||||
|
Logger.TryGet(LogEventLevel.Warning, LogArea.X11Platform)?.Log(this, |
||||
|
"SMLib was unable to add an ICE connection watcher."); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
var errorBuf = new char[255]; |
||||
|
|
||||
|
var smcConn = SMLib.SmcOpenConnection(null!, |
||||
|
IntPtr.Zero, 1, 0, |
||||
|
SmcSaveYourselfProcMask | |
||||
|
SmcSaveCompleteProcMask | |
||||
|
SmcShutdownCancelledProcMask | |
||||
|
SmcDieProcMask, |
||||
|
ref s_callbacks, |
||||
|
out _, |
||||
|
out _, |
||||
|
errorBuf.Length, |
||||
|
errorBuf); |
||||
|
|
||||
|
if (smcConn == IntPtr.Zero) |
||||
|
{ |
||||
|
Logger.TryGet(LogEventLevel.Warning, LogArea.X11Platform)?.Log(this, |
||||
|
$"SMLib/ICELib reported a new error: {new string(errorBuf)}"); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if (!s_nativeToManagedMapper.TryAdd(smcConn, this)) |
||||
|
{ |
||||
|
Logger.TryGet(LogEventLevel.Warning, LogArea.X11Platform)?.Log(this, |
||||
|
"SMLib was unable to add this instance to the native to managed map."); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
_ = SMLib.SmcSetErrorHandler(Marshal.GetFunctionPointerForDelegate(s_smcErrorHandlerDelegate)); |
||||
|
_ = ICELib.IceSetErrorHandler(Marshal.GetFunctionPointerForDelegate(s_iceErrorHandlerDelegate)); |
||||
|
_ = ICELib.IceSetIOErrorHandler(Marshal.GetFunctionPointerForDelegate(s_iceIoErrorHandlerDelegate)); |
||||
|
|
||||
|
_currentSmcConn = smcConn; |
||||
|
_currentIceConn = SMLib.SmcGetIceConnection(smcConn); |
||||
|
|
||||
|
Task.Run(() => |
||||
|
{ |
||||
|
var token = _cancellationTokenSource.Token; |
||||
|
while (!token.IsCancellationRequested) HandleRequests(); |
||||
|
}, _cancellationTokenSource.Token); |
||||
|
} |
||||
|
|
||||
|
public void Dispose() |
||||
|
{ |
||||
|
if (_currentSmcConn == IntPtr.Zero) return; |
||||
|
|
||||
|
s_nativeToManagedMapper.TryRemove(_currentSmcConn, out _); |
||||
|
|
||||
|
_ = SMLib.SmcCloseConnection(_currentSmcConn, 1, |
||||
|
new[] { $"{nameof(X11PlatformLifetimeEvents)} was disposed in managed code." }); |
||||
|
} |
||||
|
|
||||
|
private static void SmcSaveCompleteHandler(IntPtr smcConn, IntPtr clientData) |
||||
|
{ |
||||
|
GetInstance(smcConn)?.SaveCompleteHandler(); |
||||
|
} |
||||
|
|
||||
|
private static X11PlatformLifetimeEvents? GetInstance(IntPtr smcConn) |
||||
|
{ |
||||
|
return s_nativeToManagedMapper.TryGetValue(smcConn, out var instance) ? instance : null; |
||||
|
} |
||||
|
|
||||
|
private static void SmcShutdownCancelledHandler(IntPtr smcConn, IntPtr clientData) |
||||
|
{ |
||||
|
GetInstance(smcConn)?.ShutdownCancelledHandler(); |
||||
|
} |
||||
|
|
||||
|
private static void SmcDieHandler(IntPtr smcConn, IntPtr clientData) |
||||
|
{ |
||||
|
GetInstance(smcConn)?.DieHandler(); |
||||
|
} |
||||
|
|
||||
|
private static void SmcSaveYourselfHandler(IntPtr smcConn, IntPtr clientData, int saveType, |
||||
|
bool shutdown, int interactStyle, bool fast) |
||||
|
{ |
||||
|
GetInstance(smcConn)?.SaveYourselfHandler(smcConn, clientData, shutdown, fast); |
||||
|
} |
||||
|
|
||||
|
private static void StaticInteractHandler(IntPtr smcConn, IntPtr clientData) |
||||
|
{ |
||||
|
GetInstance(smcConn)?.InteractHandler(smcConn); |
||||
|
} |
||||
|
|
||||
|
private static void StaticIceIOErrorHandler(IntPtr iceConn) |
||||
|
{ |
||||
|
Logger.TryGet(LogEventLevel.Warning, LogArea.X11Platform)?.Log(null, |
||||
|
"ICELib reported an unknown IO Error."); |
||||
|
} |
||||
|
|
||||
|
private static void StaticErrorHandler(IntPtr smcConn, bool swap, int offendingMinorOpcode, |
||||
|
ulong offendingSequence, int errorClass, int severity, IntPtr values) |
||||
|
{ |
||||
|
GetInstance(smcConn) |
||||
|
?.ErrorHandler(swap, offendingMinorOpcode, offendingSequence, errorClass, severity, values); |
||||
|
} |
||||
|
|
||||
|
// ReSharper disable UnusedParameter.Local
|
||||
|
private void ErrorHandler(bool swap, int offendingMinorOpcode, ulong offendingSequence, int errorClass, |
||||
|
int severity, IntPtr values) |
||||
|
{ |
||||
|
Logger.TryGet(LogEventLevel.Warning, LogArea.X11Platform)?.Log(this, |
||||
|
"SMLib reported an error:" + |
||||
|
$" severity {severity:X}" + |
||||
|
$" mOpcode {offendingMinorOpcode:X}" + |
||||
|
$" mSeq {offendingSequence:X}" + |
||||
|
$" errClass {errorClass:X}."); |
||||
|
} |
||||
|
|
||||
|
private void HandleRequests() |
||||
|
{ |
||||
|
if (ICELib.IceProcessMessages(_currentIceConn, out _, out _) == |
||||
|
ICELib.IceProcessMessagesStatus.IceProcessMessagesIoError) |
||||
|
{ |
||||
|
Logger.TryGet(LogEventLevel.Warning, LogArea.X11Platform)?.Log(this, |
||||
|
"SMLib lost its underlying ICE connection."); |
||||
|
Dispose(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void SaveCompleteHandler() |
||||
|
{ |
||||
|
_saveYourselfPhase = false; |
||||
|
} |
||||
|
|
||||
|
private void ShutdownCancelledHandler() |
||||
|
{ |
||||
|
if (_saveYourselfPhase) |
||||
|
SMLib.SmcSaveYourselfDone(_currentSmcConn, true); |
||||
|
_saveYourselfPhase = false; |
||||
|
} |
||||
|
|
||||
|
private void DieHandler() |
||||
|
{ |
||||
|
Dispose(); |
||||
|
} |
||||
|
|
||||
|
private void SaveYourselfHandler(IntPtr smcConn, IntPtr clientData, bool shutdown, bool fast) |
||||
|
{ |
||||
|
if (_saveYourselfPhase) |
||||
|
{ |
||||
|
SMLib.SmcSaveYourselfDone(smcConn, true); |
||||
|
} |
||||
|
|
||||
|
_saveYourselfPhase = true; |
||||
|
|
||||
|
if (shutdown && !fast) |
||||
|
{ |
||||
|
var _ = SMLib.SmcInteractRequest(smcConn, SMLib.SmDialogValue.SmDialogError, |
||||
|
Marshal.GetFunctionPointerForDelegate(s_smcInteractDelegate), |
||||
|
clientData); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
SMLib.SmcSaveYourselfDone(smcConn, true); |
||||
|
_saveYourselfPhase = false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void InteractHandler(IntPtr smcConn) |
||||
|
{ |
||||
|
Dispatcher.UIThread.Post(() => ActualInteractHandler(smcConn)); |
||||
|
} |
||||
|
|
||||
|
private void ActualInteractHandler(IntPtr smcConn) |
||||
|
{ |
||||
|
var e = new ShutdownRequestedEventArgs(); |
||||
|
|
||||
|
if (_platform.Options?.EnableSessionManagement ?? false) |
||||
|
{ |
||||
|
ShutdownRequested?.Invoke(this, e); |
||||
|
} |
||||
|
|
||||
|
SMLib.SmcInteractDone(smcConn, e.Cancel); |
||||
|
|
||||
|
if (e.Cancel) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
_saveYourselfPhase = false; |
||||
|
|
||||
|
SMLib.SmcSaveYourselfDone(smcConn, true); |
||||
|
} |
||||
|
|
||||
|
private static void IceWatchHandler(IntPtr iceConn, IntPtr clientData, bool opening, IntPtr* watchData) |
||||
|
{ |
||||
|
if (!opening) return; |
||||
|
|
||||
|
ICELib.IceRemoveConnectionWatch(Marshal.GetFunctionPointerForDelegate(s_iceWatchProcDelegate), |
||||
|
IntPtr.Zero); |
||||
|
} |
||||
|
|
||||
|
public event EventHandler<ShutdownRequestedEventArgs>? ShutdownRequested; |
||||
|
} |
||||
|
} |
||||
Binary file not shown.
Binary file not shown.
@ -0,0 +1,57 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>net6.0</TargetFramework> |
||||
|
<Nullable>enable</Nullable> |
||||
|
<ImplicitUsings>enable</ImplicitUsings> |
||||
|
<PackageId>Avalonia.Web.Blazor</PackageId> |
||||
|
<LangVersion>preview</LangVersion> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<SupportedPlatform Include="browser" /> |
||||
|
<Compile Include="..\..\Shared\PlatformSupport\AssetLoader.cs" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TypescriptOutDir>wwwroot</TypescriptOutDir> |
||||
|
<TypeScriptNoEmitOnError>true</TypeScriptNoEmitOnError> |
||||
|
<TypeScriptNoImplicitReturns>true</TypeScriptNoImplicitReturns> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<PropertyGroup Condition="'$(Configuration)' == 'Debug'"> |
||||
|
<TypeScriptRemoveComments>false</TypeScriptRemoveComments> |
||||
|
<TypeScriptSourceMap>true</TypeScriptSourceMap> |
||||
|
</PropertyGroup> |
||||
|
<PropertyGroup Condition="'$(Configuration)' == 'Release'"> |
||||
|
<TypeScriptRemoveComments>true</TypeScriptRemoveComments> |
||||
|
<TypeScriptSourceMap>false</TypeScriptSourceMap> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<Import Project="..\..\..\build\BuildTargets.targets" /> |
||||
|
<Import Project="..\..\..\build\SkiaSharp.props" /> |
||||
|
<Import Project="..\..\..\build\HarfBuzzSharp.props" /> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<AvaloniaResource Include="Assets\*" /> |
||||
|
<Content Include="*.props"> |
||||
|
<Pack>true</Pack> |
||||
|
<PackagePath>build\;buildTransitive\</PackagePath> |
||||
|
</Content> |
||||
|
<Content Include="*.targets"> |
||||
|
<Pack>true</Pack> |
||||
|
<PackagePath>build\;buildTransitive\</PackagePath> |
||||
|
</Content> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.0" /> |
||||
|
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="4.5.2" PrivateAssets="all" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\Avalonia.Base\Avalonia.Base.csproj" /> |
||||
|
<ProjectReference Include="..\..\Avalonia.Controls\Avalonia.Controls.csproj" /> |
||||
|
<ProjectReference Include="..\..\Skia\Avalonia.Skia\Avalonia.Skia.csproj" /> |
||||
|
</ItemGroup> |
||||
|
</Project> |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue