using Microsoft.AspNetCore.Components; using System.Drawing; using WebWindowComplex.DTO; using WebWindowComplex.Models; namespace WebWindowComplex.Compo { public partial class General { #region Public Properties /// /// Finestra corrente /// [Parameter] public Window CurrWindow { get; set; } = null!; [Parameter] public bool BaseUser { get; set; } = false!; [Parameter] public EventCallback EC_UpdateGeneral { get; set; } [Parameter] public EventCallback EC_ReqClose { get; set; } /// /// Elenco anagrafiche di base /// [Parameter] public BaseListPayload ListPayload { get; set; } = null!; /// /// Elenco Warnings attivi /// [Parameter] public Dictionary ListWarnings { get; set; } = new Dictionary(); /// /// Elenco domande pendenti /// [Parameter] public Dictionary DictPendReq { get; set; } = new Dictionary(); /// /// Vocabolario con traduzione lingua corrente /// [Parameter] public Dictionary Vocabulary { get; set; } = null!; #endregion Public Properties #region Protected Methods protected override void OnParametersSet() { currColor = CurrWindow.sColorMaterial; currGlass = CurrWindow.sGlass; currWood = CurrWindow.sWood; currProfile = CurrWindow.sProfilePath; GeneralDict = Vocabulary.Where(x => x.Key.Contains("CWGeneral_")).ToDictionary(x => x.Key, y => y.Value); } #endregion Protected Methods #region Private Fields private string currColor = ""; private string currGlass = ""; private string currWood = ""; private string currProfile = ""; private Dictionary GeneralDict = new(); #endregion Private Fields #region Private Properties /// /// Colore corrente /// private string CurrColor { get => currColor; set { currColor = value; var args = new DataUpdateGeneral { Color = value, }; _ = EC_UpdateGeneral.InvokeAsync(args); } } /// /// Vetro corrente /// private string CurrGlass { get => currGlass; set { currGlass = value; var args = new DataUpdateGeneral { Glass = value, }; _ = EC_UpdateGeneral.InvokeAsync(args); } } /// /// Materiale corrente /// private string CurrWood { get => currWood; set { currWood = value; var args = new DataUpdateGeneral { Wood = value, }; _ = EC_UpdateGeneral.InvokeAsync(args); } } /// /// Profilo corrente /// private string CurrProfile { get => currProfile; set { currProfile = value; var args = new DataUpdateGeneral { Profile = value, }; _ = EC_UpdateGeneral.InvokeAsync(args); } } #endregion Private Properties #region Private Methods /// /// Calcola CSS warning /// /// /// protected string cssValid(string fKey) { string ans = ""; if (ListWarnings != null && DictPendReq != null && (ListWarnings.ContainsKey(fKey) || DictPendReq.ContainsKey(fKey))) ans = "border border-danger"; else ans = ""; return ans; } /// /// Richiesta di chiusura /// private void ReqClose() { _ = EC_ReqClose.InvokeAsync(true); } /// /// Metodo per traduzione in lingua corrente /// /// /// private string Traduci(string lemma) { string ans = lemma; if (GeneralDict != null && GeneralDict.ContainsKey(lemma)) { ans = GeneralDict.GetValueOrDefault(lemma) ?? ""; } return ans; } #endregion Private Methods } /// /// Classe per aggiornamento dati general /// public class DataUpdateGeneral { public string Color { get; set; } = ""; public string Glass { get; set; } = ""; public string Wood { get; set; } = ""; public string Profile { get; set; } = ""; } }