temporary
This commit is contained in:
		
							
								
								
									
										15
									
								
								Stars Assistant/App.axaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								Stars Assistant/App.axaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
<Application xmlns="https://github.com/avaloniaui"
 | 
			
		||||
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
             x:Class="net.nehmer.sa.App"
 | 
			
		||||
             xmlns:local="using:net.nehmer.sa"
 | 
			
		||||
             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>
 | 
			
		||||
							
								
								
									
										28
									
								
								Stars Assistant/App.axaml.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								Stars Assistant/App.axaml.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
using Avalonia;
 | 
			
		||||
using Avalonia.Controls.ApplicationLifetimes;
 | 
			
		||||
using Avalonia.Markup.Xaml;
 | 
			
		||||
using net.nehmer.sa.ViewModels;
 | 
			
		||||
using net.nehmer.sa.Views;
 | 
			
		||||
 | 
			
		||||
namespace net.nehmer.sa;
 | 
			
		||||
 | 
			
		||||
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();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								Stars Assistant/Assets/avalonia-logo.ico
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Stars Assistant/Assets/avalonia-logo.ico
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 172 KiB  | 
@@ -1,12 +1,34 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Globalization;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using Avalonia;
 | 
			
		||||
using Avalonia.ReactiveUI;
 | 
			
		||||
 | 
			
		||||
namespace net.nehmer.sa;
 | 
			
		||||
 | 
			
		||||
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()
 | 
			
		||||
            .WithInterFont()
 | 
			
		||||
            .LogToTrace()
 | 
			
		||||
            .UseReactiveUI();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
using Microsoft.EntityFrameworkCore;
 | 
			
		||||
using CsvHelper.Configuration;
 | 
			
		||||
using CsvHelper;
 | 
			
		||||
 | 
			
		||||
using net.nehmer.sa.model;
 | 
			
		||||
using System.Text;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
using var db = new StarsDatabase("stars.sqlite");
 | 
			
		||||
 | 
			
		||||
@@ -31,6 +53,7 @@ using (var csv = new CsvReader(reader, config))
 | 
			
		||||
    }
 | 
			
		||||
    db.SaveChanges();
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
// Create
 | 
			
		||||
 
 | 
			
		||||
@@ -6,11 +6,29 @@
 | 
			
		||||
    <RootNamespace>net.nehmer.sa</RootNamespace>
 | 
			
		||||
    <ImplicitUsings>enable</ImplicitUsings>
 | 
			
		||||
    <Nullable>enable</Nullable>
 | 
			
		||||
    <BuiltInComInteropSupport>true</BuiltInComInteropSupport>
 | 
			
		||||
    <ApplicationManifest>app.manifest</ApplicationManifest>
 | 
			
		||||
    <AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
  
 | 
			
		||||
  <!-- PropertyGroup>
 | 
			
		||||
    <OutputType>WinExe</OutputType>
 | 
			
		||||
  </PropertyGroup -->
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
 | 
			
		||||
    <PackageReference Include="CsvHelper" Version="33.0.1" />
 | 
			
		||||
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.7" />
 | 
			
		||||
 | 
			
		||||
    <PackageReference Include="Avalonia" Version="11.0.10" />
 | 
			
		||||
    <PackageReference Include="Avalonia.Desktop" Version="11.0.10" />
 | 
			
		||||
    <PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.10" />
 | 
			
		||||
    <PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.10" />
 | 
			
		||||
    <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
 | 
			
		||||
    <PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.10" />
 | 
			
		||||
    <PackageReference Include="Avalonia.ReactiveUI" Version="11.0.10" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 | 
			
		||||
</Project>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										33
									
								
								Stars Assistant/ViewLocator.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								Stars Assistant/ViewLocator.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
			
		||||
using System;
 | 
			
		||||
using Avalonia.Controls;
 | 
			
		||||
using Avalonia.Controls.Templates;
 | 
			
		||||
using net.nehmer.sa.ViewModels;
 | 
			
		||||
 | 
			
		||||
namespace net.nehmer.sa;
 | 
			
		||||
 | 
			
		||||
public class ViewLocator : IDataTemplate
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    public Control? Build(object? data)
 | 
			
		||||
    {
 | 
			
		||||
        if (data is null)
 | 
			
		||||
            return null;
 | 
			
		||||
        
 | 
			
		||||
        var name = data.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal);
 | 
			
		||||
        var type = Type.GetType(name);
 | 
			
		||||
 | 
			
		||||
        if (type != null)
 | 
			
		||||
        {
 | 
			
		||||
            var control = (Control)Activator.CreateInstance(type)!;
 | 
			
		||||
            control.DataContext = data;
 | 
			
		||||
            return control;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        return new TextBlock { Text = "Not Found: " + name };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public bool Match(object? data)
 | 
			
		||||
    {
 | 
			
		||||
        return data is ViewModelBase;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										8
									
								
								Stars Assistant/ViewModels/MainWindowViewModel.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Stars Assistant/ViewModels/MainWindowViewModel.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
namespace net.nehmer.sa.ViewModels;
 | 
			
		||||
 | 
			
		||||
public class MainWindowViewModel : ViewModelBase
 | 
			
		||||
{
 | 
			
		||||
#pragma warning disable CA1822 // Mark members as static
 | 
			
		||||
    public string Greeting => "Welcome to Stars Assistant!";
 | 
			
		||||
#pragma warning restore CA1822 // Mark members as static
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										7
									
								
								Stars Assistant/ViewModels/ViewModelBase.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								Stars Assistant/ViewModels/ViewModelBase.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
using ReactiveUI;
 | 
			
		||||
 | 
			
		||||
namespace net.nehmer.sa.ViewModels;
 | 
			
		||||
 | 
			
		||||
public class ViewModelBase : ReactiveObject
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										32
									
								
								Stars Assistant/Views/MainWindow.axaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								Stars Assistant/Views/MainWindow.axaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
			
		||||
<Window xmlns="https://github.com/avaloniaui"
 | 
			
		||||
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 | 
			
		||||
        xmlns:vm="using:net.nehmer.sa.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="net.nehmer.sa.Views.MainWindow"
 | 
			
		||||
        x:DataType="vm:MainWindowViewModel"
 | 
			
		||||
        Title="GetStartedApp">
 | 
			
		||||
 | 
			
		||||
        <!-- Icon="/Assets/avalonia-logo.ico" -->
 | 
			
		||||
 | 
			
		||||
    <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>
 | 
			
		||||
 | 
			
		||||
    <StackPanel>
 | 
			
		||||
        <Border Margin="5" CornerRadius="10" Background="LightBlue">
 | 
			
		||||
            <TextBlock Margin="5" FontSize="24" HorizontalAlignment="Center" Text="{Binding Greeting}"></TextBlock>
 | 
			
		||||
        </Border>
 | 
			
		||||
        <Grid ShowGridLines="True" Margin="5" ColumnDefinitions="120, 100" RowDefinitions="Auto, Auto, Auto">  
 | 
			
		||||
            <Label Grid.Row="0" Grid.Column="0" Margin="10">Celsius</Label>
 | 
			
		||||
            <TextBox Grid.Row="0" Grid.Column="1" Margin="0 5" Text="0" Name="celsius"/>
 | 
			
		||||
            <Label Grid.Row="1" Grid.Column="0" Margin="10">Fahrenheit</Label>
 | 
			
		||||
            <TextBox Grid.Row="1"  Grid.Column="1" Margin="0 5" Text="0" Name="fahrenheit"/>
 | 
			
		||||
            <Button Grid.Row="2" Grid.Column="1" Margin="0 5" Click="ButtonClicked">Calculate</Button>
 | 
			
		||||
        </Grid>
 | 
			
		||||
  </StackPanel>
 | 
			
		||||
 | 
			
		||||
</Window>
 | 
			
		||||
							
								
								
									
										28
									
								
								Stars Assistant/Views/MainWindow.axaml.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								Stars Assistant/Views/MainWindow.axaml.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
using Avalonia.Controls;
 | 
			
		||||
using Avalonia.Interactivity;
 | 
			
		||||
using System.Diagnostics;
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace net.nehmer.sa.Views;
 | 
			
		||||
 | 
			
		||||
public partial class MainWindow : Window
 | 
			
		||||
{
 | 
			
		||||
    public MainWindow()
 | 
			
		||||
    {
 | 
			
		||||
        InitializeComponent();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void ButtonClicked(object source, RoutedEventArgs args)
 | 
			
		||||
    {
 | 
			
		||||
        if (Double.TryParse(celsius.Text, out double C))
 | 
			
		||||
        {
 | 
			
		||||
            var F = C * (9d / 5d) + 32;
 | 
			
		||||
            fahrenheit.Text = F.ToString("0.0");
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            celsius.Text = "0";
 | 
			
		||||
            fahrenheit.Text = "0";
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								Stars Assistant/app.manifest
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								Stars Assistant/app.manifest
									
									
									
									
									
										Normal 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="nehmer.net.saa"/>
 | 
			
		||||
 | 
			
		||||
  <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>
 | 
			
		||||
@@ -1,39 +0,0 @@
 | 
			
		||||
using Microsoft.EntityFrameworkCore;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
public class BloggingContext : DbContext
 | 
			
		||||
{
 | 
			
		||||
    public DbSet<Blog> Blogs { get; set; }
 | 
			
		||||
    public DbSet<Post> Posts { get; set; }
 | 
			
		||||
 | 
			
		||||
    public string DbPath { get; }
 | 
			
		||||
 | 
			
		||||
    public BloggingContext()
 | 
			
		||||
    {
 | 
			
		||||
        DbPath = "./test.sqlite";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // The following configures EF to create a Sqlite database file in the
 | 
			
		||||
    // special "local" folder for your platform.
 | 
			
		||||
    protected override void OnConfiguring(DbContextOptionsBuilder options)
 | 
			
		||||
        => options.UseSqlite($"Data Source={DbPath}");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public class Blog
 | 
			
		||||
{
 | 
			
		||||
    public int BlogId { get; set; }
 | 
			
		||||
    public string Url { get; set; }
 | 
			
		||||
 | 
			
		||||
    public List<Post> Posts { get; } = new();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public class Post
 | 
			
		||||
{
 | 
			
		||||
    public int PostId { get; set; }
 | 
			
		||||
    public string Title { get; set; }
 | 
			
		||||
    public string Content { get; set; }
 | 
			
		||||
 | 
			
		||||
    public int BlogId { get; set; }
 | 
			
		||||
    public Blog Blog { get; set; }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user