From 50f307f84fdc49ff941d1f5890296e6ce34620ef Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 6 Oct 2025 19:42:41 +0200 Subject: [PATCH] inizio update e riscrittura modulo TableComp --- Test.UI/Components/Pages/EditJWD.razor | 17 +- Test.UI/Components/Pages/EditJWD.razor.cs | 30 +- Test.UI/Hardware/Setup.json | 20 +- WebWindowComplex/DTO/BaseListPayload.cs | 62 ++ WebWindowComplex/DTO/LivePayload.cs | 36 + WebWindowComplex/DTO/SelectPayload.cs | 56 + WebWindowComplex/TableComp.razor | 24 +- WebWindowComplex/TableComp.razor.cs | 965 ++++++++++-------- WebWindowComplex/WebWindowComplex.csproj | 16 +- WebWindowComplex/Window.cs | 4 +- .../WebWindowConfigurator.csproj | 23 +- 11 files changed, 800 insertions(+), 453 deletions(-) create mode 100644 WebWindowComplex/DTO/BaseListPayload.cs create mode 100644 WebWindowComplex/DTO/LivePayload.cs create mode 100644 WebWindowComplex/DTO/SelectPayload.cs diff --git a/Test.UI/Components/Pages/EditJWD.razor b/Test.UI/Components/Pages/EditJWD.razor index 265fd2f..193fef2 100644 --- a/Test.UI/Components/Pages/EditJWD.razor +++ b/Test.UI/Components/Pages/EditJWD.razor @@ -4,17 +4,20 @@ EditJWD - +> @* + IN_ColorMaterialList="@AvailColorMaterialList" + IN_FamilyHardwareList="@AvailFamilyHardwareList" + IN_GlassList="@AvailGlassList" + IN_HardwareList="@AvailHardwareList" + IN_MaterialList="@AvailMaterialList" + LiveSVG="@currSvg" + CurrJwd="@InitialJwd" IN_SelFamilyHardware="@SelFamilyHardware" IN_SelColorMaterial="@SelColorMaterial" IN_SelMaterial="@SelMaterial" diff --git a/Test.UI/Components/Pages/EditJWD.razor.cs b/Test.UI/Components/Pages/EditJWD.razor.cs index 4337ecc..cb41e21 100644 --- a/Test.UI/Components/Pages/EditJWD.razor.cs +++ b/Test.UI/Components/Pages/EditJWD.razor.cs @@ -98,10 +98,36 @@ namespace Test.UI.Components.Pages //SelGlass = "4T/16/4T"; InitialJwd = File.ReadAllText("Data\\AntaDoppia.jwd"); currJwd = InitialJwd; - DLService.CalcDonePipe.EA_NewMessage += CalcDonePipe_EA_NewMessage; + // rileggo altri dati await ReloadData(); + // preparo conf oggetti x controllo + SetupList = SetupList = new BaseListPayload() + { + ColorMaterial = AvailColorMaterialList, + FamilyHardware = AvailFamilyHardwareList, + Glass = AvailGlassList, + Hardware = AvailHardwareList, + Material = AvailMaterialList, + TemplateDTO = null + }; + CurrData = new LivePayload() + { + CurrJwd = InitialJwd, + SvgPreview = currSvg + }; + DLService.CalcDonePipe.EA_NewMessage += CalcDonePipe_EA_NewMessage; } + + /// + /// Configurazione elenchi anagrafiche + /// + protected BaseListPayload SetupList = new BaseListPayload(); + /// + /// Predisposizione valori live SVG/JWD + /// + protected LivePayload CurrData = new LivePayload(); + #endregion Protected Methods #region Private Fields @@ -135,6 +161,7 @@ namespace Test.UI.Components.Pages if (currArgs.msgUid.Equals($"{subChannel}:{windowUid}")) { currSvg = currArgs.newMessage; + CurrData.SvgPreview = currArgs.newMessage; } await InvokeAsync(StateHasChanged); } @@ -213,5 +240,6 @@ namespace Test.UI.Components.Pages } #endregion Private Methods + } } \ No newline at end of file diff --git a/Test.UI/Hardware/Setup.json b/Test.UI/Hardware/Setup.json index 114808a..ff15768 100644 --- a/Test.UI/Hardware/Setup.json +++ b/Test.UI/Hardware/Setup.json @@ -5,8 +5,8 @@ "Description": "Profilo78_Rect_Sash", "OpeningType": "ANTA_RIBALTA", "Shape": "Rectangular", - "SashQty": "1", - "SashPosition": "1" + "SashQty": 1, + "SashPosition": 1 }, { "Id": "000562", @@ -14,8 +14,8 @@ "Description": "Profilo78_Rect_Sash", "OpeningType": "ANTA_BANDIERA", "Shape": "Rectangular", - "SashQty": "1", - "SashPosition": "1" + "SashQty": 1, + "SashPosition": 1 }, { "Id": "000559", @@ -23,8 +23,8 @@ "Description": "Profilo78_Rect_DoubleSash", "OpeningType": "ANTA_RIBALTA", "Shape": "Rectangular", - "SashQty": "2", - "SashPosition": "1" + "SashQty": 2, + "SashPosition": 1 }, { "Id": "000563", @@ -32,8 +32,8 @@ "Description": "Profilo78_TurnOnly_Rect_DoubleSash", "OpeningType": "ANTA_BANDIERA", "Shape": "Rectangular", - "SashQty": "2", - "SashPosition": "1" + "SashQty": 2, + "SashPosition": 1 }, { "Id": "000560", @@ -41,7 +41,7 @@ "Description": "Profilo78_Rect_TripleSash", "OpeningType": "ANTA_RIBALTA", "Shape": "Rectangular", - "SashQty": "3", - "SashPosition": "1" + "SashQty": 3, + "SashPosition": 1 } ] \ No newline at end of file diff --git a/WebWindowComplex/DTO/BaseListPayload.cs b/WebWindowComplex/DTO/BaseListPayload.cs new file mode 100644 index 0000000..e0ba2bf --- /dev/null +++ b/WebWindowComplex/DTO/BaseListPayload.cs @@ -0,0 +1,62 @@ +using Egw.Window.Data; +using Microsoft.AspNetCore.Components; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http.Headers; +using System.Text; +using System.Threading.Tasks; + +namespace WebWindowComplex.DTO +{ + /// + /// Payload complessivo delle anagrafiche necessarie x Window + /// + public class BaseListPayload + { + /// + /// Elenco template in formato DTO + /// + public List? TemplateDTO { get; set; } = null; + + /// + /// Elenco Famiglie HW in formato DTO + /// + public List FamilyHardware { get; set; } = null!; + + /// + /// Elenco HW + /// + public List Hardware { get; set; } = null!; + + /// + /// Elenco colori + /// + public List ColorMaterial { get; set; } = null!; + + /// + /// Elenco Materiali impiegabili + /// + public List Material { get; set; } = null!; + + /// + /// Elenco vetri ammessi + /// + public List Glass { get; set; } = null!; + + /// + /// Verifica di validità dell'intero Payload + /// + /// + public bool IsValid() + { + //bool templateOK = TemplateDTO != null && TemplateDTO.Count > 0; + bool famHwOK = FamilyHardware != null && FamilyHardware.Count > 0; + bool hwOK = Hardware != null && Hardware.Count > 0; + bool glassOK = Glass != null && Glass.Count > 0; + bool matOK = Material != null && Material.Count > 0; + bool colorOK = ColorMaterial != null && ColorMaterial.Count > 0; + return famHwOK && glassOK && hwOK && colorOK && matOK; + } + } +} diff --git a/WebWindowComplex/DTO/LivePayload.cs b/WebWindowComplex/DTO/LivePayload.cs new file mode 100644 index 0000000..ddf6f30 --- /dev/null +++ b/WebWindowComplex/DTO/LivePayload.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebWindowComplex.DTO +{ + /// + /// Dati specifici ricevuto dal chiamante x display e calcoli + /// + public class LivePayload + { + + /// + /// JWD Corrente + /// + public string CurrJwd { get; set; } = string.Empty; + + /// + /// Preview SVG + /// + public string SvgPreview { get; set; } = string.Empty; + + + /// + /// Verifica di validità del Payload (solo jwd) + /// + /// + public bool IsValid() + { + bool jwdOK = !string.IsNullOrEmpty(CurrJwd); + return jwdOK; + } + } +} diff --git a/WebWindowComplex/DTO/SelectPayload.cs b/WebWindowComplex/DTO/SelectPayload.cs new file mode 100644 index 0000000..27d1460 --- /dev/null +++ b/WebWindowComplex/DTO/SelectPayload.cs @@ -0,0 +1,56 @@ +using Egw.Window.Data; +using Microsoft.AspNetCore.Components; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http.Headers; +using System.Text; +using System.Threading.Tasks; + +namespace WebWindowComplex.DTO +{ + /// + /// Payload complessivo delle preselezioni (globalmente opzionali) + /// + public class SelectPayload + { + /// + /// Famiglia HW selezionata + /// + public string FamilyHardware { get; set; } = string.Empty; + + /// + /// Colore selezionato + /// + public string ColorMaterial { get; set; } = string.Empty; + + /// + /// Materiale selezionato + /// + public string Material { get; set; } = string.Empty; + + /// + /// Tipologia vetro selezionato + /// + public string Glass { get; set; } = string.Empty; + + /// + /// Template selezionato + /// + public Template Template { get; set; } = null!; + + /// + /// Verifica di validità dell'intero Payload + /// + /// + public bool IsValid() + { + bool famHwOK = !string.IsNullOrEmpty(FamilyHardware); + bool colorOK = !string.IsNullOrEmpty(ColorMaterial); + bool glassOk = !string.IsNullOrEmpty(Glass); + bool matOK = !string.IsNullOrEmpty(Material); + bool templateOK = Template != null; + return famHwOK && colorOK && matOK && glassOk && templateOK; + } + } +} diff --git a/WebWindowComplex/TableComp.razor b/WebWindowComplex/TableComp.razor index 3e4ddf9..d48c54c 100644 --- a/WebWindowComplex/TableComp.razor +++ b/WebWindowComplex/TableComp.razor @@ -5,7 +5,7 @@
- @if (string.IsNullOrEmpty(CurrJwd)) + @if (string.IsNullOrEmpty(LiveData.CurrJwd)) { - @if (currStep == CompileStep.Template) + @if (currStep == CompileStep.Template && ListPayload.TemplateDTO != null) { @@ -94,7 +94,7 @@ - @foreach (var item in IN_TemplateDTOList) + @foreach (var item in ListPayload.TemplateDTO) { string colorClass = ""; @if (SelTemplateDTO != null && item.Index == SelTemplateDTO.Index) @@ -819,10 +819,14 @@
@@ -845,9 +849,9 @@
@@ -869,9 +873,9 @@
diff --git a/WebWindowComplex/TableComp.razor.cs b/WebWindowComplex/TableComp.razor.cs index 4527578..1512ce2 100644 --- a/WebWindowComplex/TableComp.razor.cs +++ b/WebWindowComplex/TableComp.razor.cs @@ -20,6 +20,12 @@ namespace WebWindowComplex [Parameter] public string CssSvg { get; set; } = "responsive-svg"; + /// + /// Preselezione valori + /// + [Parameter] + public SelectPayload? CurrSelection { get; set; } = null; + [Parameter] public EventCallback EC_OnClose { get; set; } @@ -29,6 +35,21 @@ namespace WebWindowComplex [Parameter] public EventCallback> EC_OnUpdate { get; set; } + /// + /// Elenco anagrafiche di base + /// + [Parameter] + public BaseListPayload ListPayload { get; set; } = null!; + + /// + /// Dati live controllo (JWD, SVG, ...) + /// + [Parameter] + public LivePayload LiveData { get; set; } = null!; + + #endregion Public Properties + +#if false [Parameter] public string CurrJwd { @@ -65,7 +86,15 @@ namespace WebWindowComplex } } } + [Parameter] + public string LiveSVG + { + get => m_SelSVG; + set => m_SelSVG = value; + } +#endif +#if false [Parameter] public Template IN_SelTemplate { @@ -109,9 +138,6 @@ namespace WebWindowComplex [Parameter] public List IN_FamilyHardwareList { get; set; } = null!; - [Parameter] - public string IN_SelFamilyHardware { get; set; } = null!; - [Parameter] public List IN_HardwareList { get; set; } = null!; @@ -119,28 +145,25 @@ namespace WebWindowComplex public List IN_ColorMaterialList { get; set; } = null!; [Parameter] - public string? IN_SelColorMaterial { get; set; } = null; + public List IN_MaterialList { get; set; } = null!; [Parameter] - public List IN_MaterialList { get; set; } = null!; + public List IN_GlassList { get; set; } = null!; +#endif + +#if false + [Parameter] + public string IN_SelFamilyHardware { get; set; } = null!; + + [Parameter] + public string? IN_SelColorMaterial { get; set; } = null; [Parameter] public string? IN_SelMaterial { get; set; } = null; - [Parameter] - public List IN_GlassList { get; set; } = null!; - [Parameter] public string? IN_SelGlass { get; set; } = null; - - [Parameter] - public string LiveSVG - { - get => m_SelSVG; - set => m_SelSVG = value; - } - - #endregion Public Properties +#endif #region Public Methods @@ -180,12 +203,24 @@ namespace WebWindowComplex #region Protected Properties + protected List FillList + { + get => m_FillList; + } + protected Frame FrameWindow { get => m_Frame!; set => m_Frame = value; } + + protected List ItemTableList + { + get => m_ItemTableList; + } + protected string? m_CurrJwd { get; set; } + protected string m_SelSVG { get; set; } = ""; /// @@ -196,7 +231,7 @@ namespace WebWindowComplex get { // aggiunta gestione classe svg per posizionamento con costraints - var newSvg = LiveSVG.Replace(" m_SashList; } - protected List SplitList - { - get => m_SplitList; - } - protected List FillList - { - get => m_FillList; - } - protected List SplittedList - { - get => m_SplittedList; - } - protected List ItemTableList - { - get => m_ItemTableList; - } - protected TemplateSelectDTO? SelTemplateDTO { get; set; } = null; + + protected string SelColorMaterial { get; set; } = ""; + protected string SelFamilyHardware { get @@ -244,119 +265,27 @@ namespace WebWindowComplex } } } - protected string SelColorMaterial { get; set; } = ""; + + protected string SelGlass { get; set; } = ""; protected string SelMaterial { get; set; } = ""!; - protected string SelGlass { get; set; } = ""; + protected TemplateSelectDTO? SelTemplateDTO { get; set; } = null; + + protected List SplitList + { + get => m_SplitList; + } + + protected List SplittedList + { + get => m_SplittedList; + } #endregion Protected Properties #region Protected Methods - protected override async Task OnInitializedAsync() - { - if (string.IsNullOrEmpty(CurrJwd)) - { - currStep = CompileStep.Template; - } - else - { - currStep = CompileStep.Tree; - } - if (SashList.Count > 0) - currAnta = 0; - await DoPreviewSvg(); - } - - /// - /// Metodo che resetta le liste (sash, split, splitted, fill e itemTable) e le crea nuovamente - /// - protected void UpdateLists() - { - m_maxCol = 0; - m_maxRow = 0; - m_FillList = new List(); - m_SashList = new List(); - m_SplitList = new List(); - m_SplittedList = new List(); - m_ItemTableList = new List(); - CreateWindowsList((m_CurrWindow!).AreaList[0], false); - CreateElementTable(m_CurrWindow.AreaList[0], 1, 1, 1, 1); - } - - /// - /// Metodo per settare i parmateri di ingresso selezionati - /// - protected void UpdateSelParameter() - { - SelFamilyHardware = IN_SelFamilyHardware; - SelColorMaterial = IN_SelColorMaterial ?? ""; - SelMaterial = IN_SelMaterial ?? ""; - SelGlass = IN_SelGlass ?? ""; - Sash.m_HardwareCompleteList = IN_HardwareList; - Sash.s_FamilyHardwareList = IN_FamilyHardwareList; - Sash.s_SelFamilyHW = IN_SelFamilyHardware ?? ""; - } - - // Ancora da fare... - protected async Task DoClose() - { - await EC_OnClose.InvokeAsync(true); - } - - /// - /// Anteprima SVG - /// - /// - protected async Task DoPreviewSvg() - { - if (m_CurrWindow != null) - { - var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize(), Formatting.Indented); - Dictionary Args = new Dictionary(); - Args.Add("Mode", $"{(int)Enums.QuestionModes.PREVIEW}"); - Args.Add("Jwd", CurrJwd); - await EC_OnUpdate.InvokeAsync(Args); - } - } - - /// - /// Metodo di reset dei dati a quelli del template - /// - protected async Task DoReset() - { - // Aggiornati parametri di ingresso selezionati - Area.nCounterGroup = 0; - UpdateSelParameter(); - JsonWindow WindowFromJson; - if (string.IsNullOrEmpty(CurrJwd)) - WindowFromJson = JsonConvert.DeserializeObject(m_SelTemplate.JWD, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); - else - WindowFromJson = JsonConvert.DeserializeObject(m_CurrJwd!, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); - if (m_CurrWindow != null) - { - m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview; - m_CurrWindow = null; - } - m_CurrWindow = WindowFromJson.Deserialize(); - m_CurrWindow.OnPreview += M_CurrWindow_OnPreview; - // Aggiorante liste sash, split, splitted, fill e itemTable - UpdateLists(); - currSash = -1; - currFill = -1; - currSplit = -1; - currStep = CompileStep.Tree; - await DoPreviewSvg(); - } - - // Ancora da fare.. - protected async Task DoSave() - { - //manca salvataggio JWD - await EC_OnClose.InvokeAsync(true); - } - /// /// Metodo per la scelta della maniglia univoca /// @@ -369,7 +298,7 @@ namespace WebWindowComplex { if (s.Equals(currSash)) { - // Per ogni anta della Sash setto bHasHandle + // Per ogni anta della Sash setto bHasHandle foreach (SashDimension item in s.SashList) { if (item.Equals(sashDim)) @@ -385,9 +314,11 @@ namespace WebWindowComplex case Openings.TILTTURN_LEFT: item.SetOpeningType(Openings.TURNONLY_LEFT); break; + case Openings.TILTTURN_RIGHT: item.SetOpeningType(Openings.TURNONLY_RIGHT); break; + default: break; } @@ -416,99 +347,6 @@ namespace WebWindowComplex } } - /// - /// Metodo per determinare la descrizione del parent dello split corrente - /// - /// split corrente - /// - protected string descParentSplit(Split currSplit) - { - if ((currSplit.ParentArea is Splitted || currSplit.ParentArea is Sash) && SashList.Count > 0) - { - for (int j = 0; j < SashList.Count; j++) - { - if (SashList[j].Equals(currSplit.ParentArea)) - { - return "Sash " + (j + 1); - } - else if (SashList[j].Equals(currSplit.ParentArea.ParentArea)) - { - for (int k = 0; k < SashList[j].AreaList.Count; k++) - { - if (SashList[j].AreaList[k].AreaList[0].Equals(currSplit)) - { - return "Sash " + (j + 1) + " - anta " + (k + 1); - } - } - } - } - } - else - { - return "Frame"; - } - return ""; - } - - /// - /// Selezione del template - /// - /// template selezionato - protected async void DoSelect(TemplateSelectDTO newSel) - { - SelTemplateDTO = newSel; - await EC_OnSelectedTemplate.InvokeAsync(newSel); - } - - /// - /// Metodo per riempire le liste Sash, Split, Splitted e Fill - /// - /// Area da classificare - /// Parametro per sapere se si è dentro un'anta - protected void CreateWindowsList(Area node, bool IntoSash) - { - if (node != null) - { - if (node.ParentArea is Sash || IntoSash == true) - IntoSash = true; - switch (node.AreaType) - { - case AreaTypes.FRAME: - { - FrameWindow = (Frame)node; - break; - } - case AreaTypes.SASH: - { - m_SashList.Add((Sash)node); - break; - } - case AreaTypes.FILL: - { - m_FillList.Add((Fill)node); - break; - } - case AreaTypes.SPLIT: - { - m_SplitList.Add((Split)node); - break; - } - case AreaTypes.SPLITTED: - { - if (node.ParentArea is Split && !IntoSash && node.AreaList[0] is Fill) - { - m_SplittedList.Add((Splitted)node); - } - break; - } - } - foreach (var item in node.AreaList) - { - CreateWindowsList(item, IntoSash); - } - } - } - /// /// Metodo per riempire la lista ItemTable in modo da poter rappresentarla come tabella /// @@ -652,6 +490,445 @@ namespace WebWindowComplex } } + /// + /// Metodo per riempire le liste Sash, Split, Splitted e Fill + /// + /// Area da classificare + /// Parametro per sapere se si è dentro un'anta + protected void CreateWindowsList(Area node, bool IntoSash) + { + if (node != null) + { + if (node.ParentArea is Sash || IntoSash == true) + IntoSash = true; + switch (node.AreaType) + { + case AreaTypes.FRAME: + { + FrameWindow = (Frame)node; + break; + } + case AreaTypes.SASH: + { + m_SashList.Add((Sash)node); + break; + } + case AreaTypes.FILL: + { + m_FillList.Add((Fill)node); + break; + } + case AreaTypes.SPLIT: + { + m_SplitList.Add((Split)node); + break; + } + case AreaTypes.SPLITTED: + { + if (node.ParentArea is Split && !IntoSash && node.AreaList[0] is Fill) + { + m_SplittedList.Add((Splitted)node); + } + break; + } + } + foreach (var item in node.AreaList) + { + CreateWindowsList(item, IntoSash); + } + } + } + + /// + /// Metodo per determinare la descrizione del parent dello split corrente + /// + /// split corrente + /// + protected string descParentSplit(Split currSplit) + { + if ((currSplit.ParentArea is Splitted || currSplit.ParentArea is Sash) && SashList.Count > 0) + { + for (int j = 0; j < SashList.Count; j++) + { + if (SashList[j].Equals(currSplit.ParentArea)) + { + return "Sash " + (j + 1); + } + else if (SashList[j].Equals(currSplit.ParentArea.ParentArea)) + { + for (int k = 0; k < SashList[j].AreaList.Count; k++) + { + if (SashList[j].AreaList[k].AreaList[0].Equals(currSplit)) + { + return "Sash " + (j + 1) + " - anta " + (k + 1); + } + } + } + } + } + else + { + return "Frame"; + } + return ""; + } + + // Ancora da fare... + protected async Task DoClose() + { + await EC_OnClose.InvokeAsync(true); + } + + /// + /// Anteprima SVG + /// + /// + protected async Task DoPreviewSvg() + { + if (m_CurrWindow != null) + { + var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize(), Formatting.Indented); + Dictionary Args = new Dictionary(); + Args.Add("Mode", $"{(int)Enums.QuestionModes.PREVIEW}"); + Args.Add("Jwd", CurrJwd); + await EC_OnUpdate.InvokeAsync(Args); + } + } + + /// + /// Metodo di reset dei dati a quelli del template + /// + protected async Task DoReset() + { + // Aggiornati parametri di ingresso selezionati + Area.nCounterGroup = 0; + UpdateSelParameter(); + JsonWindow WindowFromJson; + if (string.IsNullOrEmpty(LiveData.CurrJwd)) + WindowFromJson = JsonConvert.DeserializeObject(m_SelTemplate.JWD, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); + else + WindowFromJson = JsonConvert.DeserializeObject(m_CurrJwd!, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); + if (m_CurrWindow != null) + { + m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview; + m_CurrWindow = null; + } + m_CurrWindow = WindowFromJson.Deserialize(); + m_CurrWindow.OnPreview += M_CurrWindow_OnPreview; + // Aggiorante liste sash, split, splitted, fill e itemTable + UpdateLists(); + currSash = -1; + currFill = -1; + currSplit = -1; + currStep = CompileStep.Tree; + await DoPreviewSvg(); + } + + // Ancora da fare.. + protected async Task DoSave() + { + //manca salvataggio JWD + await EC_OnClose.InvokeAsync(true); + } + + /// + /// Selezione del template + /// + /// template selezionato + protected async void DoSelect(TemplateSelectDTO newSel) + { + SelTemplateDTO = newSel; + await EC_OnSelectedTemplate.InvokeAsync(newSel); + } + + protected override async Task OnInitializedAsync() + { + if (string.IsNullOrEmpty(LiveData.CurrJwd)) + { + currStep = CompileStep.Template; + } + else + { + currStep = CompileStep.Tree; + } + if (SashList.Count > 0) + currAnta = 0; + await DoPreviewSvg(); + } + + /// + /// Gestione update post ricezione parametri da controllo chiamante + /// + protected override void OnParametersSet() + { + // controllo elenchi BasePayload siano validi... + if (ListPayload.IsValid()) + { + // controllo sia popolato anche per la componente LIVE + if (LiveData.IsValid()) + { + m_CurrJwd = LiveData.CurrJwd; + m_SelSVG = LiveData.SvgPreview; + // Aggiornati parametri di ingresso selezionati + UpdateSelParameter(); + JsonWindow WindowFromJson = JsonConvert.DeserializeObject(m_CurrJwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); + if (m_CurrWindow != null) + { + m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview; + m_CurrWindow = null; + } + m_CurrWindow = WindowFromJson.Deserialize(); + m_CurrWindow.OnPreview += M_CurrWindow_OnPreview; + // Recupero dimensioni Frame e Joint del frame della finestra precedente + if (m_PreviousWindow != null) + { + for (int i = 0; i < 2; i++) + m_CurrWindow.AreaList[0].DimensionList[i] = m_PreviousWindow.AreaList[0].DimensionList[i]; + for (int i = 0; i < 4; i++) + m_CurrWindow.AreaList[0].JointList[i] = m_PreviousWindow.AreaList[0].JointList[i]; + } + if (m_CurrWindow != null) + { + // Aggiornate liste di sash, split, splitted, fill e itemTable + UpdateLists(); + } + } + else if (CurrSelection != null && CurrSelection.Template != null) + { + // Se viene passato il template selezionato oppure se non è ancora stato selezionato un template oppure se si cambia template di selezione + if (m_SelTemplate == null || (m_SelTemplate != null && CurrSelection.Template.nIndex != m_SelTemplate.nIndex) && !string.IsNullOrEmpty(CurrSelection.Template.JWD)) + { + m_SelTemplate = CurrSelection.Template; + // Aggiornamento parametri di ingresso selezionati + UpdateSelParameter(); + JsonWindow WindowFromJson = JsonConvert.DeserializeObject(m_SelTemplate.JWD, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); + if (m_CurrWindow != null) + { + m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview; + m_CurrWindow = null; + } + m_CurrWindow = WindowFromJson.Deserialize(); + m_CurrWindow.OnPreview += M_CurrWindow_OnPreview; + // Recupero dimensioni Frame e Joint del frame della finestra precedente + if (m_PreviousWindow != null) + { + for (int i = 0; i < 2; i++) + m_CurrWindow.AreaList[0].DimensionList[i] = m_PreviousWindow.AreaList[0].DimensionList[i]; + for (int i = 0; i < 4; i++) + m_CurrWindow.AreaList[0].JointList[i] = m_PreviousWindow.AreaList[0].JointList[i]; + } + } + if (m_CurrWindow != null) + { + // Aggiornamento liste sash, split, splitted, fill e itemTable + UpdateLists(); + } + } + } + } + + /// + /// Metodo che resetta le liste (sash, split, splitted, fill e itemTable) e le crea nuovamente + /// + protected void UpdateLists() + { + m_maxCol = 0; + m_maxRow = 0; + m_FillList = new List(); + m_SashList = new List(); + m_SplitList = new List(); + m_SplittedList = new List(); + m_ItemTableList = new List(); + CreateWindowsList((m_CurrWindow!).AreaList[0], false); + CreateElementTable(m_CurrWindow.AreaList[0], 1, 1, 1, 1); + } + + /// + /// Metodo per settare i parmateri di ingresso selezionati + /// + protected void UpdateSelParameter() + { + if (CurrSelection != null && CurrSelection.IsValid()) + { + SelFamilyHardware = CurrSelection.FamilyHardware; + SelColorMaterial = CurrSelection.ColorMaterial ?? ""; + SelMaterial = CurrSelection.Material ?? ""; + SelGlass = CurrSelection.Glass ?? ""; + Sash.m_HardwareCompleteList = ListPayload.Hardware; + Sash.s_FamilyHardwareList = ListPayload.FamilyHardware; + Sash.s_SelFamilyHW = CurrSelection.FamilyHardware ?? ""; + } + } + + #endregion Protected Methods + + #region Private Fields + + private int currAnta = 0; + + private int currFill = -1; + + private int currSash = -1; + + private int currSplit = -1; + + private CompileStep currStep; + + private List m_FillList = new List(); + + private Frame? m_Frame; + + private List m_ItemTableList = new List(); + + private int m_maxCol = 0; + + private int m_maxRow = 0; + + private List m_SashList = new List(); + + private List m_SplitList = new List(); + + private List m_SplittedList = new List(); + + #endregion Private Fields + + #region Private Properties + + private Window? m_CurrWindow { get; set; } = null; + + private Window? m_PreviousWindow { get; set; } = null; + + private string m_SelFamilyHardware { get; set; } = ""; + + private Template m_SelTemplate { get; set; } = null!; + + #endregion Private Properties + + #region Private Methods + + /// + /// Metodo per andare allo step successivo + /// + /// step successivo + private void AdvStep(CompileStep newStep) + { + currStep = newStep; + currSash = -1; + currFill = -1; + currSplit = -1; + } + + /// + /// Calcola larghezza colonna button nav + /// + /// + private string buttonCss() + { + return (currStep == CompileStep.Template) ? "col-4 d-grid gap-1 d-md-flex justify-content-md-end align-items-center" : "col-4 d-grid gap-1 d-md-flex justify-content-md-end align-items-center"; + } + + /// + /// Calcola bottone selezionato per il Fill + /// + /// + private string buttonFillCss(FillTypes currFillTypes) + { + if (FillList.ElementAt(currFill).SelFillType == currFillTypes) + return "btn btn-secondary btn-sm"; + else + return "btn btn-outline-secondary btn-sm"; + } + + /// + /// Metodo per settare tutti i Fill in contemporanea + /// + /// tipo di riempimento (GLASS o WOOD) + /// + private async Task ChangeAllFill(FillTypes type) + { + foreach (Fill currFill in FillList) + { + currFill.SetFillType(type); + } + await DoPreviewSvg(); + } + + /// + /// Metodo per settare tutti i Joints di Frame o Sash come ANGLED o FULL_H o FULL_V + /// + /// tipo di giunzione (ANGLED o FULL_H o FULL_V) + /// area su cui eseguire la funzione (Frame o Sash) + /// + private async Task ChangeAllJoints(WindowConst.Joints type, Area area) + { + if (area is Frame) + { + foreach (Joint joint in FrameWindow.JointList) + { + joint.SetSelJointType(type); + } + } + else + { + Sash a = (Sash)area; + foreach (Joint joint in a.JointList) + { + joint.SetSelJointType(type); + } + } + await DoPreviewSvg(); + } + + /// + /// Metodo per settare tutti i Fill in contemporanea + /// + /// tipo di riempimento (GLASS o WOOD) + /// + private async Task ChangeOneFill(FillTypes type) + { + Fill fillChange = FillList.ElementAt(currFill); + fillChange.SetFillType(type); + await DoPreviewSvg(); + } + + /// + /// Metodo per copiare contenuto di un'anta in un'altra anta + /// + /// Sash corrispondente all'anta + /// Indice dell'anta che si copia + /// Indice dell'anta che si modifica + private async Task CopyContentSash(Sash sashItem, int IndexCopy, int IndexModify) + { + // Anta selezionata + Area sashSplitted = sashItem.AreaList[IndexModify]; + // Rimuovo riempimento da anta selezionata + sashSplitted.AreaList.RemoveAt(0); + // Creo la copia dell'anta scelta + Area a = sashItem.AreaList[IndexCopy].AreaList[0].Copy(sashSplitted); + // Aggiungo copia all'anta selezionata + sashItem.AreaList[IndexModify].AreaList.Add(a); + await DoPreviewSvg(); + } + + /// + /// Metodo per copiare una Sash intera + /// + /// Area Splitted corrente + /// Indice della Sash che si vuole copiare + /// + private async Task CopySash(Splitted currSplitted, int numSash) + { + //Rimuovo contenuto di Splitted e rimuovo area da conteggio gruppi + currSplitted.AreaList.RemoveAll(i => i != null); + //Area.DelCounterGroup(); + // Copio sash + Area a = SashList[numSash].Copy(currSplitted); + a.SetParentArea(currSplitted); + // Aggiungo copia a Splitted + currSplitted.AreaList.Add(a); + await DoPreviewSvg(); + } + /// /// Metodo per riempire tabella con contenuto vuoto o con i simboli per rappresentare la struttura /// @@ -738,151 +1015,29 @@ namespace WebWindowComplex } /// - /// Metodo per settare tutti i Joints di Frame o Sash come ANGLED o FULL_H o FULL_V + /// Calcola larghezza colonna header nav /// - /// tipo di giunzione (ANGLED o FULL_H o FULL_V) - /// area su cui eseguire la funzione (Frame o Sash) /// - private async Task ChangeAllJoints(WindowConst.Joints type, Area area) + private string headerCss() { - if (area is Frame) - { - foreach (Joint joint in FrameWindow.JointList) - { - joint.SetSelJointType(type); - } - } - else - { - Sash a = (Sash)area; - foreach (Joint joint in a.JointList) - { - joint.SetSelJointType(type); - } - } - await DoPreviewSvg(); + return (currStep == CompileStep.Template) ? "col-8 d-grid px-2 d-md-flex justify-content-md-start" : "col-8 d-grid px-2 d-md-flex justify-content-md-start"; + } + + private void M_CurrWindow_OnPreview(object? sender, OnPreviewEventArgs e) + { + Dictionary Args = new Dictionary(); + Args.Add("Mode", $"{(int)Enums.QuestionModes.PREVIEW}"); + Args.Add("Jwd", e.sJwd); + EC_OnUpdate.InvokeAsync(Args); } /// - /// Metodo per settare tutti i Fill in contemporanea + /// Calcola larghezza colonna contenente nav da mostrare /// - /// tipo di riempimento (GLASS o WOOD) /// - private async Task ChangeAllFill(FillTypes type) + private string mainCss() { - foreach (Fill currFill in FillList) - { - currFill.SetFillType(type); - } - await DoPreviewSvg(); - } - - /// - /// Metodo per settare tutti i Fill in contemporanea - /// - /// tipo di riempimento (GLASS o WOOD) - /// - private async Task ChangeOneFill(FillTypes type) - { - Fill fillChange = FillList.ElementAt(currFill); - fillChange.SetFillType(type); - await DoPreviewSvg(); - } - - /// - /// Metodo per copiare contenuto di un'anta in un'altra anta - /// - /// Sash corrispondente all'anta - /// Indice dell'anta che si copia - /// Indice dell'anta che si modifica - private async Task CopyContentSash(Sash sashItem, int IndexCopy, int IndexModify) - { - // Anta selezionata - Area sashSplitted = sashItem.AreaList[IndexModify]; - // Rimuovo riempimento da anta selezionata - sashSplitted.AreaList.RemoveAt(0); - // Creo la copia dell'anta scelta - Area a = sashItem.AreaList[IndexCopy].AreaList[0].Copy(sashSplitted); - // Aggiungo copia all'anta selezionata - sashItem.AreaList[IndexModify].AreaList.Add(a); - await DoPreviewSvg(); - } - - /// - /// Metodo per copiare una Sash intera - /// - /// Area Splitted corrente - /// Indice della Sash che si vuole copiare - /// - private async Task CopySash(Splitted currSplitted, int numSash) - { - //Rimuovo contenuto di Splitted e rimuovo area da conteggio gruppi - currSplitted.AreaList.RemoveAll(i => i != null); - //Area.DelCounterGroup(); - // Copio sash - Area a = SashList[numSash].Copy(currSplitted); - a.SetParentArea(currSplitted); - // Aggiungo copia a Splitted - currSplitted.AreaList.Add(a); - await DoPreviewSvg(); - } - - #endregion Protected Methods - - #region Private Fields - - private CompileStep currStep; - private int currAnta = 0; - private int currSash = -1; - private int currSplit = -1; - private int currFill = -1; - private Frame? m_Frame; - private List m_SashList = new List(); - private List m_SplitList = new List(); - private List m_FillList = new List(); - private List m_SplittedList = new List(); - private List m_ItemTableList = new List(); - private int m_maxCol = 0; - private int m_maxRow = 0; - - #endregion Private Fields - - #region Private Properties - - private Window? m_CurrWindow { get; set; } = null; - private Window? m_PreviousWindow { get; set; } = null; - private Template m_SelTemplate { get; set; } = null!; - private string m_SelFamilyHardware { get; set; } = ""; - - #endregion Private Properties - - #region Private Methods - - /// - /// Metodo per scambiare due aree di uno split - /// - /// Area corrente - /// - private async Task SwapTwoAree(Area currArea) - { - currArea.SwapAree(); - await DoPreviewSvg(); - } - - /// - /// Metodo per eliminare Split o Sash - /// - /// Area corrente - /// - private void RemoveArea(Area currArea) - { - if (currArea is Split) - ((Split)currArea).Remove(); - else if (currArea is Sash) - { - ((Sash)currArea).Remove(); - } - currStep = CompileStep.Tree; + return (currStep == CompileStep.Template) ? "col-12" : "col-6"; } /// @@ -920,23 +1075,30 @@ namespace WebWindowComplex } /// - /// Metodo per andare allo step successivo + /// Metodo per eliminare Split o Sash /// - /// step successivo - private void AdvStep(CompileStep newStep) + /// Area corrente + /// + private void RemoveArea(Area currArea) { - currStep = newStep; - currSash = -1; - currFill = -1; - currSplit = -1; + if (currArea is Split) + ((Split)currArea).Remove(); + else if (currArea is Sash) + { + ((Sash)currArea).Remove(); + } + currStep = CompileStep.Tree; } - private void M_CurrWindow_OnPreview(object? sender, OnPreviewEventArgs e) + /// + /// Metodo per scambiare due aree di uno split + /// + /// Area corrente + /// + private async Task SwapTwoAree(Area currArea) { - Dictionary Args = new Dictionary(); - Args.Add("Mode", $"{(int)Enums.QuestionModes.PREVIEW}"); - Args.Add("Jwd", e.sJwd); - EC_OnUpdate.InvokeAsync(Args); + currArea.SwapAree(); + await DoPreviewSvg(); } /// @@ -970,45 +1132,6 @@ namespace WebWindowComplex return (testStep == currStep) ? "nav-link active fw-bold" : "nav-link text-secondary"; } - /// - /// Calcola larghezza colonna contenente nav da mostrare - /// - /// - private string mainCss() - { - return (currStep == CompileStep.Template) ? "col-12" : "col-6"; - } - - /// - /// Calcola larghezza colonna header nav - /// - /// - private string headerCss() - { - return (currStep == CompileStep.Template) ? "col-8 d-grid px-2 d-md-flex justify-content-md-start" : "col-8 d-grid px-2 d-md-flex justify-content-md-start"; - } - - /// - /// Calcola larghezza colonna button nav - /// - /// - private string buttonCss() - { - return (currStep == CompileStep.Template) ? "col-4 d-grid gap-1 d-md-flex justify-content-md-end align-items-center" : "col-4 d-grid gap-1 d-md-flex justify-content-md-end align-items-center"; - } - - /// - /// Calcola bottone selezionato per il Fill - /// - /// - private string buttonFillCss(FillTypes currFillTypes) - { - if (FillList.ElementAt(currFill).SelFillType == currFillTypes) - return "btn btn-secondary btn-sm"; - else - return "btn btn-outline-secondary btn-sm"; - } - #endregion Private Methods } } \ No newline at end of file diff --git a/WebWindowComplex/WebWindowComplex.csproj b/WebWindowComplex/WebWindowComplex.csproj index 4072fb9..2a70a11 100644 --- a/WebWindowComplex/WebWindowComplex.csproj +++ b/WebWindowComplex/WebWindowComplex.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.10.612 + 2.7.10.619 Annamaria Sassi Egalware Componente gestione Configurazioni avanzate Window per LUX @@ -41,6 +41,20 @@ + + + + + + + + + + + + + + diff --git a/WebWindowComplex/Window.cs b/WebWindowComplex/Window.cs index 820d18e..00d6a92 100644 --- a/WebWindowComplex/Window.cs +++ b/WebWindowComplex/Window.cs @@ -1338,7 +1338,7 @@ namespace WebWindowComplex var iComp = StringComparison.InvariantCultureIgnoreCase; var rawList = m_HardwareCompleteList .Where(x => x.Id == "000000" || - (s_SelFamilyHW != null && x.FamilyName.Equals(s_SelFamilyHW, iComp) && x.SashQty == nSashQty && x.Shape.Equals(sSashShape, iComp) && x.OpeningType.Equals(sOpeningType, iComp)) + (!string.IsNullOrEmpty(s_SelFamilyHW) && x.FamilyName.Equals(s_SelFamilyHW, iComp) && x.SashQty == nSashQty && x.Shape.Equals(sSashShape, iComp) && x.OpeningType.Equals(sOpeningType, iComp)) ) .ToList(); if (rawList != null && rawList.Count > 0) @@ -1918,7 +1918,7 @@ namespace WebWindowComplex { private List m_FillTypeList = new List { - new IdNameStruct((int)FillTypes.GLASS, "Glass"), + new IdNameStruct((int)FillTypes.GLASS, "SvgPreview"), new IdNameStruct((int)FillTypes.WOOD, "Wood") }; public List FillTypeList diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index 062d5c8..631d1ee 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.10.612 + 2.7.10.619 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -54,3 +54,24 @@ + + + + + + + + + + + + + + + + + + + + +