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