Add core UI
This commit is contained in:
parent
500d6df113
commit
2a7ff864bf
8 changed files with 181 additions and 19 deletions
|
|
@ -4,6 +4,10 @@
|
|||
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageVersion Include="Avalonia" Version="11.0.7" />
|
||||
<PackageVersion Include="Avalonia.Desktop" Version="11.0.7" />
|
||||
<PackageVersion Include="Avalonia.ReactiveUI" Version="11.0.7" />
|
||||
<PackageVersion Include="Avalonia.Themes.Fluent" Version="11.0.7" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.1" />
|
||||
<PackageVersion Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.1" />
|
||||
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
|
||||
|
|
@ -12,7 +16,11 @@
|
|||
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.1" />
|
||||
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.1" />
|
||||
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1" />
|
||||
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0" />
|
||||
<PackageVersion Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.0" />
|
||||
<PackageVersion Include="Splat.Microsoft.Extensions.DependencyInjection" Version="14.8.12" />
|
||||
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
<PackageVersion Include="System.IO.Hashing" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
14
InkForge.sln
14
InkForge.sln
|
|
@ -13,8 +13,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InkForge.Sqlite", "shared\m
|
|||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "app", "app", "{84CBD204-9573-4472-9334-68FB360BD6ED}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InkForge", "app\InkForge\InkForge.csproj", "{D44F8BF4-CB4D-407D-B623-495165BD3A6E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InkForge.Desktop", "app\InkForge.Desktop\InkForge.Desktop.csproj", "{5AFA8AD9-9230-4218-BBFD-BD75F1E752DC}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InkForge.Api", "InkForge.Api\InkForge.Api.csproj", "{DEB06372-672A-412E-89B1-E4D97EEBBA25}"
|
||||
|
|
@ -29,6 +27,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "design", "design", "{C78684
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InkForge.Migrations", "design\InkForge.Migrations\InkForge.Migrations.csproj", "{8DF3397E-2717-49F0-9592-82ABE9327A73}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InkForge.Common", "app\InkForge.Common\InkForge.Common.csproj", "{DCE2DCD6-D15C-4F0D-8D7F-22FF82F62F6F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -46,10 +46,6 @@ Global
|
|||
{C504E59E-16CB-41CD-B9C7-F07E9A8A2E16}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C504E59E-16CB-41CD-B9C7-F07E9A8A2E16}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C504E59E-16CB-41CD-B9C7-F07E9A8A2E16}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D44F8BF4-CB4D-407D-B623-495165BD3A6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D44F8BF4-CB4D-407D-B623-495165BD3A6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D44F8BF4-CB4D-407D-B623-495165BD3A6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D44F8BF4-CB4D-407D-B623-495165BD3A6E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5AFA8AD9-9230-4218-BBFD-BD75F1E752DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5AFA8AD9-9230-4218-BBFD-BD75F1E752DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5AFA8AD9-9230-4218-BBFD-BD75F1E752DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
@ -70,14 +66,18 @@ Global
|
|||
{8DF3397E-2717-49F0-9592-82ABE9327A73}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8DF3397E-2717-49F0-9592-82ABE9327A73}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8DF3397E-2717-49F0-9592-82ABE9327A73}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DCE2DCD6-D15C-4F0D-8D7F-22FF82F62F6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DCE2DCD6-D15C-4F0D-8D7F-22FF82F62F6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DCE2DCD6-D15C-4F0D-8D7F-22FF82F62F6F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DCE2DCD6-D15C-4F0D-8D7F-22FF82F62F6F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{DD595B76-5FDE-4C37-822E-CB58BBB02C8C} = {C73D8E17-EA0A-4206-91D4-9E5BD63B3DB0}
|
||||
{12D30DD9-8615-4947-A13D-88E6478242E4} = {C73D8E17-EA0A-4206-91D4-9E5BD63B3DB0}
|
||||
{C504E59E-16CB-41CD-B9C7-F07E9A8A2E16} = {12D30DD9-8615-4947-A13D-88E6478242E4}
|
||||
{D44F8BF4-CB4D-407D-B623-495165BD3A6E} = {84CBD204-9573-4472-9334-68FB360BD6ED}
|
||||
{5AFA8AD9-9230-4218-BBFD-BD75F1E752DC} = {84CBD204-9573-4472-9334-68FB360BD6ED}
|
||||
{F8A7563F-2647-4623-88E7-470D20F25E93} = {A9F8087F-F148-47A5-94AE-F7B6E1D33096}
|
||||
{8DF3397E-2717-49F0-9592-82ABE9327A73} = {C7868400-84D7-45C5-B594-C30777EE5191}
|
||||
{DCE2DCD6-D15C-4F0D-8D7F-22FF82F62F6F} = {84CBD204-9573-4472-9334-68FB360BD6ED}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
|||
11
app/InkForge.Common/App.axaml
Normal file
11
app/InkForge.Common/App.axaml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<Application xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:InkForge.Common"
|
||||
x:Class="InkForge.Common.App"
|
||||
RequestedThemeVariant="Default">
|
||||
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
||||
|
||||
<Application.Styles>
|
||||
<FluentTheme />
|
||||
</Application.Styles>
|
||||
</Application>
|
||||
45
app/InkForge.Common/App.axaml.cs
Normal file
45
app/InkForge.Common/App.axaml.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
using ReactiveUI;
|
||||
|
||||
namespace InkForge.Common;
|
||||
|
||||
public partial class App : Application
|
||||
{
|
||||
public static readonly StyledProperty<IHost> HostProperty = AvaloniaProperty.Register<App, IHost>("Host");
|
||||
|
||||
public IHost Host => GetValue(HostProperty);
|
||||
|
||||
public IServiceProvider Services => Host.Services;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
// var viewModel = Services.Activate<MainViewModel>();
|
||||
// var view = ViewLocator.Current.ResolveView(viewModel);
|
||||
// switch (ApplicationLifetime)
|
||||
// {
|
||||
// case IClassicDesktopStyleApplicationLifetime desktop:
|
||||
// desktop.MainWindow = view as Window;
|
||||
// break;
|
||||
|
||||
// case ISingleViewApplicationLifetime singleView:
|
||||
// singleView.MainView = view as Control;
|
||||
// break;
|
||||
|
||||
// default:
|
||||
// throw new NotSupportedException();
|
||||
// }
|
||||
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
}
|
||||
}
|
||||
22
app/InkForge.Common/InkForge.Common.csproj
Normal file
22
app/InkForge.Common/InkForge.Common.csproj
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RootNamespace>InkForge</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia.ReactiveUI" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\shared\InkForge.Data\InkForge.Data.csproj" />
|
||||
<ProjectReference Include="..\..\shared\migrations\InkForge.Sqlite\InkForge.Sqlite.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -5,6 +5,16 @@
|
|||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<AssemblyName>InkForge</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia.Desktop" />
|
||||
<PackageReference Include="Splat.Microsoft.Extensions.DependencyInjection" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\InkForge.Common\InkForge.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,2 +1,78 @@
|
|||
// See https://aka.ms/new-console-template for more information
|
||||
Console.WriteLine("Hello, World!");
|
||||
using Avalonia;
|
||||
using Avalonia.ReactiveUI;
|
||||
using Avalonia.Threading;
|
||||
|
||||
using InkForge.Common;
|
||||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
using ReactiveUI;
|
||||
|
||||
using Splat;
|
||||
using Splat.Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
static class Program
|
||||
{
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
=> BuildAvaloniaApp()
|
||||
.UseMicrosoftExtensionsHosting(args)
|
||||
.StartWithClassicDesktopLifetime(args);
|
||||
|
||||
public static AppBuilder BuildAvaloniaApp()
|
||||
=> AppBuilder.Configure<App>()
|
||||
.UsePlatformDetect()
|
||||
.UseReactiveUI()
|
||||
.LogToTrace();
|
||||
|
||||
private static void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.UseMicrosoftDependencyResolver();
|
||||
var mutableResolver = Locator.CurrentMutable;
|
||||
mutableResolver.InitializeSplat();
|
||||
mutableResolver.InitializeReactiveUI();
|
||||
|
||||
services.AddHttpClient();
|
||||
|
||||
// services.UseFactories();
|
||||
// services.AddViewModelFactory();
|
||||
// services.AddTransient<IViewFor<MainViewModel>, MainWindow>();
|
||||
}
|
||||
|
||||
private static void OnSetup(this HostApplicationBuilder hostBuilder, AppBuilder appBuilder)
|
||||
{
|
||||
var dispatcher = Dispatcher.UIThread;
|
||||
|
||||
var app = appBuilder.Instance!;
|
||||
hostBuilder.Services
|
||||
.AddSingleton(app)
|
||||
.AddSingleton(app.ApplicationLifetime!)
|
||||
.AddSingleton(app.PlatformSettings!)
|
||||
.AddSingleton(dispatcher);
|
||||
|
||||
var host = hostBuilder.Build();
|
||||
host.Services.UseMicrosoftDependencyResolver();
|
||||
app.SetValue(App.HostProperty, host);
|
||||
dispatcher.ShutdownStarted += host.Shutdown;
|
||||
|
||||
dispatcher.Post(static arg =>
|
||||
{
|
||||
var host = (IHost)arg!;
|
||||
host.StartAsync()
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
}, host, DispatcherPriority.Send);
|
||||
}
|
||||
|
||||
private static void Shutdown(this IHost host, object? sender, EventArgs e)
|
||||
=> host.StopAsync().GetAwaiter().GetResult();
|
||||
|
||||
private static AppBuilder UseMicrosoftExtensionsHosting(this AppBuilder builder, string[] args)
|
||||
{
|
||||
var hostBuilder = Host.CreateApplicationBuilder(args);
|
||||
ConfigureServices(hostBuilder.Services);
|
||||
builder.AfterSetup(hostBuilder.OnSetup);
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RootNamespace>InkForge</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Loading…
Add table
Add a link
Reference in a new issue