Core - Added missing property changed calls in ProfileConfiguration

Sidebar - Added suspended status indicators
This commit is contained in:
Robert committed 2022-07-31 21:24:02 +02:00
1 parent 7667cc5473
commit 5873df250d
9 files changed
+518 -130

No files matched your search

+3 -3
View File
@@ -28,7 +28,7 @@ namespace Artemis.Core
/// <param name="value">Value to apply.</param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected virtual bool RequiresUpdate<T>(ref T storage, T value)
protected bool RequiresUpdate<T>(ref T storage, T value)
{
return !Equals(storage, value);
}
@@ -46,7 +46,7 @@ namespace Artemis.Core
/// </param>
/// <returns><c>true</c> if the value was changed, <c>false</c> if the existing value matched the desired value.</returns>
[NotifyPropertyChangedInvocator]
protected virtual bool SetAndNotify<T>(ref T storage, T value, [CallerMemberName] string? propertyName = null)
protected bool SetAndNotify<T>(ref T storage, T value, [CallerMemberName] string? propertyName = null)
{
if (!RequiresUpdate(ref storage, value)) return false;
@@ -64,7 +64,7 @@ namespace Artemis.Core
/// and can be provided automatically when invoked from compilers that support <see cref="CallerMemberNameAttribute" />
/// .
/// </param>
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
protected void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
@@ -11,15 +11,21 @@ namespace Artemis.Core
/// </summary>
public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable
{
private ProfileCategory _category;
private bool _disposed;
private bool _isMissingModule;
private bool _isSuspended;
private Module? _module;
private string _name;
private int _order;
private bool _isSuspended;
private bool _isMissingModule;
private ProfileCategory _category;
private ProfileConfigurationHotkeyMode _hotkeyMode;
private Hotkey? _enableHotkey;
private Hotkey? _disableHotkey;
private ActivationBehaviour _activationBehaviour;
private bool _activationConditionMet;
private bool _isBeingEdited;
private Profile? _profile;
private Module? _module;
internal ProfileConfiguration(ProfileCategory category, string name, string icon)
{
@@ -91,31 +97,60 @@ namespace Artemis.Core
internal set => SetAndNotify(ref _category, value);
}
/// <summary>
/// Gets the icon configuration
/// </summary>
public ProfileConfigurationIcon Icon { get; }
/// <summary>
/// Gets or sets the <see cref="ProfileConfigurationHotkeyMode" /> used to determine hotkey behaviour
/// </summary>
public ProfileConfigurationHotkeyMode HotkeyMode { get; set; }
public ProfileConfigurationHotkeyMode HotkeyMode
{
get => _hotkeyMode;
set => SetAndNotify(ref _hotkeyMode, value);
}
/// <summary>
/// Gets or sets the hotkey used to enable or toggle the profile
/// </summary>
public Hotkey? EnableHotkey { get; set; }
public Hotkey? EnableHotkey
{
get => _enableHotkey;
set => SetAndNotify(ref _enableHotkey, value);
}
/// <summary>
/// Gets or sets the hotkey used to disable the profile
/// </summary>
public Hotkey? DisableHotkey { get; set; }
public Hotkey? DisableHotkey
{
get => _disableHotkey;
set => SetAndNotify(ref _disableHotkey, value);
}
/// <summary>
/// Gets the ID of the profile of this profile configuration
/// Gets or sets the behaviour of when this profile is activated
/// </summary>
public Guid ProfileId => Entity.ProfileId;
public ActivationBehaviour ActivationBehaviour
{
get => _activationBehaviour;
set => SetAndNotify(ref _activationBehaviour, value);
}
/// <summary>
/// Gets a boolean indicating whether the activation conditions where met during the last <see cref="Update" /> call
/// </summary>
public bool ActivationConditionMet
{
get => _activationConditionMet;
private set => SetAndNotify(ref _activationConditionMet, value);
}
/// <summary>
/// Gets or sets a boolean indicating whether this profile configuration is being edited
/// </summary>
public bool IsBeingEdited
{
get => _isBeingEdited;
set => SetAndNotify(ref _isBeingEdited, value);
}
/// <summary>
/// Gets the profile of this profile configuration
/// </summary>
@@ -125,17 +160,6 @@ namespace Artemis.Core
internal set => SetAndNotify(ref _profile, value);
}
/// <summary>
/// Gets or sets the behaviour of when this profile is activated
/// </summary>
public ActivationBehaviour ActivationBehaviour { get; set; }
/// <summary>
/// Gets the data model condition that must evaluate to <see langword="true" /> for this profile to be activated
/// alongside any activation requirements of the <see cref="Module" />, if set
/// </summary>
public NodeScript<bool> ActivationCondition { get; }
/// <summary>
/// Gets or sets the module this profile uses
/// </summary>
@@ -144,25 +168,31 @@ namespace Artemis.Core
get => _module;
set
{
_module = value;
SetAndNotify(ref _module, value);
IsMissingModule = false;
}
}
/// <summary>
/// Gets a boolean indicating whether the activation conditions where met during the last <see cref="Update" /> call
/// Gets the icon configuration
/// </summary>
public bool ActivationConditionMet { get; private set; }
public ProfileConfigurationIcon Icon { get; }
/// <summary>
/// Gets or sets a boolean indicating whether this profile configuration is being edited
/// Gets the data model condition that must evaluate to <see langword="true" /> for this profile to be activated
/// alongside any activation requirements of the <see cref="Module" />, if set
/// </summary>
public bool IsBeingEdited { get; set; }
public NodeScript<bool> ActivationCondition { get; }
/// <summary>
/// Gets the entity used by this profile config
/// </summary>
public ProfileConfigurationEntity Entity { get; }
/// <summary>
/// Gets the ID of the profile of this profile configuration
/// </summary>
public Guid ProfileId => Entity.ProfileId;
/// <summary>
/// Updates this configurations activation condition status
@@ -243,7 +273,7 @@ namespace Artemis.Core
if (Entity.ActivationCondition != null)
ActivationCondition.LoadFromEntity(Entity.ActivationCondition);
EnableHotkey = Entity.EnableHotkey != null ? new Hotkey(Entity.EnableHotkey) : null;
DisableHotkey = Entity.DisableHotkey != null ? new Hotkey(Entity.DisableHotkey) : null;
}