This commit is contained in:
Wiesław Šoltés 2022-11-08 23:17:37 +01:00
Родитель 898ba4fef7
Коммит 982284914d
27 изменённых файлов: 193 добавлений и 367 удалений

6
Directory.Build.props Normal file
Просмотреть файл

@ -0,0 +1,6 @@
<Project>
<PropertyGroup>
<AvaloniaVersion>11.0.0-preview3</AvaloniaVersion>
<SkiaSharpVersion>2.88.3</SkiaSharpVersion>
</PropertyGroup>
</Project>

Просмотреть файл

@ -11,6 +11,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Draw2D.Desktop", "src\Draw2
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Draw2D.Web", "src\Draw2D.Web\Draw2D.Web.csproj", "{FC8438E9-9BB6-4848-B779-B843C11A913F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{C922FAAF-29A5-4BBC-BA4A-F0D5DD218049}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
global.json = global.json
NuGet.Config = NuGet.Config
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU

Просмотреть файл

@ -2,12 +2,11 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<IsPackable>False</IsPackable>
<LangVersion>latest</LangVersion>
<Nullable>disable</Nullable>
<RootNamespace>Draw2D.Desktop</RootNamespace>
<AvaloniaVersion>11.0.0-preview3</AvaloniaVersion>
</PropertyGroup>
<ItemGroup>
@ -17,6 +16,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="$(SkiaSharpVersion)" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -1,10 +0,0 @@
<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>

Просмотреть файл

@ -1,14 +0,0 @@
using Avalonia.Web.Blazor;
namespace Draw2D.Web;
public partial class App
{
protected override void OnParametersSet()
{
base.OnParametersSet();
WebAppBuilder.Configure<Draw2D.App>()
.SetupWithSingleViewLifetime();
}
}

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 1.2 KiB

После

Ширина:  |  Высота:  |  Размер: 1.2 KiB

Просмотреть файл

@ -0,0 +1,64 @@
.highlight {
color: white;
font-size: 2.5rem;
display: block;
}
.purple {
color: #8b44ac;
}
.icon {
opacity : 0.05;
height: 35%;
width: 35%;
position : absolute;
background-repeat: no-repeat;
right: 0px;
bottom: 0px;
margin-right: 3%;
margin-bottom: 5%;
z-index: 5000;
background-position: right bottom;
pointer-events: none;
}
#avalonia-splash a{
color: whitesmoke;
text-decoration: none;
}
.center {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
#avalonia-splash {
position: relative;
height: 100%;
width: 100%;
color: whitesmoke;
background: #1b2a4e;
font-family: 'Nunito', sans-serif;
background-position: center;
background-size: cover;
background-repeat: no-repeat;
justify-content: center;
align-items: center;
}
.splash-close {
animation: fadeout 0.25s linear forwards;
}
@keyframes fadeout {
0% {
opacity:100%;
}
100% {
opacity:0;
visibility: collapse;
}
}

Двоичные данные
src/Draw2D.Web/AppBundle/favicon.ico Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 399 B

Просмотреть файл

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<title>Draw2D</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<base href="/" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@200;300;400;500;600;700&family=Open+Sans:wght@600&display=swap" rel="stylesheet">
<link rel="modulepreload" href="./main.js" />
<link rel="modulepreload" href="./dotnet.js" />
<link rel="modulepreload" href="./avalonia.js" />
<link rel="stylesheet" href="./app.css" />
<link rel="preconnect" href="https://fonts.googleapis.com">
</head>
<body style="margin: 0px">
<div id="out">
<div id="avalonia-splash">
<div class="center">
<h2 class="purple">
Powered by
<a class="highlight" href="https://www.avaloniaui.net/" target="_blank">Avalonia UI</a></h2>
</div>
</div>
</div>
<script type='module' src="./main.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,16 @@
import { dotnet } from './dotnet.js'
import { registerAvaloniaModule } from './avalonia.js';
const is_browser = typeof window != "undefined";
if (!is_browser) throw new Error(`Expected to be running in a browser`);
const dotnetRuntime = await dotnet
.withDiagnosticTracing(false)
.withApplicationArgumentsFromQuery()
.create();
await registerAvaloniaModule(dotnetRuntime);
const config = dotnetRuntime.getConfig();
await dotnetRuntime.runMainAndExit(config.mainAssemblyName, [window.location.search]);

Просмотреть файл

@ -0,0 +1,10 @@
{
"routes": [
{
"route": "/*",
"headers": {
"Cache-Control": "public, must-revalidate, max-age=2419200"
}
}
]
}

Просмотреть файл

@ -1,64 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
<WasmMainJSPath>AppBundle\main.js</WasmMainJSPath>
<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<MSBuildEnableWorkloadResolver>true</MSBuildEnableWorkloadResolver>
<IsPackable>False</IsPackable>
<Nullable>enable</Nullable>
<RootNamespace>Draw2D.Web</RootNamespace>
<EmccTotalMemory>16777216</EmccTotalMemory>
<BlazorEnableTimeZoneSupport>false</BlazorEnableTimeZoneSupport>
<BlazorWebAssemblyPreserveCollationData>false</BlazorWebAssemblyPreserveCollationData>
<AvaloniaVersion>11.0.0-preview3</AvaloniaVersion>
</PropertyGroup>
<!-- In debug, make builds faster by reducing optimizations -->
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<WasmNativeStrip>false</WasmNativeStrip>
<EmccCompileOptimizationFlag>-O1</EmccCompileOptimizationFlag>
<RunAOTCompilation>false</RunAOTCompilation>
<Optimize>true</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<Optimize>true</Optimize>
<WasmNativeStrip>true</WasmNativeStrip>
<EmccCompileOptimizationFlag>-O3</EmccCompileOptimizationFlag>
<EmccLinkOptimizationFlag>-O3</EmccLinkOptimizationFlag>
<RunAOTCompilation>false</RunAOTCompilation>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebuggerSupport>false</DebuggerSupport>
<EnableUnsafeBinaryFormatterSerialization>false</EnableUnsafeBinaryFormatterSerialization>
<EnableUnsafeUTF7Encoding>false</EnableUnsafeUTF7Encoding>
<EventSourceSupport>false</EventSourceSupport>
<HttpActivityPropagationSupport>false</HttpActivityPropagationSupport>
<InvariantGlobalization>true</InvariantGlobalization>
<MetadataUpdaterSupport>false</MetadataUpdaterSupport>
<UseNativeHttpHandler>true</UseNativeHttpHandler>
<UseSystemResourceKeys>true</UseSystemResourceKeys>
<PublishTrimmed>true</PublishTrimmed>
<TrimMode>link</TrimMode>
<TrimmerRemoveSymbols>true</TrimmerRemoveSymbols>
</PropertyGroup>
<ItemGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<BlazorLinkerDescriptor Include="LinkerConfig.xml" />
<TrimmableAssembly Include="Microsoft.CodeAnalysis" />
<TrimmableAssembly Include="Microsoft.CodeAnalysis.CSharp" />
<TrimmableAssembly Include="Microsoft.CodeAnalysis.CSharp.Scripting" />
<TrimmableAssembly Include="Microsoft.CodeAnalysis.Scripting" />
<!--<TrimmableAssembly Include="Avalonia.Controls.DataGrid" />-->
<TrimmableAssembly Include="Avalonia.Themes.Default" />
</ItemGroup>
<PropertyGroup>
<BlazorEnableCompression>true</BlazorEnableCompression>
</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" />
<PackageReference Include="Avalonia.Web.Blazor" Version="$(AvaloniaVersion)" />
<TrimmerRootDescriptor Include="Roots.xml" />
</ItemGroup>
<ItemGroup>
<WasmExtraFilesToDeploy Include="AppBundle\app.css" />
<WasmExtraFilesToDeploy Include="AppBundle\favicon.ico" />
<WasmExtraFilesToDeploy Include="AppBundle\index.html" />
<WasmExtraFilesToDeploy Include="AppBundle\Logo.svg" />
<WasmExtraFilesToDeploy Include="AppBundle\main.js" />
<WasmExtraFilesToDeploy Include="AppBundle\staticwebapp.config.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia.Web" Version="$(AvaloniaVersion)" />
<PackageReference Include="SkiaSharp.NativeAssets.WebAssembly" Version="$(SkiaSharpVersion)" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<linker>
<assembly fullname="Draw2D.Web" preserve="All" />
</linker>

Просмотреть файл

@ -1,5 +0,0 @@
@page "/"
@using Avalonia.Web.Blazor
<AvaloniaView />

Просмотреть файл

@ -1,26 +1,15 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
using System.Runtime.Versioning;
using Avalonia;
using Avalonia.Web;
using Draw2D;
namespace Draw2D.Web;
[assembly:SupportedOSPlatform("browser")]
public class Program
internal class Program
{
public static async Task Main(string[] args)
{
await CreateHostBuilder(args).Build().RunAsync();
}
private static void Main(string[] args)
=> BuildAvaloniaApp().SetupBrowserApp("out");
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;
}
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>();
}

