commit 721b6b3ddcb20aa6d9de5ee96b80b33ef2a7051c
parent fc8a54fe26294539dc303e68ec935f84b9c5cb60
Author: Mikolaj Lenczewski <33129490+EnderRifter@users.noreply.github.com>
Date: Fri, 19 Jul 2019 08:44:40 +0100
Added GUI project.
Diffstat:
12 files changed, 227 insertions(+), 0 deletions(-)
diff --git a/StarSim/StarSim.sln b/StarSim/StarSim.sln
@@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StarSimLib", "StarSimLib\St
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StarSim", "StarSim\StarSim.csproj", "{E7DA74EF-E69A-4165-BF3D-5B641D991D75}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StarSimGui", "StarSimGui\StarSimGui.csproj", "{FC1E5541-81B8-4B44-A77E-E66A0EC4C077}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -41,6 +43,18 @@ Global
{E7DA74EF-E69A-4165-BF3D-5B641D991D75}.Release|x64.Build.0 = Release|x64
{E7DA74EF-E69A-4165-BF3D-5B641D991D75}.Release|x86.ActiveCfg = Release|x86
{E7DA74EF-E69A-4165-BF3D-5B641D991D75}.Release|x86.Build.0 = Release|x86
+ {FC1E5541-81B8-4B44-A77E-E66A0EC4C077}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FC1E5541-81B8-4B44-A77E-E66A0EC4C077}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FC1E5541-81B8-4B44-A77E-E66A0EC4C077}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {FC1E5541-81B8-4B44-A77E-E66A0EC4C077}.Debug|x64.Build.0 = Debug|Any CPU
+ {FC1E5541-81B8-4B44-A77E-E66A0EC4C077}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {FC1E5541-81B8-4B44-A77E-E66A0EC4C077}.Debug|x86.Build.0 = Debug|Any CPU
+ {FC1E5541-81B8-4B44-A77E-E66A0EC4C077}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FC1E5541-81B8-4B44-A77E-E66A0EC4C077}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FC1E5541-81B8-4B44-A77E-E66A0EC4C077}.Release|x64.ActiveCfg = Release|Any CPU
+ {FC1E5541-81B8-4B44-A77E-E66A0EC4C077}.Release|x64.Build.0 = Release|Any CPU
+ {FC1E5541-81B8-4B44-A77E-E66A0EC4C077}.Release|x86.ActiveCfg = Release|Any CPU
+ {FC1E5541-81B8-4B44-A77E-E66A0EC4C077}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/StarSim/StarSimGui/App.xaml b/StarSim/StarSimGui/App.xaml
@@ -0,0 +1,13 @@
+<Application xmlns="https://github.com/avaloniaui"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:local="clr-namespace:StarSimGui"
+ x:Class="StarSimGui.App">
+ <Application.DataTemplates>
+ <local:ViewLocator/>
+ </Application.DataTemplates>
+
+ <Application.Styles>
+ <StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml"/>
+ <StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml"/>
+ </Application.Styles>
+</Application>
diff --git a/StarSim/StarSimGui/App.xaml.cs b/StarSim/StarSimGui/App.xaml.cs
@@ -0,0 +1,13 @@
+using Avalonia;
+using Avalonia.Markup.Xaml;
+
+namespace StarSimGui
+{
+ public class App : Application
+ {
+ public override void Initialize()
+ {
+ AvaloniaXamlLoader.Load(this);
+ }
+ }
+}
diff --git a/StarSim/StarSimGui/Assets/avalonia-logo.ico b/StarSim/StarSimGui/Assets/avalonia-logo.ico
Binary files differ.
diff --git a/StarSim/StarSimGui/Program.cs b/StarSim/StarSimGui/Program.cs
@@ -0,0 +1,35 @@
+using System;
+using Avalonia;
+using Avalonia.Logging.Serilog;
+using StarSimGui.ViewModels;
+using StarSimGui.Views;
+
+namespace StarSimGui
+{
+ internal class Program
+ {
+ // Your application's entry point. Here you can initialize your MVVM framework, DI
+ // container, etc.
+ private static void AppMain(Application app, string[] args)
+ {
+ MainWindow window = new MainWindow
+ {
+ DataContext = new MainWindowViewModel(),
+ };
+
+ app.Run(window);
+ }
+
+ // Avalonia configuration, don't remove; also used by visual designer.
+ public static AppBuilder BuildAvaloniaApp()
+ => AppBuilder.Configure<App>()
+ .UsePlatformDetect()
+ .LogToDebug()
+ .UseReactiveUI();
+
+ // 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.
+ public static void Main(string[] args) => BuildAvaloniaApp().Start(AppMain, args);
+ }
+}
+\ No newline at end of file
diff --git a/StarSim/StarSimGui/StarSimGui.csproj b/StarSim/StarSimGui/StarSimGui.csproj
@@ -0,0 +1,38 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <TargetFrameworks>netcoreapp2.1;</TargetFrameworks>
+ <Platforms>AnyCPU;x64;x86</Platforms>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <Folder Include="Models\" />
+ <Compile Update="**\*.xaml.cs">
+ <DependentUpon>%(Filename)</DependentUpon>
+ </Compile>
+ <AvaloniaResource Include="**\*.xaml">
+ <SubType>Designer</SubType>
+ </AvaloniaResource>
+ <AvaloniaResource Include="Assets\*" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <PackageReference Include="Avalonia" Version="0.8.0" />
+ <PackageReference Include="Avalonia.Desktop" Version="0.8.0" />
+ <PackageReference Include="Avalonia.ReactiveUI" Version="0.8.0" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\StarSimLib\StarSimLib.csproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Update="App.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ </None>
+ <None Update="Views\MainWindow.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ </None>
+ </ItemGroup>
+</Project>
+\ No newline at end of file
diff --git a/StarSim/StarSimGui/ViewLocator.cs b/StarSim/StarSimGui/ViewLocator.cs
@@ -0,0 +1,35 @@
+using System;
+using Avalonia.Controls;
+using Avalonia.Controls.Templates;
+using StarSimGui.ViewModels;
+
+namespace StarSimGui
+{
+ public class ViewLocator : IDataTemplate
+ {
+ public bool SupportsRecycling
+ {
+ get { return false; }
+ }
+
+ public IControl Build(object data)
+ {
+ string name = data.GetType().FullName.Replace("ViewModel", "View");
+ Type type = Type.GetType(name);
+
+ if (type != null)
+ {
+ return (Control)Activator.CreateInstance(type);
+ }
+ else
+ {
+ return new TextBlock { Text = "Not Found: " + name };
+ }
+ }
+
+ public bool Match(object data)
+ {
+ return data is ViewModelBase;
+ }
+ }
+}
+\ No newline at end of file
diff --git a/StarSim/StarSimGui/ViewModels/MainWindowViewModel.cs b/StarSim/StarSimGui/ViewModels/MainWindowViewModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace StarSimGui.ViewModels
+{
+ public class MainWindowViewModel : ViewModelBase
+ {
+ public string Greeting
+ {
+ get { return "Welcome to Avalonia!"; }
+ }
+ }
+}
+\ No newline at end of file
diff --git a/StarSim/StarSimGui/ViewModels/ViewModelBase.cs b/StarSim/StarSimGui/ViewModels/ViewModelBase.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using ReactiveUI;
+
+namespace StarSimGui.ViewModels
+{
+ public class ViewModelBase : ReactiveObject
+ {
+ }
+}
diff --git a/StarSim/StarSimGui/Views/MainWindow.xaml b/StarSim/StarSimGui/Views/MainWindow.xaml
@@ -0,0 +1,17 @@
+<Window xmlns="https://github.com/avaloniaui"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:vm="clr-namespace:StarSimGui.ViewModels;assembly=StarSimGui"
+ 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="StarSimGui.Views.MainWindow"
+ Icon="/Assets/avalonia-logo.ico"
+ Title="StarSimGui">
+
+ <Design.DataContext>
+ <vm:MainWindowViewModel/>
+ </Design.DataContext>
+
+ <TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
+
+</Window>
diff --git a/StarSim/StarSimGui/Views/MainWindow.xaml.cs b/StarSim/StarSimGui/Views/MainWindow.xaml.cs
@@ -0,0 +1,22 @@
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace StarSimGui.Views
+{
+ public class MainWindow : Window
+ {
+ public MainWindow()
+ {
+ InitializeComponent();
+#if DEBUG
+ this.AttachDevTools();
+#endif
+ }
+
+ private void InitializeComponent()
+ {
+ AvaloniaXamlLoader.Load(this);
+ }
+ }
+}
diff --git a/StarSim/StarSimGui/nuget.config b/StarSim/StarSimGui/nuget.config
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ To use the Avalonia CI feed to get unstable packages, move this file to the root of your solution.
+-->
+
+<configuration>
+ <packageSources>
+ <add key="AvaloniaCI" value="https://www.myget.org/F/avalonia-ci/api/v2" />
+ </packageSources>
+</configuration>