Initial setup of the models and view models

This commit is contained in:
Robert committed 2026-01-23 21:15:58 +01:00
1 parent 46511022d6
commit 3004293051
38 files changed
+807 -61

No files matched your search

@@ -0,0 +1,25 @@
namespace Artemis.Core;
/// <summary>
/// Represents a configuration item that accepts boolean input from the user.
/// </summary>
public class ConfigurationBooleanItem : ConfigurationInputItem<bool>
{
/// <summary>
/// Gets or sets the display text shown when the boolean value is true.
/// </summary>
public required string TrueText
{
get;
set => SetAndNotify(ref field, value);
}
/// <summary>
/// Gets or sets the display text shown when the boolean value is false.
/// </summary>
public required string FalseText
{
get;
set => SetAndNotify(ref field, value);
}
}
@@ -0,0 +1,26 @@
namespace Artemis.Core;
/// <summary>
/// Represents a single option in a configuration dropdown list.
/// </summary>
/// <typeparam name="T">The type of the value that this dropdown option represents.</typeparam>
public class ConfigurationDropdownValue<T> : CorePropertyChanged
{
/// <summary>
/// Gets or sets the display name shown to the user for this dropdown option.
/// </summary>
public required string DisplayName
{
get;
set => SetAndNotify(ref field, value);
}
/// <summary>
/// Gets or sets the actual value associated with this dropdown option.
/// </summary>
public required T Value
{
get;
set => SetAndNotify(ref field, value);
}
}
@@ -0,0 +1,53 @@
using System.Collections.ObjectModel;
namespace Artemis.Core;
/// <summary>
/// Represents a generic base class for configuration items that accept user input.
/// </summary>
/// <typeparam name="T">The type of the value that this configuration item holds.</typeparam>
public class ConfigurationInputItem<T> : CorePropertyChanged, IConfigurationItem
{
/// <summary>
/// Gets or sets the display name of the configuration item.
/// </summary>
public required string Name
{
get;
set => SetAndNotify(ref field, value);
}
/// <summary>
/// Gets or sets the description text that explains the purpose of this configuration item.
/// </summary>
public string? Description
{
get;
set => SetAndNotify(ref field, value);
}
/// <summary>
/// Gets or sets the current value of the configuration item.
/// </summary>
public T? Value
{
get;
set => SetAndNotify(ref field, value);
}
/// <summary>
/// Gets or sets the collection of dropdown values for this configuration item.
/// When populated, the configuration item will be rendered as a dropdown/combo box.
/// </summary>
public ObservableCollection<ConfigurationDropdownValue<T>>? DropdownValues
{
get;
set
{
if (Equals(value, field))
return;
field = value;
OnPropertyChanged();
}
} = [];
}
@@ -0,0 +1,8 @@
namespace Artemis.Core;
/// <summary>
/// Represents a configuration item that accepts numeric input from the user.
/// </summary>
public class ConfigurationNumericItem : ConfigurationInputItem<Numeric>
{
}
@@ -0,0 +1,10 @@
using SkiaSharp;
namespace Artemis.Core;
/// <summary>
/// Represents a configuration item that accepts SKColor input from the user.
/// </summary>
public class ConfigurationSKColorItem : ConfigurationInputItem<SKColor>
{
}
@@ -0,0 +1,32 @@
using System.Collections.ObjectModel;
namespace Artemis.Core;
/// <summary>
/// Represents a configuration section that contains a collection of configuration items.
/// </summary>
public class ConfigurationSection : CorePropertyChanged
{
/// <summary>
/// Gets or sets the name of the configuration section.
/// </summary>
public required string Name
{
get;
set => SetAndNotify(ref field, value);
}
/// <summary>
/// Gets or sets the slot number of the configuration section.
/// </summary>
public int Slot
{
get;
set => SetAndNotify(ref field, value);
}
/// <summary>
/// Gets the collection of configuration items in this section.
/// </summary>
public ObservableCollection<IConfigurationItem> Items { get; } = [];
}
@@ -0,0 +1,8 @@
namespace Artemis.Core;
/// <summary>
/// Represents a configuration item that accepts string input from the user.
/// </summary>
public class ConfigurationStringItem : ConfigurationInputItem<string>
{
}
@@ -0,0 +1,16 @@
namespace Artemis.Core;
/// <summary>
/// Represents a configuration item that displays static text.
/// </summary>
public class ConfigurationTextItem : CorePropertyChanged, IConfigurationItem
{
/// <summary>
/// Gets or sets the text content to display.
/// </summary>
public required string Text
{
get;
set => SetAndNotify(ref field, value);
}
}
@@ -0,0 +1,8 @@
namespace Artemis.Core;
/// <summary>
/// Defines a contract for configuration items that can be added to a configuration section.
/// </summary>
public interface IConfigurationItem
{
}
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Artemis.Core.Modules;
using Artemis.Storage.Entities.Profile;
@@ -16,26 +17,12 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
/// </summary>
public static readonly ProfileConfiguration Empty = new(ProfileCategory.Empty, "Empty", "Empty");
private ActivationBehaviour _activationBehaviour;
private bool _activationConditionMet;
private ProfileCategory _category;
private Hotkey? _disableHotkey;
private bool _disposed;
private Hotkey? _enableHotkey;
private ProfileConfigurationHotkeyMode _hotkeyMode;
private bool _isMissingModule;
private bool _isSuspended;
private bool _fadeInAndOut;
private Module? _module;
private string _name;
private int _order;
private Profile? _profile;
internal ProfileConfiguration(ProfileCategory category, string name, string icon)
{
_name = name;
_category = category;
Name = name;
Category = category;
Entity = new ProfileContainerEntity();
Icon = new ProfileConfigurationIcon(Entity);
@@ -49,8 +36,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
internal ProfileConfiguration(ProfileCategory category, ProfileContainerEntity entity)
{
// Will be loaded from the entity
_name = null!;
_category = category;
Name = null!;
Category = category;
Entity = entity;
Icon = new ProfileConfigurationIcon(Entity);
@@ -64,8 +51,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
/// </summary>
public string Name
{
get => _name;
set => SetAndNotify(ref _name, value);
get;
set => SetAndNotify(ref field, value);
}
/// <summary>
@@ -73,8 +60,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
/// </summary>
public int Order
{
get => _order;
set => SetAndNotify(ref _order, value);
get;
set => SetAndNotify(ref field, value);
}
/// <summary>
@@ -83,8 +70,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
/// </summary>
public bool IsSuspended
{
get => _isSuspended;
set => SetAndNotify(ref _isSuspended, value);
get;
set => SetAndNotify(ref field, value);
}
/// <summary>
@@ -92,8 +79,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
/// </summary>
public bool IsMissingModule
{
get => _isMissingModule;
private set => SetAndNotify(ref _isMissingModule, value);
get;
private set => SetAndNotify(ref field, value);
}
/// <summary>
@@ -101,8 +88,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
/// </summary>
public ProfileCategory Category
{
get => _category;
internal set => SetAndNotify(ref _category, value);
get;
internal set => SetAndNotify(ref field, value);
}
/// <summary>
@@ -110,8 +97,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
/// </summary>
public ProfileConfigurationHotkeyMode HotkeyMode
{
get => _hotkeyMode;
set => SetAndNotify(ref _hotkeyMode, value);
get;
set => SetAndNotify(ref field, value);
}
/// <summary>
@@ -119,8 +106,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
/// </summary>
public Hotkey? EnableHotkey
{
get => _enableHotkey;
set => SetAndNotify(ref _enableHotkey, value);
get;
set => SetAndNotify(ref field, value);
}
/// <summary>
@@ -128,8 +115,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
/// </summary>
public Hotkey? DisableHotkey
{
get => _disableHotkey;
set => SetAndNotify(ref _disableHotkey, value);
get;
set => SetAndNotify(ref field, value);
}
/// <summary>
@@ -137,8 +124,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
/// </summary>
public ActivationBehaviour ActivationBehaviour
{
get => _activationBehaviour;
set => SetAndNotify(ref _activationBehaviour, value);
get;
set => SetAndNotify(ref field, value);
}
/// <summary>
@@ -146,8 +133,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
/// </summary>
public bool ActivationConditionMet
{
get => _activationConditionMet;
private set => SetAndNotify(ref _activationConditionMet, value);
get;
private set => SetAndNotify(ref field, value);
}
/// <summary>
@@ -155,8 +142,8 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
/// </summary>
public Profile? Profile
{
get => _profile;
internal set => SetAndNotify(ref _profile, value);
get;
internal set => SetAndNotify(ref field, value);
}
/// <summary>
@@ -164,8 +151,17 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
/// </summary>
public bool FadeInAndOut
{
get => _fadeInAndOut;
set => SetAndNotify(ref _fadeInAndOut, value);
get;
set => SetAndNotify(ref field, value);
}
/// <summary>
/// Gets or sets a boolean indicating whether this profile is configurable via its <see cref="ConfigurationSections"/>.
/// </summary>
public bool IsConfigurable
{
get;
set => SetAndNotify(ref field, value);
}
/// <summary>
@@ -173,14 +169,19 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
/// </summary>
public Module? Module
{
get => _module;
get;
set
{
SetAndNotify(ref _module, value);
SetAndNotify(ref field, value);
IsMissingModule = false;
}
}
/// <summary>
/// Gets the configuration sections of this profile configuration.
/// </summary>
public ObservableCollection<ConfigurationSection> ConfigurationSections { get; } = [];
/// <summary>
/// Gets the icon configuration
/// </summary>
@@ -301,6 +302,30 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
EnableHotkey = Entity.ProfileConfiguration.EnableHotkey != null ? new Hotkey(Entity.ProfileConfiguration.EnableHotkey) : null;
DisableHotkey = Entity.ProfileConfiguration.DisableHotkey != null ? new Hotkey(Entity.ProfileConfiguration.DisableHotkey) : null;
// Placeholder configuration sections
ConfigurationSections.Clear();
ConfigurationSections.Add(new ConfigurationSection()
{
Name = "General (slot 0)",
Slot = 0,
});
ConfigurationSections.Add(new ConfigurationSection()
{
Name = "Other (slot 1)",
Slot = 1
});
ConfigurationSections.Add(new ConfigurationSection()
{
Name = "Something else (slot 2)",
Slot = 2
});
ConfigurationSections[0].Items.Add(new ConfigurationTextItem() {Text = "This is a placeholder text item in the General section."});
ConfigurationSections[0].Items.Add(new ConfigurationNumericItem() {Name = "Numeric item"});
ConfigurationSections[0].Items.Add(new ConfigurationBooleanItem() {Name = "Do the thing?", TrueText = "Absolutely", FalseText = "Nope"});
ConfigurationSections[1].Items.Add(new ConfigurationTextItem() {Text = "This is a placeholder text item in the Other section."});
ConfigurationSections[2].Items.Add(new ConfigurationTextItem() {Text = "This is a placeholder text item in the Something else section."});
ConfigurationSections[2].Items.Add(new ConfigurationTextItem() {Text = "This is another placeholder text item in the Something else section."});
}
/// <inheritdoc />
@@ -24,6 +24,9 @@ internal class InputService : IInputService
_deviceService.DeviceRemoved += DeviceServiceOnDevicesModified;
BustIdentifierCache();
}
public int CursorX { get; private set; }
public int CursorY { get; private set; }
protected virtual void OnKeyboardKeyUpDown(ArtemisKeyboardKeyUpDownEventArgs e)
{
@@ -426,6 +429,9 @@ internal class InputService : IInputService
private void InputProviderOnMouseMoveDataReceived(object? sender, InputProviderMouseMoveEventArgs e)
{
CursorX = e.CursorX;
CursorY = e.CursorY;
OnMouseMove(new ArtemisMouseMoveEventArgs(e.Device, e.CursorX, e.CursorY, e.DeltaX, e.DeltaY));
// _logger.Verbose("Mouse move data: XY: {X},{Y} - delta XY: {deltaX},{deltaY} - device: {device} ", e.CursorX, e.CursorY, e.DeltaX, e.DeltaY, e.Device);
}
@@ -12,6 +12,16 @@ public interface IInputService : IArtemisService, IDisposable
/// </summary>
KeyboardToggleStatus KeyboardToggleStatus { get; }
/// <summary>
/// Gets the last reported cursor X position
/// </summary>
public int CursorX { get; }
/// <summary>
/// Gets the last reported cursor Y position
/// </summary>
public int CursorY { get; }
/// <summary>
/// Adds an input provided
/// </summary>