Adding GUI project.

This commit is contained in:
2026-05-25 20:48:26 +08:00
parent 937f1dd3a9
commit 07597a63d8
12 changed files with 214 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="GUI.App"
xmlns:local="using:GUI"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>
<Application.Styles>
<FluentTheme />
</Application.Styles>
</Application>
+31
View File
@@ -0,0 +1,31 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Data.Core;
using Avalonia.Data.Core.Plugins;
using System.Linq;
using Avalonia.Markup.Xaml;
using GUI.ViewModels;
using GUI.Views;
namespace GUI;
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow
{
DataContext = new MainWindowViewModel(),
};
}
base.OnFrameworkInitializationCompleted();
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

+31
View File
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>
<ItemGroup>
<Folder Include="Models\"/>
<AvaloniaResource Include="Assets\**"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="12.0.0"/>
<PackageReference Include="Avalonia.Desktop" Version="12.0.0"/>
<PackageReference Include="Avalonia.Themes.Fluent" Version="12.0.0"/>
<PackageReference Include="Avalonia.Fonts.Inter" Version="12.0.0"/>
<PackageReference Include="AvaloniaUI.DiagnosticsSupport" Version="2.2.0">
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.1"/>
<PackageReference Include="Tmds.DBus.Protocol" Version="0.93.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core\Core.csproj" />
</ItemGroup>
</Project>
+24
View File
@@ -0,0 +1,24 @@
using Avalonia;
using System;
namespace GUI;
sealed class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
#if DEBUG
.WithDeveloperTools()
#endif
.WithInterFont()
.LogToTrace();
}
+37
View File
@@ -0,0 +1,37 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using GUI.ViewModels;
namespace GUI;
/// <summary>
/// Given a view model, returns the corresponding view if possible.
/// </summary>
[RequiresUnreferencedCode(
"Default implementation of ViewLocator involves reflection which may be trimmed away.",
Url = "https://docs.avaloniaui.net/docs/concepts/view-locator")]
public class ViewLocator : IDataTemplate
{
public Control? Build(object? param)
{
if (param is null)
return null;
var name = param.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal);
var type = Type.GetType(name);
if (type != null)
{
return (Control)Activator.CreateInstance(type)!;
}
return new TextBlock { Text = "Not Found: " + name };
}
public bool Match(object? data)
{
return data is ViewModelBase;
}
}
@@ -0,0 +1,6 @@
namespace GUI.ViewModels;
public partial class MainWindowViewModel : ViewModelBase
{
public string Greeting { get; } = "Welcome to Avalonia!";
}
+7
View File
@@ -0,0 +1,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
namespace GUI.ViewModels;
public abstract class ViewModelBase : ObservableObject
{
}
+20
View File
@@ -0,0 +1,20 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:GUI.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="GUI.Views.MainWindow"
x:DataType="vm:MainWindowViewModel"
Icon="/Assets/avalonia-logo.ico"
Title="GUI">
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
<vm:MainWindowViewModel/>
</Design.DataContext>
<TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Window>
+11
View File
@@ -0,0 +1,11 @@
using Avalonia.Controls;
namespace GUI.Views;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
+18
View File
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- This manifest is used on Windows only.
Don't remove it as it might cause problems with window transparency and embedded controls.
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
<assemblyIdentity version="1.0.0.0" name="GUI.Desktop"/>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</assembly>
+14
View File
@@ -6,6 +6,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core.Tests", "Core.Tests\Co
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AtlFieldExtractor", "AtlFieldExtractor\AtlFieldExtractor.csproj", "{17699013-3F4A-408F-84CE-FD4178B1699D}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AtlFieldExtractor", "AtlFieldExtractor\AtlFieldExtractor.csproj", "{17699013-3F4A-408F-84CE-FD4178B1699D}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GUI", "GUI\GUI.csproj", "{9AB83303-0D46-4557-A62D-3753A0BE2103}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -52,6 +54,18 @@ Global
{17699013-3F4A-408F-84CE-FD4178B1699D}.Release|x64.Build.0 = Release|Any CPU {17699013-3F4A-408F-84CE-FD4178B1699D}.Release|x64.Build.0 = Release|Any CPU
{17699013-3F4A-408F-84CE-FD4178B1699D}.Release|x86.ActiveCfg = Release|Any CPU {17699013-3F4A-408F-84CE-FD4178B1699D}.Release|x86.ActiveCfg = Release|Any CPU
{17699013-3F4A-408F-84CE-FD4178B1699D}.Release|x86.Build.0 = Release|Any CPU {17699013-3F4A-408F-84CE-FD4178B1699D}.Release|x86.Build.0 = Release|Any CPU
{9AB83303-0D46-4557-A62D-3753A0BE2103}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9AB83303-0D46-4557-A62D-3753A0BE2103}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9AB83303-0D46-4557-A62D-3753A0BE2103}.Debug|x64.ActiveCfg = Debug|Any CPU
{9AB83303-0D46-4557-A62D-3753A0BE2103}.Debug|x64.Build.0 = Debug|Any CPU
{9AB83303-0D46-4557-A62D-3753A0BE2103}.Debug|x86.ActiveCfg = Debug|Any CPU
{9AB83303-0D46-4557-A62D-3753A0BE2103}.Debug|x86.Build.0 = Debug|Any CPU
{9AB83303-0D46-4557-A62D-3753A0BE2103}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9AB83303-0D46-4557-A62D-3753A0BE2103}.Release|Any CPU.Build.0 = Release|Any CPU
{9AB83303-0D46-4557-A62D-3753A0BE2103}.Release|x64.ActiveCfg = Release|Any CPU
{9AB83303-0D46-4557-A62D-3753A0BE2103}.Release|x64.Build.0 = Release|Any CPU
{9AB83303-0D46-4557-A62D-3753A0BE2103}.Release|x86.ActiveCfg = Release|Any CPU
{9AB83303-0D46-4557-A62D-3753A0BE2103}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE