Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expedition calculator #501

Merged
merged 4 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ElectronicObserver.Avalonia.Samples/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
RequestedThemeVariant="Default"
>
<Application.Styles>
<FluentTheme />
<FluentTheme DensityStyle="Compact">
<FluentTheme.Palettes>
<ColorPaletteResources x:Key="Light" Accent="DodgerBlue" />
<ColorPaletteResources x:Key="Dark" Accent="DodgerBlue" />
</FluentTheme.Palettes>
</FluentTheme>
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml" />
</Application.Styles>
</Application>
10 changes: 7 additions & 3 deletions ElectronicObserver.Avalonia.Samples/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Avalonia;
using System.Globalization;
using System.Threading;
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Data.Core.Plugins;
using Avalonia.Markup.Xaml;
using ElectronicObserver.Avalonia.Samples.ViewModels;
using ElectronicObserver.Avalonia.Samples.Views;
using HotAvalonia;

namespace ElectronicObserver.Avalonia.Samples;
Expand All @@ -12,6 +12,10 @@ public partial class App : Application
{
public override void Initialize()
{
CultureInfo ci = new("ja-JP");
Thread.CurrentThread.CurrentCulture = ci;
Thread.CurrentThread.CurrentUICulture = ci;

this.EnableHotReload();
AvaloniaXamlLoader.Load(this);
}
Expand Down
24 changes: 24 additions & 0 deletions ElectronicObserver.Avalonia.Samples/MainView.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<UserControl
x:Class="ElectronicObserver.Avalonia.Samples.MainView"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:expeditionCalculator="clr-namespace:ElectronicObserver.Avalonia.ExpeditionCalculator;assembly=ElectronicObserver.Avalonia"
xmlns:local="clr-namespace:ElectronicObserver.Avalonia.Samples"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:shipGroup="clr-namespace:ElectronicObserver.Avalonia.Samples.ShipGroup"
d:DesignHeight="450"
d:DesignWidth="800"
x:DataType="local:MainViewModel"
mc:Ignorable="d"
>
<TabControl>
<TabItem Header="Expedition">
<expeditionCalculator:ExpeditionCalculatorView DataContext="{Binding ExpeditionCalculator}" />
</TabItem>

<TabItem Header="Groups">
<shipGroup:ShipGroupSampleView DataContext="{Binding ShipGroup}" />
</TabItem>
</TabControl>
</UserControl>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Avalonia.Controls;

namespace ElectronicObserver.Avalonia.Samples.Views;
namespace ElectronicObserver.Avalonia.Samples;

public partial class MainView : UserControl
{
Expand Down
11 changes: 11 additions & 0 deletions ElectronicObserver.Avalonia.Samples/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using CommunityToolkit.Mvvm.ComponentModel;
using ElectronicObserver.Avalonia.ExpeditionCalculator;
using ElectronicObserver.Avalonia.Samples.ShipGroup;

namespace ElectronicObserver.Avalonia.Samples;

public class MainViewModel : ObservableObject
{
public ShipGroupSampleViewModel ShipGroup { get; } = new();
public ExpeditionCalculatorViewModel ExpeditionCalculator { get; } = new();
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<Window
x:Class="ElectronicObserver.Avalonia.Samples.Views.MainWindow"
x:Class="ElectronicObserver.Avalonia.Samples.MainWindow"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ElectronicObserver.Avalonia.Samples"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:ElectronicObserver.Avalonia.Samples.Views"
xmlns:vm="using:ElectronicObserver.Avalonia.Samples.ViewModels"
Title="ElectronicObserver.Avalonia.Samples"
d:DesignHeight="450"
d:DesignWidth="800"
Icon="/Assets/avalonia-logo.ico"
mc:Ignorable="d"
>
<views:MainView />
<local:MainView />
</Window>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Avalonia;
using Avalonia.Controls;

namespace ElectronicObserver.Avalonia.Samples.Views;
namespace ElectronicObserver.Avalonia.Samples;

public partial class MainWindow : Window
{
Expand Down
1 change: 0 additions & 1 deletion ElectronicObserver.Avalonia.Samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ private static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace();

}
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<UserControl
x:Class="ElectronicObserver.Avalonia.Samples.Views.MainView"
x:Class="ElectronicObserver.Avalonia.Samples.ShipGroup.ShipGroupSampleView"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:behaviors="clr-namespace:ElectronicObserver.Avalonia.Behaviors;assembly=ElectronicObserver.Avalonia"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ElectronicObserver.Avalonia.Samples.ShipGroup"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:persistentColumns="clr-namespace:ElectronicObserver.Avalonia.Behaviors.PersistentColumns;assembly=ElectronicObserver.Avalonia"
xmlns:shipGroup="clr-namespace:ElectronicObserver.Avalonia.ShipGroup;assembly=ElectronicObserver.Avalonia"
xmlns:vm="clr-namespace:ElectronicObserver.Avalonia.Samples.ViewModels"
x:Name="MainViewControl"
x:Name="ShipGroupSampleControl"
d:DesignHeight="450"
d:DesignWidth="800"
x:DataType="vm:MainViewModel"
x:DataType="local:ShipGroupSampleViewModel"
mc:Ignorable="d"
>
<UserControl.DataTemplates>
<DataTemplate DataType="shipGroup:ShipGroupItem">
<Button
Command="{Binding ((vm:MainViewModel)DataContext).SelectGroupCommand, ElementName=MainViewControl}"
Command="{Binding ((local:ShipGroupSampleViewModel)DataContext).SelectGroupCommand, ElementName=ShipGroupSampleControl}"
CommandParameter="{Binding}"
Content="{Binding Name}"
/>
Expand Down Expand Up @@ -69,12 +69,12 @@

<DataGrid.Columns>
<DataGridTextColumn
x:DataType="vm:Test"
x:DataType="local:Test"
Binding="{Binding Name}"
Header="Name"
/>
<DataGridTextColumn
x:DataType="vm:Test"
x:DataType="local:Test"
Binding="{Binding Description}"
Header="Description"
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Avalonia.Controls;

namespace ElectronicObserver.Avalonia.Samples.ShipGroup;

public partial class ShipGroupSampleView : UserControl
{
public ShipGroupSampleView()
{
InitializeComponent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
using ElectronicObserver.Avalonia.Behaviors.PersistentColumns;
using ElectronicObserver.Avalonia.ShipGroup;

namespace ElectronicObserver.Avalonia.Samples.ViewModels;
namespace ElectronicObserver.Avalonia.Samples.ShipGroup;

public class Test
{
public required string Name { get; set; }
public required string Description { get; set; }
}

public partial class MainViewModel : ViewModelBase
public partial class ShipGroupSampleViewModel : ObservableObject
{
private List<Test> Data { get; } = [];

Expand Down Expand Up @@ -46,7 +46,7 @@ public partial class MainViewModel : ViewModelBase
[ObservableProperty] private DataGridCollectionView _collectionView = new(new List<Test>());
[ObservableProperty] private ObservableCollection<ColumnModel> _columnProperties = [];

public MainViewModel()
public ShipGroupSampleViewModel()
{
for (int i = 0; i < 100; i++)
{
Expand Down

This file was deleted.

18 changes: 18 additions & 0 deletions ElectronicObserver.Avalonia/ExpeditionCalculator/Expedition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace ElectronicObserver.Avalonia.ExpeditionCalculator;

public class Expedition
{
public required int Id { get; init; }
public required string DisplayId { get; init; }
public required GreatSuccessType GreatSuccessType { get; init; }

public required TimeSpan Duration { get; init; }

public int Fuel { get; init; }
public int Ammo { get; init; }
public int Steel { get; init; }
public int Bauxite { get; init; }

public ExpeditionReward? Item1 { get; init; }
public ExpeditionReward? Item2 { get; init; }
}
Loading
Loading