using Microsoft.AspNetCore.Components; using WebWindowTest.Models; using static WebWindowTest.Json.WindowConst; using static WebWindowTest.LayoutConst; namespace WebWindowTest.Compo { public partial class CardSashGroup { #region Public Properties /// /// Sash corrente rispetto alla lista Sash /// [CascadingParameter(Name = "CurrSashGroup")] public Sash CurrSashGroup { get; set; } = null!; /// /// Evento per cambiare tutti i fill /// [Parameter] public EventCallback EC_UpdateFrame { get; set; } /// /// Evento per tornare nella pagine Tree /// [Parameter] public EventCallback EC_ReqClose { get; set; } /// /// Evento per richiedere reset dizionario Shape /// [Parameter] public EventCallback EC_ReqResetDict { get; set; } /// /// Evento per richiedere per la prima volta opzioni hardware /// [Parameter] public EventCallback EC_ReqFirstOptionHw { get; set; } /// /// Evento per segnalare aggiornamento /// [Parameter] public EventCallback EC_UpdateSashGroup { get; set; } /// /// Lista di sash /// [CascadingParameter(Name = "SashList")] public List SashList { get; set; } = null!; /// /// Frame corrente /// [Parameter] public Frame FrameWindow { get; set; } = null!; #endregion Public Properties #region Protected Properties /// /// Selezione quantità di ante /// protected int SashQty { get => CurrSashGroup.nSashQty; } /// /// Selezione quantità bottom rail /// protected int SashBottomRailQty { get => CurrSashGroup.SashBottomRailQty; set { if (CurrSashGroup.SashBottomRailQty != value) { CurrSashGroup.SashBottomRailQty = value; if (CurrSashGroup.SashBottomRailQty > 0) CurrSashGroup.SetSashBottomRail(true); else CurrSashGroup.SetSashBottomRail(false); var args = new DataUpdateSash() { currSash = CurrSashGroup }; _ = EC_UpdateSashGroup.InvokeAsync(args); } } } /// /// Selezione tipo di orientamento della sash /// protected int OrientationSashTypeIndex { get => CurrSashGroup.SelOrientationSashTypeIndex; } /// /// Selezione famiglia hardware /// protected string FamilyHardware { get => CurrSashGroup.SelFamilyHardware; } protected string SelHwType { get => CurrSashGroup.GetHardwareDescription; } #endregion Protected Properties #region Protected Methods /// /// Metodo per scegliere tipo di misura /// /// /// protected async Task SetMeasureType(MeasureTypes type) { isOpen = !isOpen; for(int i = 0; i < CurrSashGroup.SashList.Count; i++) { CurrSashGroup.SashList.ElementAt(i).SetSelMeasureType(type, i); } var args = new DataUpdateSash { currSash = CurrSashGroup, noSvg = true }; await EC_UpdateSashGroup.InvokeAsync(args); } /// /// Metodo per aggiornare la sash dimension /// /// /// protected async Task UpdateSashDimension(SashDimension updateSD) { var currRec = CurrSashGroup.SashList.First(x => x.nSashId == updateSD.nSashId); if(currRec != null) { currRec = updateSD; var args = new DataUpdateSash { currSash = CurrSashGroup }; await EC_UpdateSashGroup.InvokeAsync(args); } } /// /// Metodo per aggiornare sash /// /// /// protected async Task UpdateSash(Sash updateS) { if (updateS != null) { CurrSashGroup = updateS; var args = new DataUpdateSash { currSash = CurrSashGroup }; await EC_UpdateSashGroup.InvokeAsync(args); } } #endregion Protected Methods #region Private Methods private bool editMode = false; private List currSashDimEdit = new List(); private void EditView(DataChangeMode args) { editMode = args.Edit; if(args.IndexSashEdit != -1) currSashDimEdit.Add(args.IndexSashEdit); if (args.IndexSashClose != -1) currSashDimEdit.Remove(args.IndexSashClose); } /// /// Sollevo evento per tornare alla pagina Tree /// private void ReqClose() { _ = EC_ReqClose.InvokeAsync(true); } /// /// Prima chiamata hw option list /// /// /// private async Task FirstHwOptionList() { var args = new DataUpdateSash { currSash = CurrSashGroup }; //await EC_UpdatePreview.InvokeAsync(args); await EC_ReqFirstOptionHw.InvokeAsync(CurrSashGroup); } private string ButtonMeasureCss(MeasureTypes type) { foreach(var item in CurrSashGroup.SashList) { if (!item.SelMeasureType.Equals(type)) return "btn btn-outline-secondary btn-sm"; } return "btn btn-secondary btn-sm"; } private bool isOpen = false; private void ToggleDropdown() { isOpen = !isOpen; } #endregion Private Methods } public class DataUpdateSash { public Sash currSash { get; set; } = null!; public bool svgNoHw { get; set; } = false; public bool noSvg { get; set; } = false; } public class DataUpdateRes { public DataAction req { get; set; } = DataAction.None; } }