Просмотреть файл

@ -1,30 +0,0 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:13961",
"sslPort": 44319
}
},
"profiles": {
"Draw2D.Web - IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Draw2D.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"
}
}
}
}

12
src/Draw2D.Web/Roots.xml Normal file
Просмотреть файл

@ -0,0 +1,12 @@
<linker>
<!-- App -->
<assembly fullname="Draw2D" preserve="All" />
<assembly fullname="Draw2D.Web" preserve="All" />
<!-- Avalonia Themes -->
<assembly fullname="Avalonia.Themes.Fluent" preserve="All" />
</linker>

Просмотреть файл

@ -1,7 +0,0 @@
@inherits LayoutComponentBase
<div class="page">
<div class="main">
@Body
</div>
</div>

Просмотреть файл

@ -1,70 +0,0 @@
.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;
}
}

Просмотреть файл

@ -1,10 +0,0 @@
@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 Draw2D.Web
@using Draw2D.Web.Shared

Просмотреть файл

@ -0,0 +1,11 @@
{
"wasmHostProperties": {
"perHostConfig": [
{
"name": "browser",
"html-path": "index.html",
"Host": "browser"
}
]
}
}

Просмотреть файл

@ -1,79 +0,0 @@
html, body {
font-family: "Nunito", sans-serif;
margin: 0;
height: 100vh;
overflow: hidden;
}
a {
text-decoration: none;
color: white;
}
#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;
position:fixed;
width:100%;
height:100%;
top:0px;
left:0px;
z-index:500;
}
canvas
{
opacity:1;
position:fixed;
width:100%;
height:100%;
top:0px;
left:0px;
z-index:500;
}
#app, .page {
height: 100%;
background: #171C2C;
color: white;
}
.navbar-brand {
font-size: 22px;
}
.overlay{
opacity:0.0;
position:fixed;
width:100vw;
height:100vh;
top:0px;
left:0px;
z-index:1000;
}
#splash {
display: flex;
justify-content: center;
align-items: center;
text-align: center;
min-height: 100vh;
}

Двоичные данные
src/Draw2D.Web/wwwroot/favicon.ico

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 172 KiB

Просмотреть файл

@ -1,54 +0,0 @@
<!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>Draw2D</title>
<base href="/" />
<link href="css/app.css" rel="stylesheet" />
</head>
<body>
<div id="app">
<div id="splash">
<h2>Powered by</h2>
<a class="navbar-brand" href="https://www.avaloniaui.net/" target="_blank">
<img src="Logo.svg" alt="Avalonia Logo" width="30" height="24" class="d-inline-block align-text-top">
Avalonia
</a>
</div>
</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" autostart="true"></script>
<!--<script type="module">
import { BrotliDecode } from './js/decode.min.js';
Blazor.start({
loadBootResource: function (type, name, defaultUri, integrity) {
if (type !== 'dotnetjs' && location.hostname !== 'localhost') {
return (async function () {
const response = await fetch(defaultUri + '.br', { cache: 'no-cache' });
if (!response.ok) {
throw new Error(response.statusText);
}
const originalResponseBuffer = await response.arrayBuffer();
const originalResponseArray = new Int8Array(originalResponseBuffer);
const decompressedResponseArray = BrotliDecode(originalResponseArray);
const contentType = type ===
'dotnetwasm' ? 'application/wasm' : 'application/octet-stream';
return new Response(decompressedResponseArray,
{ headers: { 'content-type': contentType } });
})();
}
}
});
</script>-->
</body>
</html>

Просмотреть файл

@ -1 +0,0 @@


1
src/Draw2D.Web/wwwroot/js/decode.min.js поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -7,7 +7,6 @@
<LangVersion>latest</LangVersion>
<Nullable>disable</Nullable>
<RootNamespace>Draw2D</RootNamespace>
<AvaloniaVersion>11.0.0-preview3</AvaloniaVersion>
</PropertyGroup>
<ItemGroup>
@ -17,8 +16,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Math.Spatial" Version="1.3.0" />
<PackageReference Include="SkiaSharp" Version="2.88.1-preview.108" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.1-preview.108" />
<PackageReference Include="SkiaSharp" Version="$(SkiaSharpVersion)" />
<PackageReference Include="Svg.Skia" Version="0.5.12" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />