using Microsoft.AspNetCore.Components; using WebWindowComplex.Models; using static WebWindowComplex.Json.WindowConst; namespace WebWindowComplex.Compo { public partial class CardSashGroup { #region Public Properties /// /// Indice della sash corrente rispetto alla lista sash /// [Parameter] public int CurrIndex { get; set; } = 0; /// /// Sash corrente rispetto alla lista Sash /// [CascadingParameter(Name = "CurrSashGroup")] public Sash CurrSashGroup { get; set; } = null!; /// /// Evento per cambiare l'anta su cui è presente la maniglia /// [Parameter] public EventCallback EC_ChangeHandle { get; set; } /// /// Evento per cambiare l'anta su cui è presente la maniglia /// [Parameter] public EventCallback EC_CopyContentSash { get; set; } /// /// Evento per cambiare tutti i fill /// [Parameter] public EventCallback EC_RemoveArea { 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_ReqResetDictShape { get; set; } /// /// Evento per cambiare tutti i Joints /// [Parameter] public EventCallback EC_UpdateSash { get; set; } /// /// Evento per segnalare cambio hw e richiesta calcolo /// [Parameter] public EventCallback EC_UpdateSashHardware { get; set; } /// /// Evento per richiedere la prima volta le opzioni hardware /// [Parameter] public EventCallback EC_CallFirstHwOpt { get; set; } /// /// Lista di sash /// [Parameter] public List SashList { get; set; } = null!; #endregion Public Properties #region Protected Properties /// /// Selezione hardware /// protected string SelHwType { get => CurrSashGroup.SelHardwareFromId; set { if (CurrSashGroup.SelHardwareFromId != value) { CurrSashGroup.SelHardwareFromId = value; _ = EC_UpdateSashHardware.InvokeAsync(CurrSashGroup); } } } #endregion Protected Properties #region Protected Methods /// /// Sollevo evento per rimuovere area /// /// area da rimuovere /// protected async Task RemoveArea(Area currArea) { // richiesta reset dict shape await EC_ReqResetDictShape.InvokeAsync(true); await EC_RemoveArea.InvokeAsync(currArea); } protected async Task SetMeasureType(MeasureTypes type) { isOpen = !isOpen; foreach (var item in CurrSashGroup.SashList) { item.SetSelMeasureType(type); } await EC_UpdateSash.InvokeAsync(CurrSashGroup); } protected async Task UpdateSashDimension(SashDimension updateSD) { var currRec = CurrSashGroup.SashList.Where(x => x.nSashId == updateSD.nSashId).FirstOrDefault(); if(currRec != null) { currRec = updateSD; await EC_UpdateSash.InvokeAsync(CurrSashGroup); } } #endregion Protected Methods #region Private Methods /// /// Sollevo evento per cambiare l'anta su cui è presente la maniglia /// /// private async Task ChangeHandle(DataChangeHandle Args) { await EC_ChangeHandle.InvokeAsync(Args); } /// /// Sollevo evento per cambiare l'anta su cui è presente la maniglia /// /// private async Task CopyContentSash(DataCopyContentSash Args) { await EC_CopyContentSash.InvokeAsync(Args); } 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); } /// /// Report aggiornamento Option Combo /// /// /// private async Task UpdateOptCombo(AGBOptionCombo updRec) { // cerco il record var currRec = CurrSashGroup.HwOptionList.FirstOrDefault(x => x.sName == updRec.sName && x.sDescription == updRec.sDescription); // lo aggiorno if (updRec != null) { currRec = updRec; await EC_UpdateSashHardware.InvokeAsync(CurrSashGroup); } } /// /// Report aggiornamento Option Text /// /// /// private async Task UpdateOptText(AGBOptionText updRec) { // cerco il record var currRec = CurrSashGroup.HwOptionList.FirstOrDefault(x => x.sName == updRec.sName && x.sDescription == updRec.sDescription); // lo aggiorno if (updRec != null) { currRec = updRec; await EC_UpdateSashHardware.InvokeAsync(CurrSashGroup); } } /// /// Prima chiamata hw option list /// /// /// private async Task FirstHwOptionList(int groupId) { await EC_CallFirstHwOpt.InvokeAsync(groupId); } 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 } }