From b1c1afdf094a47a589acdbb2f0f5dc91f0b5efd7 Mon Sep 17 00:00:00 2001 From: Annamaria Sassi Date: Mon, 22 Dec 2025 09:15:31 +0100 Subject: [PATCH] Componente con i template --- Test.UI/Components/Pages/Home.razor | 41 +- Test.UI/Components/Pages/Home.razor.cs | 284 +++++-- .../WebWindowConfigurator.csproj | 9 +- WebWindowConfigurator/WebWindowMaker.razor | 700 +----------------- WebWindowConfigurator/WebWindowMaker.razor.cs | 471 +----------- 5 files changed, 297 insertions(+), 1208 deletions(-) diff --git a/Test.UI/Components/Pages/Home.razor b/Test.UI/Components/Pages/Home.razor index 87ac691..937c361 100644 --- a/Test.UI/Components/Pages/Home.razor +++ b/Test.UI/Components/Pages/Home.razor @@ -2,22 +2,39 @@ @page "/Home" @rendermode InteractiveServer -Home +Select template -@if (isLoading) +@if(SelTemplate == null) { - + + } else { - - + + +
+
+ @JsonSer +
+
+} +@if (!string.IsNullOrEmpty(outClose)) +{ +
+ @outClose +
+} +else if (!string.IsNullOrEmpty(outSave)) +{ +
+ @outSave +
} -@*

- @m_CurrArgs.GetValueOrDefault("Jwd") -

