Fixed min/max handling

This commit is contained in:
Thorsten Sommer 2024-08-05 20:43:12 +02:00
parent eb884e2107
commit 7e49c3c68c
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -42,10 +42,35 @@ public partial class ConfigurationSlider<T> : ConfigurationBase where T : struct
[Parameter] [Parameter]
public Action<T> ValueUpdate { get; set; } = _ => { }; public Action<T> ValueUpdate { get; set; } = _ => { };
#region Overrides of ComponentBase
protected override async Task OnInitializedAsync()
{
await this.EnsureMinMax();
await base.OnInitializedAsync();
}
protected override async Task OnParametersSetAsync()
{
await this.EnsureMinMax();
await base.OnParametersSetAsync();
}
#endregion
private async Task OptionChanged(T updatedValue) private async Task OptionChanged(T updatedValue)
{ {
this.ValueUpdate(updatedValue); this.ValueUpdate(updatedValue);
await this.SettingsManager.StoreSettings(); await this.SettingsManager.StoreSettings();
await this.InformAboutChange(); await this.InformAboutChange();
} }
private async Task EnsureMinMax()
{
if (this.Value() < this.Min)
await this.OptionChanged(this.Min);
else if(this.Value() > this.Max)
await this.OptionChanged(this.Max);
}
} }