improve ui
This commit is contained in:
parent
782965ce49
commit
3f620cd963
@ -1,5 +1,6 @@
|
||||
<Application xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
x:Class="StarsAssistant.App"
|
||||
xmlns:local="using:StarsAssistant"
|
||||
RequestedThemeVariant="Default">
|
||||
@ -11,6 +12,7 @@
|
||||
|
||||
<Application.Styles>
|
||||
<FluentTheme DensityStyle="Compact" />
|
||||
<materialIcons:MaterialIconStyles />
|
||||
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml"/>
|
||||
</Application.Styles>
|
||||
</Application>
|
@ -18,6 +18,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.1.3" />
|
||||
<PackageReference Include="CsvHelper" Version="33.0.1" />
|
||||
<PackageReference Include="Material.Icons.Avalonia" Version="2.1.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8" />
|
||||
|
||||
<PackageReference Include="Avalonia" Version="11.1.3" />
|
||||
|
@ -8,10 +8,8 @@ using Splat;
|
||||
|
||||
namespace StarsAssistant.ViewModels;
|
||||
|
||||
public partial class BuColViewModel : ViewModelBase, IActivatableViewModel
|
||||
public partial class BuColViewModel : ViewModelBase
|
||||
{
|
||||
public ViewModelActivator Activator { get; } = new ViewModelActivator();
|
||||
|
||||
public BuColViewModel()
|
||||
{
|
||||
this.WhenActivated((CompositeDisposable disposables) =>
|
||||
|
@ -1,5 +1,4 @@
|
||||
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.SourceGenerators;
|
||||
@ -8,10 +7,8 @@ using StarsAssistant.Model;
|
||||
|
||||
namespace StarsAssistant.ViewModels;
|
||||
|
||||
public partial class MainWindowViewModel : ViewModelBase, IActivatableViewModel
|
||||
public partial class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
public ViewModelActivator Activator { get; } = new ViewModelActivator();
|
||||
|
||||
[Reactive]
|
||||
private string _dbPath;
|
||||
|
||||
@ -20,6 +17,8 @@ public partial class MainWindowViewModel : ViewModelBase, IActivatableViewModel
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
InitializeCommands();
|
||||
|
||||
using var db = Locator.Current.GetService<StarsDatabase>()!;
|
||||
DbPath = Path.GetFullPath(db.DbPath);
|
||||
|
||||
@ -32,6 +31,15 @@ public partial class MainWindowViewModel : ViewModelBase, IActivatableViewModel
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
[ReactiveCommand]
|
||||
private void New()
|
||||
{
|
||||
this.Log().Info("New button hit");
|
||||
}
|
||||
|
||||
[ReactiveCommand]
|
||||
private void Open()
|
||||
{
|
||||
this.Log().Info("Open button hit");
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,43 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Reactive.Disposables;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReactiveUI;
|
||||
using StarsAssistant.Model;
|
||||
using Splat;
|
||||
|
||||
namespace StarsAssistant.ViewModels;
|
||||
|
||||
public partial class PlanetViewModel(Planet planet) : ViewModelBase
|
||||
public partial class PlanetViewModel : ViewModelBase
|
||||
{
|
||||
public PlanetViewModel(Planet planet)
|
||||
{
|
||||
Planet = planet;
|
||||
|
||||
this.WhenActivated((CompositeDisposable disposables) =>
|
||||
{
|
||||
// /* handle activation */
|
||||
// Disposable
|
||||
// .Create(() => { /* handle deactivation */ })
|
||||
// .DisposeWith(disposables);
|
||||
});
|
||||
}
|
||||
|
||||
private readonly Planet Planet;
|
||||
|
||||
public string Name => Planet.Name;
|
||||
|
||||
public string Owner => Planet.OwnerId ?? String.Empty;
|
||||
|
||||
public int Value => Planet.Value ?? 0;
|
||||
|
||||
public int Population => Planet.Population ?? 0;
|
||||
|
||||
public int SurfaceIronium => Planet.SurfaceIronium ?? 0;
|
||||
|
||||
public int SurfaceBoranium => Planet.SurfaceBoranium ?? 0;
|
||||
|
||||
public int SurfaceGermanium => Planet.SurfaceGermanium ?? 0;
|
||||
|
||||
public static ObservableCollection<PlanetViewModel> LoadAll()
|
||||
{
|
||||
using var db = Locator.Current.GetService<StarsDatabase>()!;
|
||||
@ -18,20 +49,4 @@ public partial class PlanetViewModel(Planet planet) : ViewModelBase
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private readonly Planet planet = planet;
|
||||
|
||||
public string Name => planet.Name;
|
||||
|
||||
public string Owner => planet.OwnerId ?? String.Empty;
|
||||
|
||||
public int Value => planet.Value ?? 0;
|
||||
|
||||
public int Population => planet.Population ?? 0;
|
||||
|
||||
public int SurfaceIronium => planet.SurfaceIronium ?? 0;
|
||||
|
||||
public int SurfaceBoranium => planet.SurfaceBoranium ?? 0;
|
||||
|
||||
public int SurfaceGermanium => planet.SurfaceGermanium ?? 0;
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
using ReactiveUI;
|
||||
using Splat;
|
||||
|
||||
namespace StarsAssistant.ViewModels;
|
||||
|
||||
public class ViewModelBase : ReactiveObject
|
||||
public class ViewModelBase : ReactiveObject, IEnableLogger, IActivatableViewModel
|
||||
{
|
||||
public ViewModelActivator Activator { get; } = new ViewModelActivator();
|
||||
}
|
||||
|
@ -13,10 +13,11 @@ public partial class BuColView : ReactiveUserControl<BuColViewModel>
|
||||
{
|
||||
public BuColView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.WhenActivated(disposables =>
|
||||
{
|
||||
});
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="using:StarsAssistant.ViewModels"
|
||||
xmlns:views="clr-namespace:StarsAssistant.Views"
|
||||
xmlns:materialIcons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="StarsAssistant.Views.MainWindow"
|
||||
x:DataType="vm:MainWindowViewModel"
|
||||
@ -18,7 +19,24 @@
|
||||
<vm:MainWindowViewModel/>
|
||||
</Design.DataContext>
|
||||
|
||||
<TabControl>
|
||||
<Grid ColumnDefinitions="64,*" RowDefinitions="*">
|
||||
<StackPanel Grid.Column="0"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Top"
|
||||
Margin="0" Spacing="12"
|
||||
>
|
||||
|
||||
<materialIcons:MaterialIcon Kind="DeathStar" Width="48" Height="48" />
|
||||
|
||||
<Button Height="56" Width="56" x:Name="NewButton">
|
||||
<materialIcons:MaterialIcon Kind="NewBox" Width="48" Height="48" />
|
||||
</Button>
|
||||
|
||||
<Button Height="56" Width="56" x:Name="OpenButton">
|
||||
<materialIcons:MaterialIcon Kind="OpenInApp" Width="48" Height="48" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<TabControl Grid.Column="1">
|
||||
<TabItem Header="Stars Assistant">
|
||||
<Grid ColumnDefinitions="Auto, *" RowDefinitions="Auto, Auto">
|
||||
<Label Grid.Row="0" Grid.Column="0" Margin="0,5,5,5" Padding="3">Database Path:</Label>
|
||||
@ -30,4 +48,5 @@
|
||||
DataContext="{Binding BuColViewModel}" />
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
@ -13,13 +13,19 @@ public partial class MainWindow : ReactiveWindow<MainWindowViewModel>
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.WhenActivated(disposables =>
|
||||
{
|
||||
this.OneWayBind(ViewModel, vm => vm.DbPath, v => v.DbPath.Text)
|
||||
.DisposeWith(disposables);
|
||||
|
||||
this.BindCommand(ViewModel, vm => vm.NewCommand, v => v.NewButton)
|
||||
.DisposeWith(disposables);
|
||||
|
||||
this.BindCommand(ViewModel, vm => vm.OpenCommand, v => v.OpenButton)
|
||||
.DisposeWith(disposables);
|
||||
});
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user