using Microsoft.AspNetCore.Components; using WebWindowComplex.Models; using static WebWindowComplex.LayoutConst; namespace WebWindowComplex.Compo { public partial class CardTree { /// /// Lista oggetti ItemTable /// [Parameter] public List ItemTableList { get; set; } = null!; /// /// Numero massimo di colonne /// [Parameter] public int maxCol { get; set; } = 0; /// /// Dizionario con elementi che possono collassare /// [Parameter] public Dictionary RowCollapsedDict { get; set; } = new Dictionary(); /// /// Dizionario con numero di figli per elementi che possono collassare /// [Parameter] public Dictionary ChildDict { get; set; } = new Dictionary(); /// /// Lista di sash /// [Parameter] public List SashGroupList { get; set; } = null!; /// /// Lista di split /// [Parameter] public List SplitList { get; set; } = null!; /// /// Lista di splitted /// [Parameter] public List SplittedList { get; set; } = null!; /// /// Lista di fill /// [Parameter] public List FillList { get; set; } = null!; /// /// Lista di sash /// [Parameter] public Frame FrameWindow { get; set; } = null!; /// /// Utente /// [Parameter] public bool BaseUser { get; set; } = false; /// /// Evento richiesta prossimo step /// [Parameter] public EventCallback EC_NextStep { get; set; } /// /// Evento richiesta prossimo step /// [Parameter] public EventCallback EC_Remove { get; set; } /// /// Evento aggiornamento dizionari per collasso righe /// [Parameter] public EventCallback> EC_Collapsed { get; set; } /// /// Evento per richiedere reset dizionari /// [Parameter] public EventCallback EC_ReqResetDict { get; set; } /// /// Evento per richiedere opzioni hardware /// [Parameter] public EventCallback EC_ReqOptionHw { get; set; } /// /// Evento per richiesta profili degli Element /// [Parameter] public EventCallback EC_ReqElement { get; set; } /// /// Evento per richiesta calcolo preview /// [Parameter] public EventCallback EC_UpdateFrame { get; set; } /// /// Evento per aggiungere Sash /// [Parameter] public EventCallback EC_UpdateSplitted { get; set; } protected override void OnParametersSet() { for(int i = 0; i < FillList.Count; i++) { isOpenFill.Add(false); } } /// /// Metodo per richiesta prossimo step /// /// private Task RaiseNextStep(CompileStep cs, int indexStep) { var Args = new DataNextStep { currCompileStep = cs, index = indexStep, }; return EC_NextStep.InvokeAsync(Args); } /// /// Metodo per aprire/chiudere sottorighe /// /// private Task ChangeCollapsed(int row) { RowCollapsedDict[row] = RowCollapsedDict[row] ? false : true; return EC_Collapsed.InvokeAsync(RowCollapsedDict); } private string hwIcon(int row) { return RowCollapsedDict[row] ? "fa-solid fa-chevron-down" : "fa-solid fa-chevron-up"; } /// /// Metodo per rimuovere area (sash group o split) /// /// /// /// private Task Remove(CompileStep cs, int indexStep) { var Args = new DataNextStep { currCompileStep = cs, index = indexStep, }; return EC_Remove.InvokeAsync(Args); } /// /// Chiamata per aggiungere sash al frame /// /// private async Task RaiseAddSash() { FrameWindow.AddFirstSash(); await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDimElem }); await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDictShape }); var args = new DataUpdateFrame() { currFrame = FrameWindow, svgNoHw = true, reqShape = true }; await EC_ReqElement.InvokeAsync(FrameWindow); await EC_UpdateFrame.InvokeAsync(args); } /// /// Chiamata per aggiungere split al frame /// /// private async Task RaiseAddSplit() { FrameWindow.AddSplit(); Split s = (Split)FrameWindow.AreaList[0]; foreach(var item in s.AreaList) { if (item.AreaList.FirstOrDefault() is Fill) isOpenFill.Add(false); } await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDimElem }); var args = new DataUpdateFrame() { currFrame = FrameWindow, svgNoHw = true }; await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDictShape }); if (SashGroupList.Count > 0) await EC_ReqOptionHw.InvokeAsync(FrameWindow); await EC_ReqElement.InvokeAsync(FrameWindow); await EC_UpdateFrame.InvokeAsync(args); } /// /// Chiamata per aggiungere sash in un fill /// /// indice del fill /// private Task AddSashIntoFill(int currIndexFill) { Splitted? currSplitted = SplittedList.Where(x => x.AreaList.First().Equals(FillList[currIndexFill])).FirstOrDefault(); if (currSplitted != null) currSplitted.AddFirstSash(); return EC_UpdateSplitted.InvokeAsync(currSplitted); } /// /// Chiamata per aggiungere inglesina in un fill /// /// indice del fill /// private Task AddInglesinaIntoFill(int currIndexFill) { Splitted? currSplitted; Frame? currFrame; if (FillList.ElementAt(currIndexFill).ParentArea is Splitted) { currSplitted = (Splitted)FillList.ElementAt(currIndexFill).ParentArea; currSplitted.AddInglesina(); return EC_UpdateSplitted.InvokeAsync(currSplitted); } else if(FillList.ElementAt(currIndexFill).ParentArea is Frame) { currFrame = (Frame)FillList.ElementAt(currIndexFill).ParentArea; currFrame.AddInglesina(); DataUpdateFrame args = new DataUpdateFrame() { currFrame = currFrame }; return EC_UpdateFrame.InvokeAsync(args); } return null; } /// /// Chiamata per copiare sash in fill /// /// indice della sash da copiare /// indice del fill /// private Task CopySashIntoFill(int indexCurrSash, int currIndexFill) { Splitted? currSplitted = SplittedList.Where(x => x.AreaList.First().Equals(FillList[currIndexFill])).FirstOrDefault(); if (currSplitted != null) { currSplitted.AreaList.RemoveAll(i => i != null); Area a = SashGroupList[indexCurrSash].Copy(currSplitted); a.SetParentArea(currSplitted); currSplitted.AreaList.Add(a); } return EC_UpdateSplitted.InvokeAsync(currSplitted); } private bool isOpenFrame = false; private void ToggleDropdownFrame() { isOpenFrame = !isOpenFrame; } private List isOpenFill = new(); private void ToggleDropdownFill(int currIndexFill) { isOpenFill[currIndexFill] = !isOpenFill.ElementAt(currIndexFill); } } /// /// Classe per inserire dati per NextStep /// public class DataNextStep { public CompileStep currCompileStep { get; set; } public int index { get; set; } } }