-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Windows.Input; | ||
using NSubstitute; | ||
|
||
namespace SightKeeper.Avalonia.ViewModels; | ||
|
||
public static class FakeViewModel | ||
{ | ||
internal static ICommand CommandSubstitute { get; } = Substitute.For<ICommand>(); | ||
} |
30 changes: 30 additions & 0 deletions
30
SightKeeper.Avalonia/ViewModels/Tabs/Profiles/FakeProfilesViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Windows.Input; | ||
using SightKeeper.Domain.Model; | ||
using SightKeeper.Domain.Model.Common; | ||
|
||
namespace SightKeeper.Avalonia.ViewModels.Tabs.Profiles; | ||
|
||
public sealed class FakeProfilesViewModel : IProfilesViewModel | ||
{ | ||
public IReadOnlyCollection<ProfileViewModel> Profiles { get; } | ||
public ICommand CreateProfileCommand => FakeViewModel.CommandSubstitute; | ||
|
||
public FakeProfilesViewModel() | ||
{ | ||
DataSet dataSet = new("Dataset 1"); | ||
Game game = new("Game 1", "game1"); | ||
dataSet.Game = game; | ||
var weights = dataSet.WeightsLibrary.CreateWeights(Array.Empty<byte>(), Array.Empty<byte>(), ModelSize.Small, | ||
100, 0.5f, 0.4f, 0.3f, Enumerable.Empty<Asset>()); | ||
Profile profile1 = new("Profile", string.Empty, 0.5f, 2f, weights); | ||
Profile profile2 = new("Profile with long name!", string.Empty, 0.3f, 3f, weights); | ||
Profiles = new ProfileViewModel[] | ||
{ | ||
new(profile1), | ||
new(profile2) | ||
}; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
SightKeeper.Avalonia/ViewModels/Tabs/Profiles/IProfilesViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Collections.Generic; | ||
using System.Windows.Input; | ||
|
||
namespace SightKeeper.Avalonia.ViewModels.Tabs.Profiles; | ||
|
||
public interface IProfilesViewModel | ||
{ | ||
IReadOnlyCollection<ProfileViewModel> Profiles { get; } | ||
ICommand CreateProfileCommand { get; } | ||
} |
17 changes: 17 additions & 0 deletions
17
SightKeeper.Avalonia/ViewModels/Tabs/Profiles/ProfileViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using SightKeeper.Domain.Model; | ||
using SightKeeper.Domain.Model.Common; | ||
|
||
namespace SightKeeper.Avalonia.ViewModels.Tabs.Profiles; | ||
|
||
public sealed class ProfileViewModel | ||
{ | ||
public Profile Profile { get; } | ||
public string Name => Profile.Name; | ||
public string Description => Profile.Description; | ||
public Game? Game => Profile.Weights.Library.DataSet.Game; | ||
|
||
public ProfileViewModel(Profile profile) | ||
{ | ||
Profile = profile; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<UserControl xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:profilesViewModels="clr-namespace:SightKeeper.Avalonia.ViewModels.Tabs.Profiles" | ||
xmlns:icons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" | ||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" | ||
x:Class="SightKeeper.Avalonia.Views.Tabs.ProfilesTab" | ||
x:DataType="profilesViewModels:IProfilesViewModel"> | ||
<Design.DataContext> | ||
<profilesViewModels:FakeProfilesViewModel/> | ||
</Design.DataContext> | ||
<Grid RowDefinitions="Auto *"> | ||
<StackPanel Grid.Row="0" | ||
Orientation="Horizontal" | ||
Margin="5"> | ||
<Button Content="{icons:MaterialIconExt Plus}"/> | ||
</StackPanel> | ||
<ScrollViewer Grid.Row="1"> | ||
<ItemsControl ItemsSource="{Binding Profiles}"> | ||
<ItemsControl.ItemsPanel> | ||
<ItemsPanelTemplate> | ||
<WrapPanel/> | ||
</ItemsPanelTemplate> | ||
</ItemsControl.ItemsPanel> | ||
<ItemsControl.ItemTemplate> | ||
<DataTemplate> | ||
<Border BorderBrush="SlateGray" | ||
BorderThickness="1" | ||
CornerRadius="5" | ||
Margin="5" | ||
Padding="10 5 5 5" | ||
MaxWidth="200" | ||
MinWidth="100"> | ||
<Grid RowDefinitions="* *" | ||
ColumnDefinitions="* Auto"> | ||
<TextBlock Grid.Row="0" Grid.Column="0" | ||
Grid.ColumnSpan="2" | ||
Text="{Binding Name}" | ||
FontSize="18" | ||
VerticalAlignment="Center" | ||
Margin="0 0 5 0"/> | ||
<TextBlock Grid.Row="1" Grid.Column="0" | ||
Text="{Binding Game.Title}" | ||
FontSize="14" | ||
VerticalAlignment="Center" | ||
Margin="0 0 5 0"/> | ||
<Button Grid.Row="1" Grid.Column="1" | ||
Content="{icons:MaterialIconExt Cog}" | ||
Padding="5"/> | ||
</Grid> | ||
</Border> | ||
</DataTemplate> | ||
</ItemsControl.ItemTemplate> | ||
</ItemsControl> | ||
</ScrollViewer> | ||
</Grid> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Markup.Xaml; | ||
|
||
namespace SightKeeper.Avalonia.Views.Tabs; | ||
|
||
public partial class ProfilesTab : UserControl | ||
{ | ||
public ProfilesTab() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void InitializeComponent() | ||
{ | ||
AvaloniaXamlLoader.Load(this); | ||
} | ||
} |