TRX/tools/config/TRX_ConfigToolLib/Models/Specification/BaseProperty.cs
lahm86 c0583e193a tools/config: disable editing of enforced properties
This makes enforced properties read-only inside the config tool, and
adds a banner to the top of the main window to inform the user why some
settings cannot be changed.
2024-11-10 17:13:33 +00:00

45 lines
1.1 KiB
C#

namespace TRX_ConfigToolLib.Models;
public abstract class BaseProperty : BaseNotifyPropertyChanged
{
private static readonly object _nullValue = new();
public string Field { get; set; }
public string Title
{
get => Language.Instance.Properties[Field].Title;
}
public string Description
{
get => Language.Instance.Properties[Field].Description;
}
public abstract object ExportValue();
public abstract void LoadValue(string value);
public abstract void SetToDefault();
public abstract bool IsDefault { get; }
private object _enforcedValue = _nullValue;
public object EnforcedValue
{
get => _enforcedValue;
set
{
if (_enforcedValue != value)
{
_enforcedValue = value;
NotifyPropertyChanged();
NotifyPropertyChanged(nameof(IsEnabled));
}
}
}
public bool IsEnabled => _enforcedValue == _nullValue;
public virtual void Initialise(Specification specification)
{
SetToDefault();
}
}