149 lines
4.2 KiB
C#
149 lines
4.2 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Threading.Tasks;
|
|
using WebWindowComplex.Models;
|
|
using static WebWindowComplex.Json.WindowConst;
|
|
|
|
namespace WebWindowComplex.Compo
|
|
{
|
|
public partial class AreaHwOption
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Sash corrente rispetto alla lista Sash
|
|
/// </summary>
|
|
[CascadingParameter(Name = "CurrSashGroup")]
|
|
public Sash CurrSashGroup { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Vocabolario con traduzione lingua corrente
|
|
/// </summary>
|
|
[CascadingParameter(Name = "Vocabulary")]
|
|
public Dictionary<string, string> Vocabulary { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Evento per aggiornare gli hardware option
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<DataUpdateHwOption> EC_UpdateHwOpt { get; set; }
|
|
|
|
/// <summary>
|
|
/// Evento per chiamare la prima volta la lista delle opzioni
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<int> EC_FirstHwOptionList { get; set; }
|
|
|
|
[CascadingParameter(Name = "IsLoading")]
|
|
public List<string> IsLoading { get; set; } = new List<string>();
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
HwOptDict = Vocabulary.Where(x => x.Key.Contains("CWHwOpt_")).ToDictionary(x => x.Key, y => y.Value);
|
|
}
|
|
|
|
protected override void OnAfterRender(bool firstRender)
|
|
{
|
|
if (firstRender)
|
|
{
|
|
hwOptCollapsed = true;
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private Dictionary<string, string> HwOptDict = new();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private bool hwOptCollapsed { get; set; } = true;
|
|
private bool IsLoadingHwOpt
|
|
{
|
|
get => IsLoading != null && IsLoading.Count > 0 && IsLoading.Contains("LoadHwOpt");
|
|
}
|
|
|
|
private string hwIcon
|
|
{
|
|
get => hwOptCollapsed ? "fa-solid fa-chevron-down" : "fa-solid fa-chevron-up";
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// Metodo per aprire/chiudere area per hw option
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task changeCollapsed()
|
|
{
|
|
hwOptCollapsed = !hwOptCollapsed;
|
|
if (CurrSashGroup.HwOptionList.Count == 0)
|
|
{
|
|
await EC_FirstHwOptionList.InvokeAsync();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Report aggiornamento Option Combo
|
|
/// </summary>
|
|
/// <param name="updRec"></param>
|
|
/// <returns></returns>
|
|
private Task RaiseOptCombo(AGBOptionCombo updRec)
|
|
{
|
|
var args = new DataUpdateHwOption
|
|
{
|
|
AGBOptCombo = updRec
|
|
};
|
|
return EC_UpdateHwOpt.InvokeAsync(args);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Report aggiornamento Option Text
|
|
/// </summary>
|
|
/// <param name="updRec"></param>
|
|
/// <returns></returns>
|
|
private Task RaiseOptText(AGBOptionText updRec)
|
|
{
|
|
var args = new DataUpdateHwOption
|
|
{
|
|
AGBOptText = updRec
|
|
};
|
|
return EC_UpdateHwOpt.InvokeAsync(args);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per traduzione in lingua corrente
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
private string Traduci(string lemma)
|
|
{
|
|
string ans = lemma;
|
|
if (HwOptDict != null && HwOptDict.ContainsKey(lemma))
|
|
{
|
|
ans = HwOptDict.GetValueOrDefault(lemma) ?? "";
|
|
}
|
|
return ans;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
|
|
/// <summary>
|
|
/// Classe per oggetto di aggiornamento delle opzioni
|
|
/// </summary>
|
|
public class DataUpdateHwOption
|
|
{
|
|
public AGBOptionText AGBOptText { get; set; } = null!;
|
|
public AGBOptionCombo AGBOptCombo { get; set; } = null!;
|
|
}
|
|
} |