Files
webwindowconfigurator/WebWindowComplex/Compo/CardFill.razor.cs
T
Annamaria Sassi fe0d52d46f Fix traduzioni
2026-08-14 16:48:47 +02:00

123 lines
3.6 KiB
C#

using Microsoft.AspNetCore.Components;
using WebWindowComplex.Models;
using static WebWindowComplex.Json.WindowConst;
namespace WebWindowComplex.Compo
{
public partial class CardFill
{
#region Public Properties
/// <summary>
/// Indice del fill corrente rispetto alla lista fill
/// </summary>
[Parameter]
public int CurrIndex { get; set; } = 0;
/// <summary>
/// Fill corrente rispetto alla lista fill
/// </summary>
[Parameter]
public Fill CurrFill { get; set; } = null!;
/// <summary>
/// Livello di accesso (utente base)
/// </summary>
[Parameter]
public bool BaseUser { get; set; } = false!;
/// <summary>
/// Vocabolario con traduzione lingua corrente
/// </summary>
[Parameter]
public Dictionary<string, string> Vocabulary { get; set; } = null!;
/// <summary>
/// Evento per cambiare tutti i fill
/// </summary>
[Parameter]
public EventCallback<Fill> EC_UpdateFill { get; set; }
/// <summary>
/// Evento per tornare nella pagine Tree
/// </summary>
[Parameter]
public EventCallback<bool> EC_ReqClose { get; set; }
/// <summary>
/// Evento per richiesta traduzione
/// </summary>
[Parameter]
public EventCallback<List<string>> EC_ReqTraduzione { get; set; }
#endregion Public Properties
#region Protected Properties
protected override async Task OnInitializedAsync()
{
Dictionary<string, string> FDict = Vocabulary.Where(x => x.Key.Contains("CWFill_")).ToDictionary(x => x.Key, y => y.Value);
if (FDict == null || FDict.Count != 3)
{
List<string> tradList = new List<string>() { "CWFill_Fill", "CWFill_Glass", "CWFill_Wood"};
await EC_ReqTraduzione.InvokeAsync(tradList);
}
}
protected override void OnParametersSet()
{
FillDict = Vocabulary.Where(x => x.Key.Contains("CWFill_")).ToDictionary(x => x.Key, y => y.Value);
}
#endregion Protected Properties
private Dictionary<string, string> FillDict = new();
#region Private Methods
/// <summary>
/// Metodo per cambiare solo il Fill corrente
/// </summary>
/// <param name="reqFillType"> Tipo di fill richiesto </param>
/// <returns></returns>
private Task ChangeOneFill(FillTypes reqFillType)
{
CurrFill.SelFillType = reqFillType;
return EC_UpdateFill.InvokeAsync(CurrFill);
}
/// <summary>
/// Metodo per tornare alla pagina Tree
/// </summary>
private void ReqClose()
{
_ = EC_ReqClose.InvokeAsync(true);
}
/// <summary>
/// Calcola bottone selezionato per il Fill
/// </summary>
/// <returns></returns>
private string buttonFillCss(FillTypes reqFillTypes)
{
return (CurrFill.SelFillType == reqFillTypes) ? "btn btn-secondary btn-sm" : "btn btn-outline-secondary btn-sm";
}
/// <summary>
/// Metodo per traduzione in lingua corrente
/// </summary>
/// <param name="lemma"></param>
/// <returns></returns>
private string Traduci(string lemma)
{
string ans = lemma;
if (FillDict != null && FillDict.ContainsKey(lemma))
{
ans = FillDict.GetValueOrDefault(lemma) ?? "";
}
return ans;
}
#endregion Private Methods
}
}