From 7a8583cb813bedb54791812ec0d0055b2b7bbf7f Mon Sep 17 00:00:00 2001 From: KatterMaw Date: Sun, 17 Sep 2023 19:32:26 +0500 Subject: [PATCH] Implement ProfileEditor view and VM stuff for that (just without implementations for ProfileEditorViewModel, interface and fake only) --- .../SightKeeper.Avalonia.csproj | 4 + .../SightKeeper.Avalonia.csproj.DotSettings | 4 +- .../Editor/FakeProfileEditorViewModel.cs | 47 ++++++++ .../Profiles/Editor/ProfileEditorViewModel.cs | 28 +++++ .../{ => Tab}/FakeProfilesViewModel.cs | 0 .../Profiles/{ => Tab}/IProfilesViewModel.cs | 0 .../Profiles/{ => Tab}/ProfileViewModel.cs | 0 .../{ => Tab}/ProfilesListViewModel.cs | 0 .../Profiles/{ => Tab}/ProfilesViewModel.cs | 0 .../Views/Profiles/ProfileEditor.axaml | 104 ++++++++++++++++++ .../Views/Profiles/ProfileEditor.axaml.cs | 17 +++ .../{Tabs => Profiles}/ProfilesTab.axaml | 0 .../{Tabs => Profiles}/ProfilesTab.axaml.cs | 0 13 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Editor/FakeProfileEditorViewModel.cs create mode 100644 SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Editor/ProfileEditorViewModel.cs rename SightKeeper.Avalonia/ViewModels/Tabs/Profiles/{ => Tab}/FakeProfilesViewModel.cs (100%) rename SightKeeper.Avalonia/ViewModels/Tabs/Profiles/{ => Tab}/IProfilesViewModel.cs (100%) rename SightKeeper.Avalonia/ViewModels/Tabs/Profiles/{ => Tab}/ProfileViewModel.cs (100%) rename SightKeeper.Avalonia/ViewModels/Tabs/Profiles/{ => Tab}/ProfilesListViewModel.cs (100%) rename SightKeeper.Avalonia/ViewModels/Tabs/Profiles/{ => Tab}/ProfilesViewModel.cs (100%) create mode 100644 SightKeeper.Avalonia/Views/Profiles/ProfileEditor.axaml create mode 100644 SightKeeper.Avalonia/Views/Profiles/ProfileEditor.axaml.cs rename SightKeeper.Avalonia/Views/{Tabs => Profiles}/ProfilesTab.axaml (100%) rename SightKeeper.Avalonia/Views/{Tabs => Profiles}/ProfilesTab.axaml.cs (100%) diff --git a/SightKeeper.Avalonia/SightKeeper.Avalonia.csproj b/SightKeeper.Avalonia/SightKeeper.Avalonia.csproj index 94b0c338..a166e863 100644 --- a/SightKeeper.Avalonia/SightKeeper.Avalonia.csproj +++ b/SightKeeper.Avalonia/SightKeeper.Avalonia.csproj @@ -54,5 +54,9 @@ DetectorItem.axaml Code + + ProfilesTab.axaml + Code + diff --git a/SightKeeper.Avalonia/SightKeeper.Avalonia.csproj.DotSettings b/SightKeeper.Avalonia/SightKeeper.Avalonia.csproj.DotSettings index f41b9138..7af62314 100644 --- a/SightKeeper.Avalonia/SightKeeper.Avalonia.csproj.DotSettings +++ b/SightKeeper.Avalonia/SightKeeper.Avalonia.csproj.DotSettings @@ -4,4 +4,6 @@ True True True - True \ No newline at end of file + True + True + True \ No newline at end of file diff --git a/SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Editor/FakeProfileEditorViewModel.cs b/SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Editor/FakeProfileEditorViewModel.cs new file mode 100644 index 00000000..d681b963 --- /dev/null +++ b/SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Editor/FakeProfileEditorViewModel.cs @@ -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 AvailableDataSets { get; } + public IReadOnlyCollection AvailableWeights { get; } + public IReadOnlyCollection 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 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(), Array.Empty(), ModelSize.Nano, 100, 1.1f, 1.0f, + 0.9f, Enumerable.Empty()); + 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; + } +} \ No newline at end of file diff --git a/SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Editor/ProfileEditorViewModel.cs b/SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Editor/ProfileEditorViewModel.cs new file mode 100644 index 00000000..3ca07c34 --- /dev/null +++ b/SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Editor/ProfileEditorViewModel.cs @@ -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 AvailableDataSets { get; } + IReadOnlyCollection AvailableWeights { get; } + IReadOnlyCollection 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 ItemClasses { get; } + ItemClass? ItemClassToAdd { get; set; } + + ICommand AddItemClassCommand { get; } + ICommand RemoveItemClassCommand { get; } + ICommand MoveItemClassUpCommand { get; } + ICommand MoveItemClassDownCommand { get; } + ICommand ApplyCommand { get; } +} \ No newline at end of file diff --git a/SightKeeper.Avalonia/ViewModels/Tabs/Profiles/FakeProfilesViewModel.cs b/SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Tab/FakeProfilesViewModel.cs similarity index 100% rename from SightKeeper.Avalonia/ViewModels/Tabs/Profiles/FakeProfilesViewModel.cs rename to SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Tab/FakeProfilesViewModel.cs diff --git a/SightKeeper.Avalonia/ViewModels/Tabs/Profiles/IProfilesViewModel.cs b/SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Tab/IProfilesViewModel.cs similarity index 100% rename from SightKeeper.Avalonia/ViewModels/Tabs/Profiles/IProfilesViewModel.cs rename to SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Tab/IProfilesViewModel.cs diff --git a/SightKeeper.Avalonia/ViewModels/Tabs/Profiles/ProfileViewModel.cs b/SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Tab/ProfileViewModel.cs similarity index 100% rename from SightKeeper.Avalonia/ViewModels/Tabs/Profiles/ProfileViewModel.cs rename to SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Tab/ProfileViewModel.cs diff --git a/SightKeeper.Avalonia/ViewModels/Tabs/Profiles/ProfilesListViewModel.cs b/SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Tab/ProfilesListViewModel.cs similarity index 100% rename from SightKeeper.Avalonia/ViewModels/Tabs/Profiles/ProfilesListViewModel.cs rename to SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Tab/ProfilesListViewModel.cs diff --git a/SightKeeper.Avalonia/ViewModels/Tabs/Profiles/ProfilesViewModel.cs b/SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Tab/ProfilesViewModel.cs similarity index 100% rename from SightKeeper.Avalonia/ViewModels/Tabs/Profiles/ProfilesViewModel.cs rename to SightKeeper.Avalonia/ViewModels/Tabs/Profiles/Tab/ProfilesViewModel.cs diff --git a/SightKeeper.Avalonia/Views/Profiles/ProfileEditor.axaml b/SightKeeper.Avalonia/Views/Profiles/ProfileEditor.axaml new file mode 100644 index 00000000..426897e1 --- /dev/null +++ b/SightKeeper.Avalonia/Views/Profiles/ProfileEditor.axaml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + +