-
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.
Implement ProfileEditor view and VM stuff for that (just without impl…
…ementations for ProfileEditorViewModel, interface and fake only)
- Loading branch information
Showing
13 changed files
with
203 additions
and
1 deletion.
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
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
47 changes: 47 additions & 0 deletions
47
SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Editor/FakeProfileEditorViewModel.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,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Windows.Input; | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using SightKeeper.Domain.Model; | ||
using SightKeeper.Domain.Model.Common; | ||
|
||
namespace SightKeeper.Avalonia.ViewModels.Tabs.Profiles.Editor; | ||
|
||
public sealed partial class FakeProfileEditorViewModel : ViewModel, ProfileEditorViewModel | ||
{ | ||
public IReadOnlyCollection<DataSet> AvailableDataSets { get; } | ||
public IReadOnlyCollection<Weights> AvailableWeights { get; } | ||
public IReadOnlyCollection<ItemClass> AvailableItemClasses { get; } | ||
public string Name { get; set; } = "Profile 1"; | ||
public string Description { get; set; } = "Some description.. lorem ipsum and all that stuff"; | ||
[ObservableProperty] private float _detectionThreshold = 0.6f; | ||
[ObservableProperty] private float _mouseSensitivity = 1.5f; | ||
public DataSet? DataSet { get; set; } | ||
public Weights? Weights { get; set; } | ||
public IReadOnlyList<ItemClass> ItemClasses { get; } | ||
public ItemClass? ItemClassToAdd { get; set; } | ||
public ICommand AddItemClassCommand => FakeViewModel.CommandSubstitute; | ||
public ICommand RemoveItemClassCommand => FakeViewModel.CommandSubstitute; | ||
public ICommand MoveItemClassUpCommand => FakeViewModel.CommandSubstitute; | ||
public ICommand MoveItemClassDownCommand => FakeViewModel.CommandSubstitute; | ||
public ICommand ApplyCommand => FakeViewModel.CommandSubstitute; | ||
|
||
public FakeProfileEditorViewModel() | ||
{ | ||
DataSet dataSet = new("Dataset 1"); | ||
var weights = dataSet.WeightsLibrary.CreateWeights(Array.Empty<byte>(), Array.Empty<byte>(), ModelSize.Nano, 100, 1.1f, 1.0f, | ||
0.9f, Enumerable.Empty<Asset>()); | ||
var itemClass1 = dataSet.CreateItemClass("Item class 1", 0); | ||
var itemClass2 = dataSet.CreateItemClass("Item class 2", 0); | ||
var itemClass3 = dataSet.CreateItemClass("Item class 3", 0); | ||
var itemClass4 = dataSet.CreateItemClass("Item class 4", 0); | ||
ItemClassToAdd = itemClass3; | ||
AvailableDataSets = new[] { dataSet }; | ||
AvailableWeights = new[] { weights }; | ||
ItemClasses = new[] { itemClass1, itemClass2 }; | ||
AvailableItemClasses = new[] { itemClass3, itemClass4 }; | ||
Weights = weights; | ||
DataSet = dataSet; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Editor/ProfileEditorViewModel.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,28 @@ | ||
using System.Collections.Generic; | ||
using System.Windows.Input; | ||
using SightKeeper.Domain.Model; | ||
using SightKeeper.Domain.Model.Common; | ||
|
||
namespace SightKeeper.Avalonia.ViewModels.Tabs.Profiles.Editor; | ||
|
||
public interface ProfileEditorViewModel | ||
{ | ||
IReadOnlyCollection<DataSet> AvailableDataSets { get; } | ||
IReadOnlyCollection<Weights> AvailableWeights { get; } | ||
IReadOnlyCollection<ItemClass> AvailableItemClasses { get; } | ||
|
||
string Name { get; set; } | ||
string Description { get; set; } | ||
float DetectionThreshold { get; set; } | ||
float MouseSensitivity { get; set; } | ||
DataSet? DataSet { get; set; } | ||
Weights? Weights { get; set; } | ||
IReadOnlyList<ItemClass> ItemClasses { get; } | ||
ItemClass? ItemClassToAdd { get; set; } | ||
|
||
ICommand AddItemClassCommand { get; } | ||
ICommand RemoveItemClassCommand { get; } | ||
ICommand MoveItemClassUpCommand { get; } | ||
ICommand MoveItemClassDownCommand { get; } | ||
ICommand ApplyCommand { get; } | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
104 changes: 104 additions & 0 deletions
104
SightKeeper.Avalonia/Views/Profiles/ProfileEditor.axaml
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,104 @@ | ||
<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:profilesEditorViewModels="clr-namespace:SightKeeper.Avalonia.ViewModels.Tabs.Profiles.Editor" | ||
xmlns:icons="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" | ||
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="450" | ||
x:Class="SightKeeper.Avalonia.Views.ProfileEditor" | ||
x:DataType="profilesEditorViewModels:ProfileEditorViewModel"> | ||
<Design.DataContext> | ||
<profilesEditorViewModels:FakeProfileEditorViewModel/> | ||
</Design.DataContext> | ||
<UserControl.Styles> | ||
<Style Selector="Slider"> | ||
<Setter Property="TickPlacement" Value="Outside"/> | ||
<Setter Property="IsSnapToTickEnabled" Value="True"/> | ||
<Setter Property="TickFrequency" Value="0.1"/> | ||
<Setter Property="Minimum" Value="0.1"/> | ||
</Style> | ||
<Style Selector="NumericUpDown"> | ||
<Setter Property="MinWidth" Value="130"/> | ||
<Setter Property="FormatString" Value="P0"/> | ||
<Setter Property="Increment" Value="0.1"/> | ||
<Setter Property="Minimum" Value="0.1"/> | ||
<Setter Property="VerticalAlignment" Value="Center"/> | ||
</Style> | ||
</UserControl.Styles> | ||
<Grid RowDefinitions="* Auto"> | ||
<StackPanel Grid.Row="0" Name="Root"> | ||
<TextBox Text="{Binding Name}" | ||
Watermark="Name"/> | ||
<ComboBox ItemsSource="{Binding AvailableDataSets}" | ||
SelectedItem="{Binding DataSet}" | ||
PlaceholderText="Dataset"/> | ||
<ComboBox ItemsSource="{Binding AvailableWeights}" | ||
SelectedItem="{Binding Weights}" | ||
PlaceholderText="Weights"/> | ||
<Grid ColumnDefinitions="Auto *"> | ||
<NumericUpDown Grid.Column="0" | ||
Watermark="Detection threshold" | ||
Value="{Binding DetectionThreshold}" | ||
Maximum="0.9"/> | ||
<Slider Grid.Column="1" | ||
Maximum="0.9" | ||
Value="{Binding DetectionThreshold}"/> | ||
</Grid> | ||
<Grid ColumnDefinitions="Auto *"> | ||
<NumericUpDown Grid.Column="0" | ||
Watermark="Mouse sensitivity" | ||
Value="{Binding MouseSensitivity}" | ||
Maximum="5"/> | ||
<Slider Grid.Column="1" | ||
Maximum="5" | ||
Value="{Binding MouseSensitivity}"/> | ||
</Grid> | ||
<StackPanel Orientation="Horizontal"> | ||
<ComboBox ItemsSource="{Binding AvailableItemClasses}" | ||
SelectedItem="{Binding ItemClassToAdd}"/> | ||
<Button Content="{icons:MaterialIconExt Plus}" | ||
Command="{Binding AddItemClassCommand}"/> | ||
</StackPanel> | ||
<ItemsControl ItemsSource="{Binding ItemClasses}"> | ||
<ItemsControl.ItemTemplate> | ||
<DataTemplate> | ||
<Border BorderBrush="Gray" | ||
BorderThickness="1" | ||
CornerRadius="5" | ||
Margin="5" | ||
Padding="5"> | ||
<Grid RowDefinitions="* *" | ||
ColumnDefinitions="Auto * Auto"> | ||
<Button Grid.Row="0" Grid.Column="0" | ||
Content="{icons:MaterialIconExt ChevronUp}" | ||
Padding="5 0" | ||
Command="{Binding #Root.((profilesEditorViewModels:ProfileEditorViewModel)DataContext).MoveItemClassUpCommand}" | ||
CommandParameter="{Binding}"/> | ||
<Button Grid.Row="1" Grid.Column="0" | ||
Content="{icons:MaterialIconExt ChevronDown}" | ||
Padding="5 0" | ||
Command="{Binding #Root.((profilesEditorViewModels:ProfileEditorViewModel)DataContext).MoveItemClassDownCommand}" | ||
CommandParameter="{Binding}"/> | ||
<TextBlock Grid.Row="0" Grid.RowSpan="2" | ||
Grid.Column="1" | ||
Text="{Binding Name}" | ||
VerticalAlignment="Center" | ||
Margin="5 0 0 0"/> | ||
<Button Grid.Row="0" Grid.RowSpan="2" | ||
Grid.Column="2" | ||
Content="{icons:MaterialIconExt Close}" | ||
Command="{Binding #Root.((profilesEditorViewModels:ProfileEditorViewModel)DataContext).RemoveItemClassCommand}" | ||
CommandParameter="{Binding}"/> | ||
</Grid> | ||
</Border> | ||
</DataTemplate> | ||
</ItemsControl.ItemTemplate> | ||
</ItemsControl> | ||
</StackPanel> | ||
<Button Grid.Row="1" | ||
Content="Apply" | ||
Command="{Binding ApplyCommand}" | ||
HorizontalAlignment="Right" | ||
Margin="5"/> | ||
</Grid> | ||
</UserControl> |
17 changes: 17 additions & 0 deletions
17
SightKeeper.Avalonia/Views/Profiles/ProfileEditor.axaml.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 Avalonia.Controls; | ||
using Avalonia.Markup.Xaml; | ||
|
||
namespace SightKeeper.Avalonia.Views; | ||
|
||
public partial class ProfileEditor : UserControl | ||
{ | ||
public ProfileEditor() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void InitializeComponent() | ||
{ | ||
AvaloniaXamlLoader.Load(this); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.