mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-05 04:07:21 +00:00
Added a setting to change the size of the interface (#1136)
Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
1 parent
c2b62c6dbd
commit
e0337a99bc
27 files changed
+1742
-27
No files matched your search
@@ -1,3 +1,4 @@
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
@@ -42,6 +43,22 @@ public partial class ConfigurationSlider<T> : ConfigurationBaseCore where T : st
|
||||
[Parameter]
|
||||
public Action<T> ValueUpdate { get; set; } = _ => { };
|
||||
|
||||
/// <summary>
|
||||
/// Whether the option changes while the user drags the slider, or only once they release it.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Defaults to true. An option which changes the layout of the page, such as the interface size,
|
||||
/// should wait for the release: a page which changes under the pointer moves the slider away from
|
||||
/// it. The slider shows the value it is dragged to either way.
|
||||
/// </remarks>
|
||||
[Parameter]
|
||||
public bool Immediate { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// The value the user drags the slider to, while the option waits for the release, see Immediate.
|
||||
/// </summary>
|
||||
private T? draggedValue;
|
||||
|
||||
#region Overrides of ConfigurationBase
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -72,10 +89,24 @@ public partial class ConfigurationSlider<T> : ConfigurationBaseCore where T : st
|
||||
|
||||
private async Task OptionChanged(T updatedValue)
|
||||
{
|
||||
this.draggedValue = null;
|
||||
this.ValueUpdate(updatedValue);
|
||||
await this.SettingsManager.StoreSettings();
|
||||
await this.InformAboutChange();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the value the user drags the slider to, while the option waits for the release.
|
||||
/// </summary>
|
||||
private void ShowDraggedValue(ChangeEventArgs args)
|
||||
{
|
||||
if (this.Immediate)
|
||||
return;
|
||||
|
||||
// The range input reports its value with a dot as decimal separator, whatever the language:
|
||||
if (T.TryParse(args.Value?.ToString(), CultureInfo.InvariantCulture, out var value))
|
||||
this.draggedValue = value;
|
||||
}
|
||||
|
||||
private async Task EnsureMinMax()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user