*@ + diff --git a/Test.UI/Components/Pages/Home.razor.cs b/Test.UI/Components/Pages/Home.razor.cs index e749c4c..8ed9c13 100644 --- a/Test.UI/Components/Pages/Home.razor.cs +++ b/Test.UI/Components/Pages/Home.razor.cs @@ -4,6 +4,9 @@ using EgwCoreLib.Lux.Data.Services; using Microsoft.AspNetCore.Components; using Newtonsoft.Json; using WebWindowConfigurator; +using WebWindowComplex; +using Egw.Window.Data; +using WebWindowComplex.DTO; using WebWindowConfigurator.DTO; namespace Test.UI.Components.Pages @@ -12,7 +15,7 @@ namespace Test.UI.Components.Pages { #region Public Properties - public Template SelTemplate { get; set; } = new Template(0, "---SELECT---", "", ""); + public Template SelTemplate { get; set; } = null; #endregion Public Properties @@ -21,14 +24,29 @@ namespace Test.UI.Components.Pages public void Dispose() { DLService.PipeSvg.EA_NewMessage -= PipeSvg_EA_NewMessage; + DLService.PipeShape.EA_NewMessage -= PipeShape_EA_NewMessage; + DLService.PipeHwOpt.EA_NewMessage -= PipeHwOption_EA_NewMessage; } #endregion Public Methods #region Protected Fields + protected Dictionary currGroupShape = new Dictionary(); + protected Dictionary currHwOption = new Dictionary(); protected string currJwd = ""; protected Dictionary m_CurrArgs = new Dictionary(); + protected string prevJwd = ""; + + /// + /// Configurazione elenchi anagrafiche + /// + protected BaseListPayload SetupList = new BaseListPayload(); + + /// + /// Predisposizione valori live SVG/JWD + /// + protected LivePayload CurrData = new LivePayload(); #endregion Protected Fields @@ -36,6 +54,49 @@ namespace Test.UI.Components.Pages protected List AvailTemplateList { get; set; } = new List(); + protected List AvailColorMaterialList { get; set; } = new List() + { + new string("White"), + new string("Black"), + new string("Blu") + }; + + protected List AvailFamilyHardwareList { get; set; } = new List() + { + new string("ArTech"), + new string("ArTechPlana") + }; + + protected List AvailGlassList { get; set; } = new List() + { + new string("Vetro BE 2S 4/12/4"), + new string("Vetro BE 2S 4/16/4"), + new string("Vetro BE 3S 4/12/4/12/4"), + new string("Vetro BE 3S 4/16/4/16/4"), + new string("Vetro BE 2S 4T/12/4T"), + new string("Vetro BE 2S 4T/16/4T") + }; + + protected List AvailHardwareList { get; set; } = new List(); + + protected List AvailMaterialList { get; set; } = new List() + { + new string("Pino"), + new string("Abete") + }; + + protected List AvailProfileList { get; set; } = new List() + { + new string("Profilo78"), + new string("ProfiloSaomad") + }; + + protected List AvailThresholdList { get; set; } = new List() + { + new Threshold(1, "Bottom"), + new Threshold(3, "Threshold") + }; + [Inject] protected IConfiguration Config { get; set; } = null!; @@ -58,16 +119,26 @@ namespace Test.UI.Components.Pages #region Protected Methods + protected override void OnAfterRender(bool firstRender) + { + if (firstRender) + { + // JS interop or data fetches go here + isInteractive = true; + } + } protected override async Task OnInitializedAsync() { - isLoading = true; ConfInit(); + Random random = new Random(); + CalcUid = Convert.ToString(random.Next(1000, 10000)); + windowUid = CalcUid; DLService.PipeSvg.EA_NewMessage += PipeSvg_EA_NewMessage; + DLService.PipeShape.EA_NewMessage += PipeShape_EA_NewMessage; + DLService.PipeHwOpt.EA_NewMessage += PipeHwOption_EA_NewMessage; await ReloadData(); } - private bool isLoading = false; - #endregion Protected Methods #region Private Fields @@ -75,50 +146,40 @@ namespace Test.UI.Components.Pages private string apiUrl = ""; private string calcTag = ""; private string CalcUid = "CurrWindow"; - private string cFile = "Data/Setup.json"; + private string cFileTemplate = "Data/Setup.json"; private TemplateSelectDTO? currSel = null; private string currSvg = ""; + private string channelHwOpt = ""; + private string channelShape = ""; + private string channelSvg = ""; private string imgBasePath = ""; private string GenericBasePath = ""; - private string subChannel = ""; + private string cFileHardware = "Hardware/Setup.json"; + + private string outClose = ""; + private string outSave = ""; + + private string windowUid = "CurrWindow"; + + /// + /// Semaforo x definire se sia già in modalità ionterattiva o di prerendering + /// + private bool isInteractive = false; #endregion Private Fields - #region Private Properties - - private string windowUid = "CurrWindow"; - //{ - // get - // { - // string answ = ""; - // if (currSel != null) - // { - // answ = currSel.SVGFileName.Replace(".svg", ""); - // } - // return answ; - // } - //} - - #endregion Private Properties - #region Private Methods - private async void PipeSvg_EA_NewMessage(object? sender, EventArgs e) + /// + /// Effettua chiusura oggetto con eventuale save + /// + /// + private void CloseObj(bool reqSave) { - // aggiorno visualizzazione - PubSubEventArgs currArgs = (PubSubEventArgs)e; - // conversione on-the-fly SVG da mostrare - if (!string.IsNullOrEmpty(currArgs.newMessage)) - { - if (currArgs.msgUid.Equals($"{subChannel}:{windowUid}")) - { - currSvg = currArgs.newMessage; - } - await InvokeAsync(StateHasChanged); - } - await Task.Delay(1); + outClose = !reqSave ? "Richiesto chiusura!" : ""; + outSave = reqSave ? "Richiesto salvataggio!" : ""; } private void ConfInit() @@ -127,7 +188,118 @@ namespace Test.UI.Components.Pages imgBasePath = Config.GetValue("ServerConf:ImageBaseUrl") ?? ""; GenericBasePath = Config.GetValue("ServerConf:GenericBaseUrl") ?? ""; calcTag = Config.GetValue("ServerConf:CalcTag") ?? ""; - subChannel = Config.GetValue("ServerConf:SvgChannel") ?? ""; + channelSvg = Config.GetValue("ServerConf:ChannelSvg") ?? ""; + channelShape = Config.GetValue("ServerConf:ChannelShape") ?? ""; + channelHwOpt = Config.GetValue("ServerConf:ChannelHwOpt") ?? ""; + } + + /// + /// Esecuzione azione richiesta + /// + /// Azione richiesta + private void DoAction(LayoutConst.DataAction actReq) + { + switch (actReq) + { + case LayoutConst.DataAction.None: + break; + + case LayoutConst.DataAction.ResetDictShape: + CurrData.DictShape = new Dictionary(); + break; + + case LayoutConst.DataAction.ResetHwOpt: + CurrData.DictOptionsXml = new Dictionary(); + break; + + default: + break; + } + } + + private async Task ExecRequest(Dictionary CurrArgs) + { + // Proseguo solo se sono in interattivo (NO prerender pagina) + if (isInteractive) + { + outClose = ""; + outSave = ""; + // verifico se contiene JWD, lo aggiorno + if (CurrArgs.ContainsKey("SerializedData")) + { + currJwd = CurrArgs["SerializedData"]; + CurrData.CurrJwd = currJwd; + } + // se il SSE variato --> invio + if (!currJwd.Equals(prevJwd) || !EgwCoreLib.Utils.DictUtils.DictAreEqual(m_CurrArgs, CurrArgs)) + { + m_CurrArgs = CurrArgs; + prevJwd = currJwd; + CalcRequestDTO calcRequestDTO = new CalcRequestDTO(); + calcRequestDTO.EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; + calcRequestDTO.DictExec = m_CurrArgs; + // chiamo la chiamata POST alla API, che manda la richiesta via REDIS + await ICService.CallRestPost($"{apiUrl}/{GenericBasePath}", $"{calcTag}/{CalcUid}", calcRequestDTO); + } + } + } + + private async void PipeHwOption_EA_NewMessage(object? sender, EventArgs e) + { + // aggiorno visualizzazione + PubSubEventArgs currArgs = (PubSubEventArgs)e; + // conversione on-the-fly SVG da mostrare + if (!string.IsNullOrEmpty(currArgs.newMessage)) + { + if (currArgs.msgUid.StartsWith($"{channelHwOpt}:{windowUid}") && currArgs.newMessage.Length > 2) + { + // deserializzo il dizionario delle risposte... + Dictionary rawDict = JsonConvert.DeserializeObject>(currArgs.newMessage) ?? new Dictionary(); + if (rawDict.Count > 0) + { + currHwOption = rawDict; + CurrData.DictOptionsXml = currHwOption; + } + } + await InvokeAsync(StateHasChanged); + } + await Task.Delay(1); + } + + private async void PipeSvg_EA_NewMessage(object? sender, EventArgs e) + { + // aggiorno visualizzazione + PubSubEventArgs currArgs = (PubSubEventArgs)e; + // conversione on-the-fly SVG da mostrare + if (!string.IsNullOrEmpty(currArgs.newMessage)) + { + if (currArgs.msgUid.Equals($"{channelSvg}:{windowUid}")) + { + currSvg = currArgs.newMessage; + CurrData.SvgPreview = currArgs.newMessage; + } + await InvokeAsync(StateHasChanged); + } + await Task.Delay(1); + } + + private async void PipeShape_EA_NewMessage(object? sender, EventArgs e) + { + // aggiorno visualizzazione + PubSubEventArgs currArgs = (PubSubEventArgs)e; + // conversione on-the-fly SVG da mostrare + if (!string.IsNullOrEmpty(currArgs.newMessage) && currArgs.newMessage.Length > 2) + { + if (currArgs.msgUid.StartsWith($"{channelShape}:{windowUid}")) + { + // deserializzo il dizionario delle risposte... + var rawDict = JsonConvert.DeserializeObject>(currArgs.newMessage); + currGroupShape = rawDict ?? new Dictionary(); + CurrData.DictShape = currGroupShape; + } + await InvokeAsync(StateHasChanged); + } + await Task.Delay(1); } /// @@ -136,13 +308,13 @@ namespace Test.UI.Components.Pages /// private async Task ReloadData() { - //return base.OnInitializedAsync(); + // Caricamento lista Template AvailTemplateList = new List(); await Task.Delay(100); // brutale, da rivedere... - if (File.Exists(cFile)) + if (File.Exists(cFileTemplate)) { - string rawVal = File.ReadAllText(cFile); + string rawVal = File.ReadAllText(cFileTemplate); var rawList = JsonConvert.DeserializeObject>(rawVal) ?? new List(); // calcolo URL immagini... DTO interno da rivedere? @@ -153,19 +325,16 @@ namespace Test.UI.Components.Pages AvailTemplateList.Add(item); } } - isLoading = false; - } - - private async Task SaveJWD(Dictionary CurrArgs) - { - m_CurrArgs = CurrArgs; - // chiamo la chiamata POST alla API, che manda la richiesta via REDIS - if (currSel != null) + // Caricamento lista hardware + AvailHardwareList = new List(); + if (File.Exists(cFileHardware)) { - CalcRequestDTO calcRequestDTO = new CalcRequestDTO(); - calcRequestDTO.EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; - calcRequestDTO.DictExec = m_CurrArgs; - await ICService.CallRestPost($"{apiUrl}/{GenericBasePath}", $"{calcTag}/{CalcUid}", calcRequestDTO); + string rawValHW = File.ReadAllText(cFileHardware); + var rawListHW = JsonConvert.DeserializeObject>(rawValHW) ?? new List(); + foreach (var item in rawListHW) + { + AvailHardwareList.Add(item); + } } } @@ -179,6 +348,17 @@ namespace Test.UI.Components.Pages rawVal = File.ReadAllText(selTemp.JwdFileName); } SelTemplate = new Template(selTemp.Index, selTemp.Description, selTemp.SVGFileName, rawVal); + CurrData.CurrJwd = rawVal; + SetupList = new BaseListPayload() + { + ColorMaterial = AvailColorMaterialList, + FamilyHardware = AvailFamilyHardwareList, + Glass = AvailGlassList, + Hardware = AvailHardwareList, + Material = AvailMaterialList, + Profile = AvailProfileList, + Threshold = AvailThresholdList + }; } #endregion Private Methods diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index 99deb6a..767c465 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.12.1812 + 2.7.12.1917 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -26,7 +26,7 @@ - + @@ -494,6 +494,11 @@ + + + + + diff --git a/WebWindowConfigurator/WebWindowMaker.razor b/WebWindowConfigurator/WebWindowMaker.razor index c93c263..22e0607 100644 --- a/WebWindowConfigurator/WebWindowMaker.razor +++ b/WebWindowConfigurator/WebWindowMaker.razor @@ -1,679 +1,33 @@ -
-
-
-
-
-
- -
-
- @if (currStep != CompileStep.Template) - { -
- -
- } -
- -
-
- -
-
-
-
-
-
- @if (currStep == CompileStep.Template) +
+
+
Template
+
+
+
+ + + + + + + + + + @foreach (var item in TemplateDTOList) { -
#ImageDescription
- - - - - - - - - @foreach (var item in IN_TemplateDTOList) - { - string colorClass = ""; - @if (SelTemplateDTO != null && item.Index == SelTemplateDTO.Index) - colorClass = "table-success"; - else - colorClass = ""; - - - - - - } - -
#ImageDescription
@item.Index@item.Description
- } - @if (currStep == CompileStep.Frame) - { - @if(m_CurrWindow != null) - { - m_PreviousWindow = m_CurrWindow; - } -
-
-
-
- - -
-
-
-
Dimension
- @foreach (FrameDimension dimension in FrameWindow.DimensionList) - { -
- @dimension.sName - - mm -
- } -
-
-
-
-
Frame joints
-
-
- -
-
- -
-
- -
-
- @foreach (Joint joint in FrameWindow.JointList) - { -
- - -
- } -
-
- @if (m_SashList.Count == 0) - { -
-
-
Bottom rail
-
- Quantity - -
-
-
- } -
-
-
- } - else if (currStep == CompileStep.Split) - { - int numSplit = 0; -
-
-
-
- @for (int i = 0; i < SplitList.Count; i++) - { - Split currSplit = SplitList[i]; -
-
-
- @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)) - { -
@("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)) - { -
@("Sash " + (j + 1) + " - anta " + (k + 1))
- } - } - } - } - } - else if (currSplit.ParentArea is Splitted) - { - for(int j = 0; j < SplittedList.Count; j++) - { - if (SplittedList[j].Equals(currSplit.ParentArea)) - { - numSplit++; -
@("Area di split " + numSplit)
- } - } - } - else - { -
@("Frame")
- } -
-
-
-
Split
-
- -
-
- Number - -
-
- - -
- @foreach (var dim in currSplit.SplitPositionList) - { - string desc = ""; - @if (currSplit.SelSplitShape == Json.WindowConst.SplitShapes.VERTICAL) - { - @if (currSplit.SplitPositionList.IndexOf(dim) == 0) - { - desc = "Larg. area sx split"; - } - else - { - desc = "Larg. area dx split"; - } - } - else - { - @if (currSplit.SplitPositionList.IndexOf(dim) == 0) - { - desc = "Altez. area sotto split"; - } - else - { - desc = "Altez. area sopra split"; - } - } -
- @desc - - % -
- } -
-
-
-
-
-
- } -
-
-
-
- } - else if (currStep == CompileStep.Sash) - { - @if (currSash >= SashList.Count || currSash == -1) - { - currStep = CompileStep.Frame; - } + string colorClass = ""; + @if (SelTemplateDTO != null && item.Index == SelTemplateDTO.Index) + colorClass = "table-success"; else - { - Sash item = SashList[currSash]; -
-
-
-
-
- Number - -
-
-
-
-
-
-
-
Orientation
-
- - -
-
-
-
-
-
-
-
Bottom rail
-
- Quantity - -
-
-
-
-
-
- @for (int i = 0; i <= item.SashList.Count / 2; i++) - { - for (int j = 0; j < 2 && (i * 2 + j <= item.SashList.Count - 1); j++) - { - SashDimension sash = item.SashList[i * 2 + j]; -
-
-
- @if (item.SashList.Count == 1) - { -
Opening
- } - else - { -
Sash opening @(i * 2 + j + 1)
- } -
- - -
-
- Dimension - - % -
-
-
- -
-
- -
-
- @*
- @for (int k = 1; k <= i * 2 + j; k++) - { - int IndexCopy = k; - int IndexModify = i * 2 + j; -
-
- -
-
- } -
*@ -
-
-
- } - } -
-
-
-
-
-
Sash joints
-
-
- -
-
- -
-
- -
-
- @foreach (Joint joint in item.JointList) - { -
- - -
- } -
-
-
-
- @for (int i = 0; i < item.AreaList.Count; i++) - { - Area anta; - @if (item.AreaList[i] is Splitted) - { - anta = item.AreaList[i]; - } - else - { - anta = item; - } - @if (!(anta.AreaList[0] is Split)) - { -
-
-
-
Anta @(i + 1)
-
- -
-
-
-
- } - } -
-
- -
-
- } + colorClass = ""; + + @item.Index + + @item.Description + } - else if (currStep == CompileStep.Fill) - { -
-
-
-
-
-
-
-
-
Fill Area
-
-
-
-
- -
-
- -
-
-
-
-
-
-
- @for(int i = 0; i < FillList.Count; i += 2) - { - Fill currFill = FillList[i]; -
-
-
- @if (FillList.Count == 1) - { -
Fill
- } - else - { -
Fill @(FillList.IndexOf(currFill) + 1)
- } -
- -
-
-
-
- @if( i + 1 < FillList.Count) - { - Fill nextFill = FillList[i+1]; -
-
-
- @if (FillList.Count == 1) - { -
Fill
- } - else - { -
Fill @(FillList.IndexOf(nextFill) + 1)
- } -
- -
-
-
-
- } - } -
-
-
- } - else if (currStep == CompileStep.General) - { -
-
-
-
-
-
-
Generic
-
- - -
-
- - -
-
-
-
-
-
-
-
Fill type
-
- - -
-
- - -
-
-
-
-
-
-
-
-
-
Color
-
- - -
-
-

-

- -
-
- -
-
- -
-

-
-
-

-

- -
-
- -
-
- -
-

-
-
-
-
-
- @if(m_SashList.Count > 0) - { -
-
-
-
-
Hardware
-
- - -
-
- - -
-
- - -
-
-
-
-
- } -
-
- } -
-
+ +
- @if(currStep != CompileStep.Template) - { -
- @outSvg -
- }
- diff --git a/WebWindowConfigurator/WebWindowMaker.razor.cs b/WebWindowConfigurator/WebWindowMaker.razor.cs index fa301f1..82c8ce4 100644 --- a/WebWindowConfigurator/WebWindowMaker.razor.cs +++ b/WebWindowConfigurator/WebWindowMaker.razor.cs @@ -9,13 +9,10 @@ using static WebWindowConfigurator.Json.WindowConst; namespace WebWindowConfigurator { - public partial class WebWindowMaker : IDisposable + public partial class WebWindowMaker { #region Public Properties - [Parameter] - public string CssSvg { get; set; } = "responsive-svg"; - [Parameter] public EventCallback EC_OnClose { get; set; } @@ -23,210 +20,25 @@ namespace WebWindowConfigurator public EventCallback EC_OnSelectedTemplate { get; set; } [Parameter] - public EventCallback> EC_OnUpdate { get; set; } + public List TemplateDTOList { get; set; } = null!; - [Parameter] - public Template IN_SelTemplate - { - get => m_SelTemplate; - set - { - // Se non ho ancora selezionato template oppure se cambio template di selezione - if (value != null && (m_SelTemplate == null || (m_SelTemplate != null && value.nIndex != m_SelTemplate.nIndex)) && !string.IsNullOrEmpty(value.JWD)) - { - m_SelTemplate = value; - 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 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) - { - m_FillList = new List(); - m_SashList = new List(); - m_SplitList = new List(); - m_SplittedList = new List(); - CreateWindowsList(m_CurrWindow.AreaList[0]); - } - } - } - - [Parameter] - public List IN_TemplateDTOList { get; set; } = null!; - - [Parameter] - public string LiveSVG - { - get => m_SelSVG; - set => m_SelSVG = value; - } #endregion Public Properties - #region Public Methods - - public void Dispose() - { - if (m_CurrWindow != null) - { - m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview; - m_CurrWindow = null; - } - } - - #endregion Public Methods - - #region Protected Enums - - protected enum CompileStep - { - Template = 0, - Frame = 1, - Split, - Sash, - Fill, - General - } - - protected enum ColorWindow - { - Bianco = 0, - Grigio = 1, - Tortora, - Blu, - Verde, - Nero - } - - #endregion Protected Enums - #region Protected Properties - protected Frame FrameWindow - { - get => m_Frame; - set => m_Frame = value; - } - - protected string m_SelSVG { get; set; } = ""; - - /// - /// Componente SVG da mostrare - /// - protected MarkupString outSvg - { - get - { - // aggiunta gestione classe svg per posizionamento con costraints - var newSvg = LiveSVG.Replace(" SashList - { - get => m_SashList; - } - protected List SplitList - { - get => m_SplitList; - } - protected List FillList - { - get => m_FillList; - } - protected List SplittedList - { - get => m_SplittedList; - } - protected TemplateSelectDTO? SelTemplateDTO { get; set; } = null; #endregion Protected Properties #region Protected Methods - /// - /// Metodo per la scelta della maniglia univoca - /// - /// - /// - protected async Task changeHandle(SashDimension sashDim) - { - //if(m_SashList[0].AreaList.Count < 3) - //{ - foreach (SashDimension item in SashList[0].SashList) - { - if (item.Equals(sashDim)) - { - item.bHasHandle = true; - } - else - { - item.bHasHandle = false; - } - } - //} - await Task.Delay(1); - } - // 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("Jwd", CurrJwd); - Args.Add("Mode", 1.ToString()); - await EC_OnUpdate.InvokeAsync(Args); - } - } - - /// - /// Metodo di reset dei dati a quelli del template - /// - protected async Task DoReset() - { - 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; - m_FillList = new List(); - m_SashList = new List(); - m_SplitList = new List(); - m_SplittedList = new List(); - // popolo le liste Fill, Sash e Split - CreateWindowsList(m_CurrWindow.AreaList[0]); - currSash = -1; - await DoPreviewSvg(); - } - // Ancora da fare.. protected async Task DoSave() { @@ -245,292 +57,13 @@ namespace WebWindowConfigurator await EC_OnSelectedTemplate.InvokeAsync(newSel); } - /// - /// Metodo per cambiare step e aggiornare preview svg - /// - /// step successivo - protected async void NextStepAndPreview(CompileStep newStep, int Index = -1) - { - currStep = newStep; - if (newStep == CompileStep.Sash) - currSash = Index; - else - currSash = -1; - await DoPreviewSvg(); - } - - //protected void CreateWindowsList(Area node, bool IntoSash) - //{ - // if (node != null) - // { - // bool nodeIntoSash = false; - // if (node.ParentArea is Sash || IntoSash == true) - // nodeIntoSash = true; - // switch (node.AreaType) - // { - // case AreaTypes.FRAME: - // { - // FrameWindow = (Frame)node; - // if (node.AreaList[0] is Split) - // SplitParentList.Add(new SplitParent(AreaTypes.FRAME, "Frame", nodeIntoSash, node.AreaList[0], null)); - // else - // SplitParentList.Add(new SplitParent(AreaTypes.FRAME, "Frame", nodeIntoSash, null, node)); - // break; - // } - // case AreaTypes.SASH: - // { - // m_SashList.Add((Sash)node); - // if (node.AreaList[0] is Fill) - // SplitParentList.Add(new SplitParent(AreaTypes.SPLITTED, "Sash", nodeIntoSash, null, node)); - // else if (node.AreaList[0] is Split) - // SplitParentList.Add(new SplitParent(AreaTypes.SPLITTED, "Sash into split", nodeIntoSash, node.AreaList[0], node)); - // break; - // } - // case AreaTypes.FILL: - // { - // m_FillList.Add((Fill)node); - // break; - // } - // case AreaTypes.SPLIT: - // { - // m_SplitList.Add((Split)node); - // break; - // } - // case AreaTypes.SPLITTED: - // { - // m_SplittedList.Add((Splitted)node); - // if (node.AreaList[0] is Split) - // { - // if (node.ParentArea is Sash) - // SplitParentList.Add(new SplitParent(AreaTypes.SPLITTED, "Sash", nodeIntoSash, node.AreaList[0], node)); - // else - // SplitParentList.Add(new SplitParent(AreaTypes.SPLITTED, "Split", nodeIntoSash, node.AreaList[0], node)); - // } - // else if (node.AreaList[0] is Sash) - // { - // SplitParentList.Add(new SplitParent(AreaTypes.SPLITTED, "Split area with sash", nodeIntoSash, null, node)); - // } - // else - // { - // if (node.ParentArea is Sash) - // SplitParentList.Add(new SplitParent(AreaTypes.SPLITTED, "Sash", nodeIntoSash, null, node)); - // else if (nodeIntoSash) - // SplitParentList.Add(new SplitParent(AreaTypes.SPLITTED, "Area split into sash", nodeIntoSash, null, node)); - // else - // SplitParentList.Add(new SplitParent(AreaTypes.SPLITTED, "Split", nodeIntoSash, null, node)); - // } - // break; - // } - // } - // foreach (var item in node.AreaList) - // { - // CreateWindowsList(item, nodeIntoSash); - // } - // } - //} - - protected void CreateWindowsList(Area node) - { - if (node != null) - { - 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: - { - m_SplittedList.Add((Splitted)node); - break; - } - } - foreach (var item in node.AreaList) - { - CreateWindowsList(item); - } - } - } - - - /// - /// 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) - /// oggetto a cui essere applicato (Frame o Sash) - /// - private async Task AllJointsFrame(int int_type, int int_place) - { - Joints type = Joints.ANGLED; - if (int_type == 2) - { - type = Joints.FULL_H; - } - else if (int_type == 3) - { - type = Joints.FULL_V; - } - if(int_place == 0) - { - foreach (Joint joint in FrameWindow.JointList) - { - joint.SetSelJointType(type); - } - } - else if(int_place == 1) - { - foreach (Joint joint in m_SashList[0].JointList) - { - joint.SetSelJointType(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) - /// oggetto a cui essere applicato (Frame o Sash) - /// - private async Task AllFill(int int_type) - { - FillTypes type = FillTypes.GLASS; - if (int_type == 2) - { - type = FillTypes.WOOD; - } - foreach (Fill currFill in m_FillList) - { - currFill.SetFillType(type); - } - await DoPreviewSvg(); - } - - private async Task SwapTwoAree(Area currArea) - { - currArea.SwapAree(); - await DoPreviewSvg(); - } - - #endregion Protected Methods - #region Private Fields - - private CompileStep currStep = CompileStep.Template; - - private ColorWindow currColorWin = ColorWindow.Bianco; - - private Frame m_Frame; - - private int currSash = -1; - - 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 enum positionJoints - { - BL=0, // Bottom Left - BR=1, // Bottom Right - TR, // Top Right - TL // Top Left - } - - #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!; #endregion Private Properties - #region Private Methods - - /// - /// Metodo per andare allo step successivo - /// - /// step successivo - private void AdvStep(CompileStep newStep) - { - currStep = newStep; - currSash = -1; - } - - - private void ChangeColorWindow(ColorWindow newColorWin) - { - currColorWin = newColorWin; - } - - private void M_CurrWindow_OnPreview(object? sender, OnPreviewEventArgs e) - { - Dictionary Args = new Dictionary(); - Args.Add("Jwd", e.sJwd); - Args.Add("Mode", 1.ToString()); - EC_OnUpdate.InvokeAsync(Args); - } - - /// - /// Calcola il css del tab selezionato - /// - /// - /// - private string tabNavCss(CompileStep testStep, int Index = -1) - { - if (testStep == CompileStep.Sash) - { - if ((currSash == 0 && Index == 0) || (currSash == 1 && Index == 1)) - { - return "nav-link active fw-bold"; - } - else - { - return "nav-link text-secondary"; - } - } - return (testStep == currStep) ? "nav-link active fw-bold" : "nav-link text-secondary"; - } - - private string buttonCss(ColorWindow testColor) - { - return testColor.Equals(currColorWin) ? "btn btn-outline-secondary active" : "btn btn-outline-secondary"; - } - - /// - /// Calcola larghezza colonna da mostrare - /// - /// - private string mainCss() - { - return currStep == CompileStep.Template ? "col-12" : "col-6"; - } - - #endregion Private Methods } } \ No newline at end of file