mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 22:39:47 +00:00
Fixed min/max handling
This commit is contained in:
parent
eb884e2107
commit
7e49c3c68c
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user