diff --git a/src/GUI/App.axaml b/src/GUI/App.axaml new file mode 100644 index 0000000..6047e5e --- /dev/null +++ b/src/GUI/App.axaml @@ -0,0 +1,15 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/GUI/App.axaml.cs b/src/GUI/App.axaml.cs new file mode 100644 index 0000000..45bfd43 --- /dev/null +++ b/src/GUI/App.axaml.cs @@ -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(); + } +} diff --git a/src/GUI/Assets/avalonia-logo.ico b/src/GUI/Assets/avalonia-logo.ico new file mode 100644 index 0000000..f7da8bb Binary files /dev/null and b/src/GUI/Assets/avalonia-logo.ico differ diff --git a/src/GUI/GUI.csproj b/src/GUI/GUI.csproj new file mode 100644 index 0000000..ba7ee4f --- /dev/null +++ b/src/GUI/GUI.csproj @@ -0,0 +1,31 @@ + + + WinExe + net10.0 + enable + app.manifest + true + + + + + + + + + + + + + + None + All + + + + + + + + + diff --git a/src/GUI/Program.cs b/src/GUI/Program.cs new file mode 100644 index 0000000..2bea6c8 --- /dev/null +++ b/src/GUI/Program.cs @@ -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() + .UsePlatformDetect() +#if DEBUG + .WithDeveloperTools() +#endif + .WithInterFont() + .LogToTrace(); +} diff --git a/src/GUI/ViewLocator.cs b/src/GUI/ViewLocator.cs new file mode 100644 index 0000000..ba1c95d --- /dev/null +++ b/src/GUI/ViewLocator.cs @@ -0,0 +1,37 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Avalonia.Controls; +using Avalonia.Controls.Templates; +using GUI.ViewModels; + +namespace GUI; + +/// +/// Given a view model, returns the corresponding view if possible. +/// +[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; + } +} diff --git a/src/GUI/ViewModels/MainWindowViewModel.cs b/src/GUI/ViewModels/MainWindowViewModel.cs new file mode 100644 index 0000000..7a2194a --- /dev/null +++ b/src/GUI/ViewModels/MainWindowViewModel.cs @@ -0,0 +1,6 @@ +namespace GUI.ViewModels; + +public partial class MainWindowViewModel : ViewModelBase +{ + public string Greeting { get; } = "Welcome to Avalonia!"; +} diff --git a/src/GUI/ViewModels/ViewModelBase.cs b/src/GUI/ViewModels/ViewModelBase.cs new file mode 100644 index 0000000..1abda89 --- /dev/null +++ b/src/GUI/ViewModels/ViewModelBase.cs @@ -0,0 +1,7 @@ +using CommunityToolkit.Mvvm.ComponentModel; + +namespace GUI.ViewModels; + +public abstract class ViewModelBase : ObservableObject +{ +} diff --git a/src/GUI/Views/MainWindow.axaml b/src/GUI/Views/MainWindow.axaml new file mode 100644 index 0000000..c7b2c18 --- /dev/null +++ b/src/GUI/Views/MainWindow.axaml @@ -0,0 +1,20 @@ + + + + + + + + + + diff --git a/src/GUI/Views/MainWindow.axaml.cs b/src/GUI/Views/MainWindow.axaml.cs new file mode 100644 index 0000000..df3d036 --- /dev/null +++ b/src/GUI/Views/MainWindow.axaml.cs @@ -0,0 +1,11 @@ +using Avalonia.Controls; + +namespace GUI.Views; + +public partial class MainWindow : Window +{ + public MainWindow() + { + InitializeComponent(); + } +} diff --git a/src/GUI/app.manifest b/src/GUI/app.manifest new file mode 100644 index 0000000..75d0e28 --- /dev/null +++ b/src/GUI/app.manifest @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/src/Resonance.sln b/src/Resonance.sln index 1bbef9a..4cb09cd 100755 --- a/src/Resonance.sln +++ b/src/Resonance.sln @@ -6,6 +6,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core.Tests", "Core.Tests\Co EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AtlFieldExtractor", "AtlFieldExtractor\AtlFieldExtractor.csproj", "{17699013-3F4A-408F-84CE-FD4178B1699D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GUI", "GUI\GUI.csproj", "{9AB83303-0D46-4557-A62D-3753A0BE2103}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution 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|x86.ActiveCfg = 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 GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE