2025-04-03 10:21:57 +01:00
|
|
|
|
using TRX_ConfigToolLib.Models.Lang;
|
|
|
|
|
using TRX_ConfigToolLib.Utils;
|
2024-11-16 15:56:54 +00:00
|
|
|
|
|
2025-04-03 10:21:57 +01:00
|
|
|
|
namespace TRX_ConfigToolLib.Models.Specification;
|
2024-10-02 10:23:19 +02:00
|
|
|
|
|
|
|
|
|
public abstract class BaseProperty : BaseNotifyPropertyChanged
|
|
|
|
|
{
|
2024-11-09 17:17:15 +00:00
|
|
|
|
private static readonly object _nullValue = new();
|
|
|
|
|
|
2024-10-02 10:23:19 +02:00
|
|
|
|
public string Field { get; set; }
|
|
|
|
|
|
|
|
|
|
public string Title
|
|
|
|
|
{
|
|
|
|
|
get => Language.Instance.Properties[Field].Title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Description
|
|
|
|
|
{
|
|
|
|
|
get => Language.Instance.Properties[Field].Description;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-16 15:56:54 +00:00
|
|
|
|
public string NormalisedText { get; private set; }
|
|
|
|
|
|
2024-10-02 10:23:19 +02:00
|
|
|
|
public abstract object ExportValue();
|
|
|
|
|
public abstract void LoadValue(string value);
|
|
|
|
|
public abstract void SetToDefault();
|
|
|
|
|
public abstract bool IsDefault { get; }
|
|
|
|
|
|
2024-11-09 17:17:15 +00:00
|
|
|
|
private object _enforcedValue = _nullValue;
|
|
|
|
|
public object EnforcedValue
|
|
|
|
|
{
|
|
|
|
|
get => _enforcedValue;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_enforcedValue != value)
|
|
|
|
|
{
|
|
|
|
|
_enforcedValue = value;
|
|
|
|
|
NotifyPropertyChanged();
|
|
|
|
|
NotifyPropertyChanged(nameof(IsEnabled));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsEnabled => _enforcedValue == _nullValue;
|
|
|
|
|
|
2024-10-02 10:23:19 +02:00
|
|
|
|
public virtual void Initialise(Specification specification)
|
|
|
|
|
{
|
|
|
|
|
SetToDefault();
|
2024-11-16 15:56:54 +00:00
|
|
|
|
|
|
|
|
|
string text = (Title + " " + Description).ToLower();
|
|
|
|
|
NormalisedText = TextUtilities.Normalise(text);
|
2024-10-02 10:23:19 +02:00
|
|
|
|
}
|
|
|
|
|
}
|