using Microsoft.AspNetCore.Components; using WebWindowComplex.Models; namespace WebWindowComplex.Compo { public partial class BottomRail { #region Public Properties [Parameter] public Area CurrArea { get; set; } = null!; /// /// Vocabolario con traduzione lingua corrente /// [CascadingParameter(Name = "Vocabulary")] public Dictionary Vocabulary { get; set; } = null!; [Parameter] public EventCallback EC_UpdateBottomRail { get; set; } #endregion Public Properties #region Protected Methods protected override void OnParametersSet() { BottomRDict = Vocabulary.Where(x => x.Key.Contains("CWBottomR_")).ToDictionary(x => x.Key, y => y.Value); } #endregion Protected Methods #region Private Fields private Dictionary BottomRDict = new(); #endregion Private Fields #region Private Properties /// /// Aggiornamento element Bottom Rail /// /// /// private async Task UpdateElement(ElementDimension updRec) { if (updRec != null) { DataBottomRail ans = new(); ElementDimension? currRec = new(CurrArea, -1, 0); if (CurrFrame() != null) { // cerco il record currRec = CurrFrame()!.BottomRailElemDimList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex); } else if(CurrSash() != null) { // cerco il record currRec = CurrSash()!.BottomRailElemDimList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex); } if (currRec != null) { currRec = updRec; ans = new DataBottomRail { frame = CurrFrame(), sash = CurrSash() }; } await EC_UpdateBottomRail.InvokeAsync(ans); } } private Frame? CurrFrame() { if(CurrArea is Frame frame) return frame; else return null; } private Sash? CurrSash() { if (CurrArea is Sash sash) return sash; else return null; } /// /// Metodo per traduzione in lingua corrente /// /// /// private string Traduci(string lemma) { string ans = lemma; if (BottomRDict != null && BottomRDict.ContainsKey(lemma)) { ans = BottomRDict.GetValueOrDefault(lemma) ?? ""; } return ans; } #endregion Private Properties } public class DataBottomRail { public Sash? sash { get; set; } public Frame? frame { get; set; } } }