From 86fe2e64043f4ff79e926c948db08e9dd9eb7968 Mon Sep 17 00:00:00 2001 From: Annamaria Sassi Date: Tue, 30 Sep 2025 11:44:20 +0200 Subject: [PATCH] WebWindowComplex: - Aggiunto Nuget Web.Window.Data - Aggiornate classi Window e JsonUtility - Aggiornata interfaccia --- Test.UI/Components/Pages/EditJWD.razor | 5 +- Test.UI/Components/Pages/EditJWD.razor.cs | 1 + Test.UI/Components/Pages/Gerarchia.razor | 3 +- Test.UI/Components/Pages/Gerarchia.razor.cs | 1 + WebWindow.Base/WebWindow.Base.csproj | 13 +- WebWindowComplex/Json/JsonUtility.cs | 123 ++- WebWindowComplex/TableComp.razor | 909 ++++++++++-------- WebWindowComplex/TableComp.razor.cs | 242 +++-- WebWindowComplex/WebWindowComplex.csproj | 14 +- WebWindowComplex/Window.cs | 688 +++++++++---- .../WebWindowConfigurator.csproj | 14 +- WebWindowTest/Test.razor | 4 +- WebWindowTest/Test.razor.cs | 38 +- WebWindowTest/Window.cs | 4 - 14 files changed, 1325 insertions(+), 734 deletions(-) diff --git a/Test.UI/Components/Pages/EditJWD.razor b/Test.UI/Components/Pages/EditJWD.razor index de852b3..6147ac2 100644 --- a/Test.UI/Components/Pages/EditJWD.razor +++ b/Test.UI/Components/Pages/EditJWD.razor @@ -4,9 +4,7 @@ EditJWD - \ No newline at end of file diff --git a/Test.UI/Components/Pages/EditJWD.razor.cs b/Test.UI/Components/Pages/EditJWD.razor.cs index 9675361..9d7ee93 100644 --- a/Test.UI/Components/Pages/EditJWD.razor.cs +++ b/Test.UI/Components/Pages/EditJWD.razor.cs @@ -6,6 +6,7 @@ using Newtonsoft.Json; using NLog; using System.Diagnostics; using System.Security.AccessControl; +using Egw.Window.Data; using WebWindowComplex; using WebWindowComplex.DTO; diff --git a/Test.UI/Components/Pages/Gerarchia.razor b/Test.UI/Components/Pages/Gerarchia.razor index b5548ca..08a6bef 100644 --- a/Test.UI/Components/Pages/Gerarchia.razor +++ b/Test.UI/Components/Pages/Gerarchia.razor @@ -16,8 +16,7 @@ IN_SelGlass="@SelGlass" EC_OnUpdate="SaveJWD" EC_OnSelectedTemplate="SetTemplate" - LiveSVG="@currSvg" - CurrJwd="@InitialJwd"> + LiveSVG="@currSvg"> @*

diff --git a/Test.UI/Components/Pages/Gerarchia.razor.cs b/Test.UI/Components/Pages/Gerarchia.razor.cs index 9984302..010780f 100644 --- a/Test.UI/Components/Pages/Gerarchia.razor.cs +++ b/Test.UI/Components/Pages/Gerarchia.razor.cs @@ -6,6 +6,7 @@ using Newtonsoft.Json; using NLog; using System.Diagnostics; using System.Security.AccessControl; +using Egw.Window.Data; using WebWindowComplex; using WebWindowComplex.DTO; diff --git a/WebWindow.Base/WebWindow.Base.csproj b/WebWindow.Base/WebWindow.Base.csproj index 2ebf2a1..9e8530a 100644 --- a/WebWindow.Base/WebWindow.Base.csproj +++ b/WebWindow.Base/WebWindow.Base.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.9.3009 + 2.7.9.3011 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -89,6 +89,17 @@ + + + + + + + + + + + diff --git a/WebWindowComplex/Json/JsonUtility.cs b/WebWindowComplex/Json/JsonUtility.cs index bc198a5..164836b 100644 --- a/WebWindowComplex/Json/JsonUtility.cs +++ b/WebWindowComplex/Json/JsonUtility.cs @@ -105,8 +105,21 @@ namespace WebWindowComplex.Json public class JsonArea { - private List m_AreaList = new List(); + private int m_nIdGroup; + [JsonProperty] + public int IdGroup + { + get + { + return m_nIdGroup; + } + set + { + m_nIdGroup = value; + } + } + private List m_AreaList = new List(); [JsonProperty] public List AreaList { @@ -219,16 +232,18 @@ namespace WebWindowComplex.Json { } - public JsonFrame(Shapes Shape, bool BottomRail, int BottomRailQty) : base(AreaTypes.FRAME) + public JsonFrame(Shapes Shape, bool BottomRail, int BottomRailQty, int nIdGroup) : base(AreaTypes.FRAME) { m_Shape = Shape; m_bBottomRail = BottomRail; m_nBottomRailQty = BottomRailQty; + IdGroup = nIdGroup; } internal override Area Deserialize(Area ParentArea, Window ParentWindow) { Frame newFrame = new Frame(null, ParentWindow); + newFrame.SetIdGroup(IdGroup); newFrame.SetAreaType(AreaTypes.FRAME); newFrame.SetSelShape(m_Shape); newFrame.SetBottomRail(m_bBottomRail); @@ -355,18 +370,20 @@ namespace WebWindowComplex.Json { } - public JsonSash(bool bIsSashVertical, SashTypes SashType, bool SashBottomRail, int SashBottomRailQty, string Hardware) : base(AreaTypes.SASH) + public JsonSash(bool bIsSashVertical, SashTypes SashType, bool SashBottomRail, int SashBottomRailQty, string Hardware, int nIdGroup) : base(AreaTypes.SASH) { m_bIsSashVertical = bIsSashVertical; m_SashType = SashType; m_bBottomRail = SashBottomRail; m_nBottomRailQty = SashBottomRailQty; m_Hardware = Hardware; + IdGroup = nIdGroup; } internal override Area Deserialize(Area ParentArea, Window ParentWindow) { Sash newSash = new Sash(ParentArea, ParentWindow); + newSash.SetIdGroup(IdGroup); newSash.SetAreaType(AreaTypes.SASH); newSash.SetSashQty(m_SashList.Count); newSash.SetIsSashVertical(m_bIsSashVertical); @@ -411,17 +428,45 @@ namespace WebWindowComplex.Json } } - private List m_SplitPositionList = new List(); + private bool m_SplitStartVert; [JsonProperty] - public List SplitPositionList + public bool SplitStartVert { get { - return m_SplitPositionList; + return m_SplitStartVert; } set { - m_SplitPositionList = value; + m_SplitStartVert = value; + } + } + + private List m_SplitVertList = new List(); + [JsonProperty] + public List SplitVertList + { + get + { + return m_SplitVertList; + } + set + { + m_SplitVertList = value; + } + } + + private List m_SplitHorizList = new List(); + [JsonProperty] + public List SplitHorizList + { + get + { + return m_SplitHorizList; + } + set + { + m_SplitHorizList = value; } } @@ -429,22 +474,42 @@ namespace WebWindowComplex.Json { } - public JsonSplit(SplitShapes SplitShape) : base(AreaTypes.SPLIT) + public JsonSplit(SplitShapes SplitShape, int nIdGroup) : base(AreaTypes.SPLIT) { m_SplitShape = SplitShape; + IdGroup = nIdGroup; } internal override Area Deserialize(Area ParentArea, Window ParentWindow) { Split Split = new Split(ParentArea, ParentWindow); + Split.SetIdGroup(IdGroup); Split.SetAreaType(AreaTypes.SPLIT); Split.SetSplitShape(m_SplitShape, true); - Split.SetSplitQty(m_SplitPositionList.Count - 1, true); - //Split.AppliedDone(); - for (var SplitIndex = 0; SplitIndex <= m_SplitPositionList.Count - 1; SplitIndex++) + Split.SetSplitStartVert(m_SplitStartVert); + if (m_SplitVertList.Count == 0) + Split.SetSplitQtyVert(0, true); + else { - Split.SplitPositionList[SplitIndex].SetIsRelative(m_SplitPositionList[SplitIndex].bIsRelative); - Split.SplitPositionList[SplitIndex].SetDimension(m_SplitPositionList[SplitIndex].dDimension); + //Split.SplitVertList.Clear(); + Split.SetSplitQtyVert(m_SplitVertList.Count - 1, true); + for (var SplitIndex = 0; SplitIndex <= m_SplitVertList.Count - 1; SplitIndex++) + { + Split.SplitVertList[SplitIndex].SetIsRelative(m_SplitVertList[SplitIndex].bIsRelative); + Split.SplitVertList[SplitIndex].SetDimension(m_SplitVertList[SplitIndex].dDimension); + } + } + if (m_SplitHorizList.Count == 0) + Split.SetSplitQtyHoriz(0, true); + else + { + //Split.SplitHorizList.Clear(); + Split.SetSplitQtyHoriz(m_SplitHorizList.Count - 1, true); + for (var SplitIndex = 0; SplitIndex <= m_SplitHorizList.Count - 1; SplitIndex++) + { + Split.SplitHorizList[SplitIndex].SetIsRelative(m_SplitHorizList[SplitIndex].bIsRelative); + Split.SplitHorizList[SplitIndex].SetDimension(m_SplitHorizList[SplitIndex].dDimension); + } } foreach (var Area in AreaList) { @@ -463,22 +528,27 @@ namespace WebWindowComplex.Json public JsonSplitted() : base(AreaTypes.SPLITTED) { } + public JsonSplitted(int nIdGroup) : base(AreaTypes.SPLITTED) + { + IdGroup = nIdGroup; + } internal override Area Deserialize(Area ParentArea, Window ParentWindow) { - Splitted Split = new Splitted(ParentArea, ParentWindow); - Split.SetAreaType(AreaTypes.SPLITTED); + Splitted newSplitted = new Splitted(ParentArea, ParentWindow); + newSplitted.SetIdGroup(IdGroup); + newSplitted.SetAreaType(AreaTypes.SPLITTED); //Split.AppliedDone(); foreach (var Area in AreaList) { - var AreaDeserealized = Area.Deserialize(Split, ParentWindow); + var AreaDeserealized = Area.Deserialize(newSplitted, ParentWindow); if (AreaDeserealized != null) { - Split.AreaList.Add(AreaDeserealized); + newSplitted.AreaList.Add(AreaDeserealized); } } - return Split; + return newSplitted; } } @@ -503,14 +573,16 @@ namespace WebWindowComplex.Json { } - public JsonFill(FillTypes FillType) : base(AreaTypes.FILL) + public JsonFill(FillTypes FillType, int nIdGroup) : base(AreaTypes.FILL) { m_FillType = FillType; + IdGroup = nIdGroup; } internal override Area Deserialize(Area ParentArea, Window ParentWindow) { Fill Fill = new Fill(ParentArea, ParentWindow); + Fill.SetIdGroup(IdGroup); Fill.SetAreaType(AreaTypes.FILL); Fill.SetFillType(m_FillType); //Fill.AppliedDone(); @@ -612,6 +684,16 @@ namespace WebWindowComplex.Json public class JsonSashDimension { + private int m_nSashId; + [JsonProperty] + public int nSashId + { + get + { + return m_nSashId; + } + } + private Openings m_OpeningType; [JsonProperty] [JsonConverter(typeof(StringEnumConverter))] @@ -651,11 +733,12 @@ namespace WebWindowComplex.Json } } - public JsonSashDimension(Openings OpeningType, bool bHasHandle, double dDimension) + public JsonSashDimension(Openings OpeningType, bool bHasHandle, double dDimension, int nSashId) { m_OpeningType = OpeningType; m_bHasHandle = bHasHandle; m_dDimension = dDimension; + m_nSashId = nSashId; } } diff --git a/WebWindowComplex/TableComp.razor b/WebWindowComplex/TableComp.razor index 1dd914a..0236d89 100644 --- a/WebWindowComplex/TableComp.razor +++ b/WebWindowComplex/TableComp.razor @@ -38,7 +38,7 @@ { int Index = i;

} } @@ -153,101 +153,138 @@ m_PreviousWindow = m_CurrWindow; }
-
-
-
-
- - -
-
-
-
-
-
-
-
Dimension
- @foreach (FrameDimension dimension in FrameWindow.DimensionList) - { -
- @dimension.sName - - mm -
- } +
+
+
+
+
+ +
-
-
-
-
-
-
Frame joints
-
-
- -
-
- -
-
- -
-
- @foreach (Joint joint in FrameWindow.JointList) - { -
- - -
- } -
-
-
- @if (!(FrameWindow.AreaList[0] is Split)) - { +
-
Frame
+
Dimension
+ @foreach (FrameDimension dimension in FrameWindow.DimensionList) + { +
+ @dimension.sName + + mm +
+ } +
+
+
+
+
+
+
Threshold
- + + +
+
+
+
+
+
+
+
+
+
Frame joints
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+ @foreach (Joint joint in FrameWindow.JointList) + { +
+ + +
+ } +
+
+
+ @if (!(FrameWindow.AreaList[0] is Split) || (SashList.Count == 0 && SplitList.Count == 0)) + { +
+
+
+
Area frame
+
+
+ @if (!(FrameWindow.AreaList[0] is Split)) + { +
+ +
+ } +
+ @if (SashList.Count == 0 && SplitList.Count == 0) + { +
+
+ +
+
+ } +
+
+
+
+ } +
+ @if (m_SashList.Count == 0) + { +
+
+
+
+
Bottom rail
+
+ Quantity + +
}
- @if (m_SashList.Count == 0) - { -
-
-
-
-
Bottom rail
-
- Quantity - -
-
-
-
-
- }
} @@ -260,86 +297,109 @@ @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 - { -
@("Frame")
- } +
@(descParentSplit(currSplit))
-
Split
- @if (currSplit.nSplitQty == 1) - { -
- +
+
+
Split
+
+
+
+ +
- } -
- Number -
-
- - +
+
+
+ @if ((currSplit.nSplitQtyVert == 1 && currSplit.nSplitQtyHoriz == 0) || (currSplit.nSplitQtyVert == 0 && currSplit.nSplitQtyHoriz == 1)) + { +
+ +
+ } +
- @foreach (var dim in currSplit.SplitPositionList) +
+
+
+ + +
+
+
+
+ @if (currSplit.nSplitQtyVert > 0) + { +
+
+ QtyVert + +
+
+ } + @if (currSplit.nSplitQtyHoriz > 0) + { +
+
+ QtyHoriz + +
+
+ } +
+
+ @if (currSplit.SplitVertList.Count > 0) + { +
+ @foreach (var dim in currSplit.SplitVertList) + { +
+ Width + + % +
+ } +
+ } + @if (currSplit.SplitHorizList.Count > 0) + { +
+ @foreach (var dim in currSplit.SplitHorizList) + { +
+ Height + + % +
+ + } +
+ } +
+ @if (currSplit.SelSplitShape == Json.WindowConst.SplitShapes.GRID) { - 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 - - % +
+
+
+
+ +
+
+ +
+
+
}
@@ -349,7 +409,8 @@
} - +
+
@for (int i = 0; i < SplittedList.Count; i++) { Splitted currSplitted = SplittedList[i]; @@ -360,7 +421,7 @@
- +
@for (int j = 0; j < SashList.Count; j++) @@ -368,7 +429,7 @@ int Index = j;
- +
} @@ -393,157 +454,122 @@ { Sash item = SashList[currSash];
-
-
-
-
- Number - -
-
-
-
-
-
-
-
Orientation
-
- - -
+
+
+
+
+
+
+
-
-
-
-
Bottom rail
-
- Quantity - -
+
+
+
+ Qty sash +
-
-
- @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) - { +
+
+
+
+
Orientation
- - + +
- } +
+
+
+
+
+
+
Bottom rail
+
+ Quantity + +
+
-
- @for (int i = 0; i < item.AreaList.Count; i++) +
+ @for (int i = 0; i <= item.SashList.Count / 2; i++) { - Area anta; - @if (item.AreaList[i] is Splitted) + for (int j = 0; j < 2 && (i * 2 + j <= item.SashList.Count - 1); j++) { - anta = item.AreaList[i]; - } - else - { - anta = item; - } - @if (!(anta.AreaList[0] is Split)) - { -
+ SashDimension sash = item.SashList[i * 2 + j]; + Area anta = item.AreaList[i * 2 + j]; +
-
Anta @(i + 1)
+ @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; +
+
+ +
+
+ }
@@ -551,33 +577,70 @@ } }
-
-
-
-
-
-
Hardware
-
-
-
- - +
+
+
+
+
Sash joints
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
-
+ @foreach (Joint joint in item.JointList) + {
- + + +
+ } +
+
+
+
+
+
+
+
+
Hardware
+
+
+
+ + +
+
+
+
+ +
+
@@ -593,20 +656,20 @@
-
+
-
-
-
Fill Area
+
Area Fill
+
+
+
+ +
-
-
-
- -
-
- +
+
+ +
@@ -669,121 +732,123 @@ else if (currStep == CompileStep.General) {
-
-
-
-
-
-
Generic
-
- - -
-
- - -
-
-
-
-
-
-
-
Fill type
-
- - -
-
- - -
-
-
-
-
-
-
-
-
-
Color
-
-
- - -
-
-
- - -
-
-
-
-
- @if (m_SashList.Count > 0) - { +
+
-
Hardware
+
Generic
- - + @for (int i = 0; i < IN_MaterialList.Count; i++) + { + + }
- - + + + + +
+
+
+
+
+
+
+
Fill type
+
+ +
- - + + +
- } +
+
+
+
+
Color
+
+
+ + +
+
+
+ + +
+
+
+
+
+ @if (m_SashList.Count > 0) + { +
+
+
+
+
Hardware
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+ } +
} diff --git a/WebWindowComplex/TableComp.razor.cs b/WebWindowComplex/TableComp.razor.cs index 22d230b..cd848ee 100644 --- a/WebWindowComplex/TableComp.razor.cs +++ b/WebWindowComplex/TableComp.razor.cs @@ -1,10 +1,12 @@ using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; +using Microsoft.Net.Http.Headers; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System.Reflection.Metadata; +using System.Reflection.Metadata.Ecma335; using System.Runtime.InteropServices; -using WebWindow.Base; +using Egw.Window.Data; using WebWindowComplex.DTO; using WebWindowComplex.Json; using static WebWindowComplex.Json.WindowConst; @@ -295,6 +297,62 @@ namespace WebWindowComplex 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; + currStep = CompileStep.Gerarchia; + await DoPreviewSvg(); + } + + // Ancora da fare.. + protected async Task DoSave() + { + //manca salvataggio JWD + await EC_OnClose.InvokeAsync(true); + } + /// /// Metodo per la scelta della maniglia univoca /// @@ -316,6 +374,20 @@ namespace WebWindowComplex } else { + if (item.bHasHandle) + { + switch (item.SelOpeningType) + { + case Openings.TILTTURN_LEFT: + item.SetOpeningType(Openings.TURNONLY_LEFT); + break; + case Openings.TILTTURN_RIGHT: + item.SetOpeningType(Openings.TURNONLY_RIGHT); + break; + default: + break; + } + } item.bHasHandle = false; } } @@ -323,58 +395,55 @@ namespace WebWindowComplex } } - // Ancora da fare... - protected async Task DoClose() - { - await EC_OnClose.InvokeAsync(true); - } - /// - /// Anteprima SVG + /// Metodo per la scelta dello split intero nella modalità griglia /// + /// split su cui si sceglie /// - protected async Task DoPreviewSvg() + protected void changeStartVert(ChangeEventArgs e, Split currSplit) { - if (m_CurrWindow != null) + // Cerco la Sash che si sta considerando nella lista Sash + foreach (Split s in SplitList) { - var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize(), Formatting.Indented); - Dictionary Args = new Dictionary(); - Args.Add("Mode", $"{(int)Enums.EngineQueryType.Preview}"); - Args.Add("Jwd", CurrJwd); - await EC_OnUpdate.InvokeAsync(Args); + if (s.Equals(currSplit)) + { + s.SetSplitStartVert((bool)e.Value); + } } } /// - /// Metodo di reset dei dati a quelli del template + /// Metodo per determinare la descrizione del parent dello split corrente /// - protected async Task DoReset() + /// split corrente + /// + protected string descParentSplit(Split currSplit) { - // Aggiornati parametri di ingresso selezionati - 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) + if ((currSplit.ParentArea is Splitted || currSplit.ParentArea is Sash) && SashList.Count > 0) { - m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview; - m_CurrWindow = null; + 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); + } + } + } + } } - m_CurrWindow = WindowFromJson.Deserialize(); - m_CurrWindow.OnPreview += M_CurrWindow_OnPreview; - // Aggiorante liste sash, split, splitted, fill e itemTable - UpdateLists(); - currSash = -1; - await DoPreviewSvg(); - } - - // Ancora da fare.. - protected async Task DoSave() - { - //manca salvataggio JWD - await EC_OnClose.InvokeAsync(true); + else + { + return "Frame"; + } + return ""; } /// @@ -387,20 +456,6 @@ namespace WebWindowComplex 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(); - } - /// /// Metodo per riempire le liste Sash, Split, Splitted e Fill /// @@ -719,8 +774,9 @@ namespace WebWindowComplex /// private async Task CopySash(Splitted currSplitted, int numSash) { - //Rimuovo contenuto di Splitted + //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); @@ -729,17 +785,6 @@ namespace WebWindowComplex await DoPreviewSvg(); } - /// - /// Metodo per scambiare due aree di uno split - /// - /// Area corrente - /// - private async Task SwapTwoAree(Area currArea) - { - currArea.SwapAree(); - await DoPreviewSvg(); - } - #endregion Protected Methods #region Private Fields @@ -768,6 +813,47 @@ namespace WebWindowComplex #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.Gerarchia; + } + + /// + /// Metodo per cambiare step e aggiornare preview svg + /// + /// step successivo + private async void NextStepAndPreview(CompileStep newStep, int Index = -1) + { + currStep = newStep; + if (newStep == CompileStep.Sash) + currSash = Index; + else + currSash = -1; + await DoPreviewSvg(); + } + /// /// Metodo per andare allo step successivo /// @@ -781,7 +867,7 @@ namespace WebWindowComplex private void M_CurrWindow_OnPreview(object? sender, OnPreviewEventArgs e) { Dictionary Args = new Dictionary(); - Args.Add("Mode", $"{(int)Enums.EngineQueryType.Preview}"); + Args.Add("Mode", $"{(int)Enums.QuestionModes.PREVIEW}"); Args.Add("Jwd", e.sJwd); EC_OnUpdate.InvokeAsync(Args); } @@ -812,13 +898,31 @@ namespace WebWindowComplex return (currStep == CompileStep.Template) ? "col-12" : "col-6"; } + /// + /// Calcola larghezza border descrizione split + /// + /// + private string splitCss(Split currSplit) + { + return (currSplit.SelSplitShape == SplitShapes.GRID) ? "col-sm-12" : "col-sm-6"; + } + + /// + /// Calcola larghezza border descrizione split + /// + /// + private string splitContentCss(Split currSplit) + { + return (currSplit.SelSplitShape == SplitShapes.GRID) ? "col-sm-6" : "col-sm-12"; + } + /// /// Calcola larghezza colonna header nav /// /// private string headerCss() { - return (currStep == CompileStep.Template) ? "col-10 d-grid gap-1 px-2 d-md-flex justify-content-md-start" : "col-8 d-grid gap-1 px-2 d-md-flex justify-content-md-start"; + return (currStep == CompileStep.Template) ? "col-8 d-grid gap-1 px-2 d-md-flex justify-content-md-start" : "col-8 d-grid gap-1 px-2 d-md-flex justify-content-md-start"; } /// @@ -827,7 +931,7 @@ namespace WebWindowComplex /// private string buttonCss() { - return (currStep == CompileStep.Template) ? "col-2 d-grid gap-1 d-md-flex justify-content-md-end" : "col-4 d-grid gap-1 d-md-flex justify-content-md-end"; + return (currStep == CompileStep.Template) ? "col-4 d-grid gap-1 d-md-flex justify-content-md-end" : "col-4 d-grid gap-1 d-md-flex justify-content-md-end"; } #endregion Private Methods diff --git a/WebWindowComplex/WebWindowComplex.csproj b/WebWindowComplex/WebWindowComplex.csproj index ff41b73..a556bc4 100644 --- a/WebWindowComplex/WebWindowComplex.csproj +++ b/WebWindowComplex/WebWindowComplex.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.9.3009 + 2.7.9.3011 Annamaria Sassi Egalware Componente gestione Configurazioni avanzate Window per LUX @@ -18,6 +18,7 @@ + @@ -67,6 +68,17 @@ + + + + + + + + + + + diff --git a/WebWindowComplex/Window.cs b/WebWindowComplex/Window.cs index 116d47e..5cbc801 100644 --- a/WebWindowComplex/Window.cs +++ b/WebWindowComplex/Window.cs @@ -5,10 +5,12 @@ using System.Collections.ObjectModel; using System.ComponentModel; using System.Drawing; using System.Runtime.Intrinsics.Arm; +using System.Xml.Linq; using System.Xml.Serialization; using WebWindowComplex.Json; -using static WebWindowComplex.ParametriOpzioni; +using Egw.Window.Data; using static WebWindowComplex.Json.WindowConst; +using static WebWindowComplex.ParametriOpzioni; namespace WebWindowComplex { @@ -96,7 +98,6 @@ namespace WebWindowComplex internal string sSerialized() { return JsonConvert.SerializeObject(Serialize(), Formatting.Indented); - } internal void OnUpdatePreview(string sJwd) @@ -122,6 +123,35 @@ namespace WebWindowComplex public abstract class Area { + // Conteggio dei macro elementi + private static int m_CounterGroup = 0; + public static void AddCounterGroup() + { + m_CounterGroup++; + } + public static int nCounterGroup + { + get => m_CounterGroup; + set => m_CounterGroup = value; + } + + private int m_IdGroup; + public int IdGroup + { + get + { + return m_IdGroup; + } + + set + { + m_IdGroup = value; + } + } + public void SetIdGroup(int nIdGroup) + { + m_IdGroup = nIdGroup; + } protected Window m_ParentWindow; public Window ParentWindow @@ -206,7 +236,8 @@ namespace WebWindowComplex // Aggiungo Area split di default Split SplitArea = Split.CreateSplit(this, SplitShapes.HORIZONTAL); // imposto i parametri di default - SplitArea.SetSplitQty(1); + SplitArea.SetSplitQtyHoriz(1); + SplitArea.SetSplitStartVert(false); // Aggiungo area AreaList.Add(SplitArea); // Creo le due aree Splitted @@ -380,6 +411,8 @@ namespace WebWindowComplex break; } } + // salvo tipo Joint + Joints oldJointType = JointList[0].SelJointType; // aggiungo Joint m_JointList.Clear(); switch (SelShape) @@ -391,17 +424,21 @@ namespace WebWindowComplex case Shapes.ARC: case Shapes.DOUBLEARC: { - JointList.Add(new Joint(this, 1, Joints.FULL_H)); - JointList.Add(new Joint(this, 2, Joints.FULL_H)); - JointList.Add(new Joint(this, 3, Joints.FULL_H)); - JointList.Add(new Joint(this, 4, Joints.FULL_H)); + JointList.Add(new Joint(this, 1, oldJointType)); + JointList.Add(new Joint(this, 2, oldJointType)); + JointList.Add(new Joint(this, 3, oldJointType)); + JointList.Add(new Joint(this, 4, oldJointType)); + //JointList.Add(new Joint(this, 1, Joints.FULL_H)); + //JointList.Add(new Joint(this, 2, Joints.FULL_H)); + //JointList.Add(new Joint(this, 3, Joints.FULL_H)); + //JointList.Add(new Joint(this, 4, Joints.FULL_H)); break; } case Shapes.ARC_FULL: { - JointList.Add(new Joint(this, 1, Joints.FULL_H)); - JointList.Add(new Joint(this, 2, Joints.FULL_H)); + JointList.Add(new Joint(this, 1, oldJointType)); + JointList.Add(new Joint(this, 2, oldJointType)); JointList.Add(new Joint(this, 3, Joints.ANGLED)); JointList.Add(new Joint(this, 4, Joints.ANGLED)); break; @@ -409,8 +446,8 @@ namespace WebWindowComplex case Shapes.TRIANGLE: { - JointList.Add(new Joint(this, 1, Joints.FULL_H)); - JointList.Add(new Joint(this, 2, Joints.FULL_H)); + JointList.Add(new Joint(this, 1, oldJointType)); + JointList.Add(new Joint(this, 2, oldJointType)); JointList.Add(new Joint(this, 3, Joints.ANGLED)); break; } @@ -621,7 +658,10 @@ namespace WebWindowComplex internal override JsonArea Serialize() { - JsonFrame JsonFrame = new JsonFrame(m_Shape, m_bBottomRail, m_nBottomRailQty); + Area.nCounterGroup = 0; + if (nCounterGroup < IdGroup) + Area.nCounterGroup = IdGroup; + JsonFrame JsonFrame = new JsonFrame(m_Shape, m_bBottomRail, m_nBottomRailQty, IdGroup); foreach (var Dimension in DimensionList) JsonFrame.DimensionList.Add(Dimension.Serialize()); foreach (var Joint in JointList) @@ -667,7 +707,7 @@ namespace WebWindowComplex // aggiungo area Sash di default for (var SplitIndex = m_SashList.Count; SplitIndex <= value - 1; SplitIndex++) { - SashList.Add(new SashDimension(dNewDimension, true, this)); + SashList.Add(new SashDimension(dNewDimension, true, this, SplitIndex + 1)); } } else if (value < m_SashList.Count) @@ -759,8 +799,9 @@ namespace WebWindowComplex } // Aggiungo all'ultimo Splitted l'area di vetro - Fill newFill = new Fill(AreaList[1], ParentWindow); - newFill.SetFillType(FillTypes.GLASS); + Fill newFill = Fill.CreateFill(AreaList[1], FillTypes.GLASS); + //Fill newFill = new Fill(AreaList[1], ParentWindow); + //newFill.SetFillType(FillTypes.GLASS); newFill.SetAreaType(AreaTypes.FILL); AreaList[AreaList.Count - 1].AreaList.Add(newFill); } @@ -773,37 +814,6 @@ namespace WebWindowComplex break; } } - //if (AreaList[AreaList.Count - 1].AreaList.Count == 0) - //{ - // if (ContentArea.Count > 0) - // { - // if (ContentArea[0] is Fill) - // { - // for (int SplitIndex = 0; SplitIndex <= AreaList.Count() - 1; SplitIndex++) - // { - // if (SplitIndex == 0) - // { - // AreaList[0].AreaList.Add(ContentArea[0]); - // } - // else - // { - // Fill f1 = (Fill)ContentArea[0]; - // AreaList[SplitIndex].AreaList.Add(Fill.CreateFill(AreaList[SplitIndex], f1.FillType)); - // } - // } - // } - // else - // { - // AreaList[0].AreaList.Add(ContentArea[0]); - // AreaList[1].AreaList.Add(ContentArea[0]); - // } - // } - // else - // { - // Fill f1 = (Fill)AreaList[AreaList.Count - 2].AreaList[0]; - // AreaList[AreaList.Count - 1].AreaList.Add(Fill.CreateFill(AreaList[AreaList.Count - 1], f1.FillType)); - // } - //} } } RefreshHardwareList(); @@ -829,7 +839,7 @@ namespace WebWindowComplex dNewDimension = dLastDimension / (Qty + 1 - nSashQty); // aggiungo area Sash di default for (var SplitIndex = m_SashList.Count; SplitIndex <= Qty - 1; SplitIndex++) - SashList.Add(new SashDimension(dNewDimension, true, this)); + SashList.Add(new SashDimension(dNewDimension, true, this, SplitIndex + 1)); } else if (Qty < m_SashList.Count) { @@ -1135,7 +1145,7 @@ namespace WebWindowComplex internal void SetSelHardwareFromId(string sId) { - m_SelHardware = m_HardwareList.FirstOrDefault(x => x.sId == sId) ?? new Hardware("", "", "", "", "", 0, 0); + m_SelHardware = m_HardwareList.FirstOrDefault(x => x.Id == sId) ?? new Hardware("", "", "", "", "", 0, 0); if (m_SelHardware == null) m_SelHardware = m_HardwareList[0]; } @@ -1184,6 +1194,8 @@ namespace WebWindowComplex internal static Sash CreateSash(Area Area) { Sash newSash = new Sash(Area, Area.ParentWindow); + AddCounterGroup(); + newSash.SetIdGroup(nCounterGroup); newSash.SetAreaType(AreaTypes.SASH); newSash.SetSashQty(1); newSash.SetOrientationSashType(OrientationSash.VERTICAL); @@ -1317,7 +1329,7 @@ namespace WebWindowComplex string sSashShape = FindSashShape(); string sOpeningType = ConvertOpeningType(); m_HardwareList = new ObservableCollection(from Hardware in m_HardwareCompleteList - where Hardware.sId == "000000" || (Hardware.sFamily == s_SelFamilyHW && Hardware.nSashQty == nSashQty && Hardware.sShape == sSashShape && Hardware.sOpeningType == sOpeningType) + where Hardware.Id == "000000" || (Hardware.FamilyName == s_SelFamilyHW && Hardware.SashQty == nSashQty && Hardware.Shape == sSashShape && Hardware.OpeningType == sOpeningType) select Hardware); } @@ -1358,6 +1370,8 @@ namespace WebWindowComplex public override Sash Copy(Area newParentArea) { Sash newSash = new Sash(newParentArea, m_ParentWindow); + AddCounterGroup(); + newSash.SetIdGroup(nCounterGroup); newSash.SetAreaType(AreaType); // Imposta la quantità di ante e definisce SashDimension di ogni anta ai valori di default newSash.SetSashQty(nSashQty); @@ -1387,9 +1401,20 @@ namespace WebWindowComplex return newSash; } + public void Remove() + { + ParentArea.AreaList.Remove(this); + Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS); + newFill.SetAreaType(AreaTypes.FILL); + ParentArea.AreaList.Add(newFill); + m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + } + internal override JsonArea Serialize() { - JsonSash JsonSash = new JsonSash(m_bIsSashVertical, m_SashType, m_bSashBottomRail, m_nSashBottomRailQty, m_SelHardware.sId); + if (nCounterGroup < IdGroup) + Area.nCounterGroup = IdGroup; + JsonSash JsonSash = new JsonSash(m_bIsSashVertical, m_SashType, m_bSashBottomRail, m_nSashBottomRailQty, m_SelHardware.Id, IdGroup); foreach (var SashDimension in SashList) JsonSash.SashList.Add(SashDimension.Serialize()); foreach (var Joint in JointList) @@ -1402,101 +1427,247 @@ namespace WebWindowComplex public class Split : Area { - public int nSplitQty + private bool m_bSplitStartVert = true; + public bool bSplitStartVert { get { - return m_SplitPositionList.Count > 0 ? m_SplitPositionList.Count - 1 : 0; + return m_bSplitStartVert; } set { - // Ricalcolo dimensioni aggiungendo split - if (value > m_SplitPositionList.Count - 1) + m_bSplitStartVert = value; + m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + } + } + internal void SetSplitStartVert(bool SplitStartVert) + { + bSplitStartVert = SplitStartVert; + } + public int nSplitQtyVert + { + get + { + return m_SplitVertList.Count > 0 ? m_SplitVertList.Count - 1 : 0; + } + set + { + if (value == 0) { - // recupero larghezza ultimo - double dLastDimension = 100; - double dNewDimension = 100; - if (m_SplitPositionList.Count > 0) + for (var SplitIndex = m_SplitVertList.Count - 1; SplitIndex >= value; SplitIndex += -1) + m_SplitVertList.RemoveAt(SplitIndex); + if (nSplitQtyHoriz == 0) { - dLastDimension = m_SplitPositionList[m_SplitPositionList.Count - 1].dDimension; - dNewDimension = dLastDimension / (value + 1 - nSplitQty); - m_SplitPositionList[m_SplitPositionList.Count - 1].SetDimension(dNewDimension); + ParentArea.AreaList.Remove(this); + Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS); + newFill.SetAreaType(AreaTypes.FILL); + ParentArea.AreaList.Add(newFill); } else - dNewDimension = dLastDimension / (value + 1 - nSplitQty); - // aggiungo area Split di default - for (var SplitIndex = m_SplitPositionList.Count; SplitIndex <= value; SplitIndex++) - SplitPositionList.Add(new SplitDimension(dNewDimension, true, this)); + SetSplitShape(SplitShapes.HORIZONTAL); } - else if (value == 0) - { - SplitPositionList.RemoveAt(1); - SplitPositionList.RemoveAt(0); - } - // Ricalcolo dimensioni rimuovendo split else { - double dLastDimension = 0; - for (var SplitIndex = m_SplitPositionList.Count - 1; SplitIndex >= value + 1; SplitIndex += -1) + // Ricalcolo dimensioni aggiungendo split + if (value > m_SplitVertList.Count - 1) { - dLastDimension += m_SplitPositionList[SplitIndex].dDimension; - SplitPositionList.RemoveAt(SplitIndex); + // recupero larghezza ultimo + double dLastDimension = 100; + double dNewDimension = 100; + if (m_SplitVertList.Count > 0) + { + dLastDimension = m_SplitVertList[m_SplitVertList.Count - 1].dDimension; + dNewDimension = dLastDimension / (value + 1 - nSplitQtyVert); + m_SplitVertList[m_SplitVertList.Count - 1].SetDimension(dNewDimension); + } + else + dNewDimension = dLastDimension / (value + 1 - nSplitQtyVert); + // aggiungo area Split di default + for (var SplitIndex = m_SplitVertList.Count; SplitIndex <= value; SplitIndex++) + m_SplitVertList.Add(new SplitDimension(dNewDimension, true, this, true)); } - dLastDimension += m_SplitPositionList[SplitPositionList.Count - 1].dDimension; - SplitPositionList[SplitPositionList.Count - 1].SetDimension(dLastDimension); - } - // Se aggiungo split devo aggiungere vetro nell'area splitted aggiunta - for (var SplitIndex = AreaList.Count; SplitIndex <= SplitPositionList.Count - 1; SplitIndex++) - { - AreaList.Add(Splitted.CreateSplitted(this)); - Fill newFill = new Fill(AreaList.Last(), ParentWindow); - newFill.SetFillType(FillTypes.GLASS); - newFill.SetAreaType(AreaTypes.FILL); - AreaList[AreaList.Count - 1].AreaList.Add(newFill); - } - // Se ho più di uno split, elimino l'ultimo - if (AreaList.Count > 2) - { - for (var SplitIndex = SplitPositionList.Count; SplitIndex <= AreaList.Count - 1; SplitIndex++) + else if (value == 0) { - AreaList.Remove(AreaList[AreaList.Count - 1]); + m_SplitVertList.RemoveAt(1); + m_SplitVertList.RemoveAt(0); + } + // Ricalcolo dimensioni rimuovendo split + else + { + double dLastDimension = 0; + for (var SplitIndex = m_SplitVertList.Count - 1; SplitIndex >= value + 1; SplitIndex += -1) + { + dLastDimension += m_SplitVertList[SplitIndex].dDimension; + m_SplitVertList.RemoveAt(SplitIndex); + } + dLastDimension += m_SplitVertList[m_SplitVertList.Count - 1].dDimension; + m_SplitVertList[m_SplitVertList.Count - 1].SetDimension(dLastDimension); + } + // Controllo quanti split orizzontali ci sono + int nHoriz = m_SplitHorizList.Count > 0 ? m_SplitHorizList.Count : 1; + // Se aggiungo split devo aggiungere vetro nell'area splitted aggiunta + for (var SplitIndex = AreaList.Count; SplitIndex <= (m_SplitVertList.Count * nHoriz) - 1; SplitIndex++) + { + AreaList.Add(Splitted.CreateSplitted(this)); + Fill newFill = Fill.CreateFill(AreaList[SplitIndex], FillTypes.GLASS); + newFill.SetAreaType(AreaTypes.FILL); + AreaList[AreaList.Count - 1].AreaList.Add(newFill); + } + // Se ho più di uno split, elimino l'ultimo + if (AreaList.Count > 2) + { + int nAreaList = AreaList.Count - 1; + for (var SplitIndex = (m_SplitVertList.Count * nHoriz); SplitIndex <= nAreaList; SplitIndex++) + { + AreaList.Remove(AreaList[AreaList.Count - 1]); + } + } + // Se elimino l'unico split presente + else + { + Splitted s = (Splitted)AreaList[0]; + s.SetParentArea(ParentArea); + ParentArea.AreaList.Add(s); + ParentArea.AreaList.Remove(this); } - } - // Se elimino l'unico split presente - else - { - Splitted s = (Splitted)AreaList[0]; - s.SetParentArea(ParentArea); - ParentArea.AreaList.Add(s); - ParentArea.AreaList.Remove(this); } m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } - - internal void SetSplitQty(int Qty, bool NotifyProperty = false) + internal void SetSplitQtyVert(int QtyVert, bool NotifyProperty = false) { - if (Qty > m_SplitPositionList.Count) + if (QtyVert > m_SplitVertList.Count) { // recupero larghezza ultimo double dLastDimension = 100; double dNewDimension = 100; - if (m_SplitPositionList.Count > 0) + if (m_SplitVertList.Count > 0) { - dLastDimension = m_SplitPositionList[m_SplitPositionList.Count - 1].dDimension; - dNewDimension = dLastDimension / (Qty + 1 - nSplitQty); - m_SplitPositionList[m_SplitPositionList.Count - 1].dDimension = dNewDimension; + dLastDimension = m_SplitVertList[m_SplitVertList.Count - 1].dDimension; + dNewDimension = dLastDimension / (QtyVert + 1 - nSplitQtyVert); + m_SplitVertList[m_SplitVertList.Count - 1].dDimension = dNewDimension; } else - dNewDimension = dLastDimension / (Qty + 1 - nSplitQty); + dNewDimension = dLastDimension / (QtyVert + 1 - nSplitQtyVert); // aggiungo area Split di default - for (var SplitIndex = m_SplitPositionList.Count; SplitIndex <= Qty; SplitIndex++) - SplitPositionList.Add(new SplitDimension(dNewDimension, true, this)); + for (var SplitIndex = m_SplitVertList.Count; SplitIndex <= QtyVert; SplitIndex++) + m_SplitVertList.Add(new SplitDimension(dNewDimension, true, this, true)); } - else if (Qty < m_SplitPositionList.Count) + else if (QtyVert < m_SplitVertList.Count) { - for (var SplitIndex = m_SplitPositionList.Count - 1; SplitIndex >= Qty; SplitIndex += -1) - SplitPositionList.RemoveAt(SplitIndex); + for (var SplitIndex = m_SplitVertList.Count - 1; SplitIndex >= QtyVert; SplitIndex += -1) + m_SplitVertList.RemoveAt(SplitIndex); + } + } + + public int nSplitQtyHoriz + { + get + { + return m_SplitHorizList.Count > 0 ? m_SplitHorizList.Count - 1 : 0; + } + set + { + if (value == 0) + { + for (var SplitIndex = m_SplitHorizList.Count - 1; SplitIndex >= value; SplitIndex += -1) + m_SplitHorizList.RemoveAt(SplitIndex); + if (nSplitQtyVert == 0) + { + ParentArea.AreaList.Remove(this); + Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS); + newFill.SetAreaType(AreaTypes.FILL); + ParentArea.AreaList.Add(newFill); + } + else + SetSplitShape(SplitShapes.VERTICAL); + } + else + { + // Ricalcolo dimensioni aggiungendo split + if (value > m_SplitHorizList.Count - 1) + { + // recupero larghezza ultimo + double dLastDimension = 100; + double dNewDimension = 100; + if (m_SplitHorizList.Count > 0) + { + dLastDimension = m_SplitHorizList[m_SplitHorizList.Count - 1].dDimension; + dNewDimension = dLastDimension / (value + 1 - nSplitQtyHoriz); + m_SplitHorizList[m_SplitHorizList.Count - 1].SetDimension(dNewDimension); + } + else + dNewDimension = dLastDimension / (value + 1 - nSplitQtyHoriz); + // aggiungo area Split di default + for (var SplitIndex = m_SplitHorizList.Count; SplitIndex <= value; SplitIndex++) + m_SplitHorizList.Add(new SplitDimension(dNewDimension, true, this, false)); + } + // Ricalcolo dimensioni rimuovendo split + else + { + double dLastDimension = 0; + for (var SplitIndex = m_SplitHorizList.Count - 1; SplitIndex >= value + 1; SplitIndex += -1) + { + dLastDimension += m_SplitHorizList[SplitIndex].dDimension; + m_SplitHorizList.RemoveAt(SplitIndex); + } + dLastDimension += m_SplitHorizList[m_SplitHorizList.Count - 1].dDimension; + m_SplitHorizList[m_SplitHorizList.Count - 1].SetDimension(dLastDimension); + } + // Controllo quanti split verticali ci sono + int nVert = m_SplitVertList.Count > 0 ? m_SplitVertList.Count : 1; + // Se aggiungo split devo aggiungere vetro nell'area splitted aggiunta + for (var SplitIndex = AreaList.Count; SplitIndex <= (m_SplitHorizList.Count * nVert) - 1; SplitIndex++) + { + AreaList.Add(Splitted.CreateSplitted(this)); + Fill newFill = Fill.CreateFill(AreaList[SplitIndex], FillTypes.GLASS); + newFill.SetAreaType(AreaTypes.FILL); + AreaList[AreaList.Count - 1].AreaList.Add(newFill); + } + // Se ho più di uno split, elimino l'ultimo + if (AreaList.Count > 2) + { + int nAreaList = AreaList.Count - 1; + for (var SplitIndex = (m_SplitHorizList.Count * nVert); SplitIndex <= nAreaList; SplitIndex++) + { + AreaList.Remove(AreaList[AreaList.Count - 1]); + } + } + // Se elimino l'unico split presente + else + { + Splitted s = (Splitted)AreaList[0]; + s.SetParentArea(ParentArea); + ParentArea.AreaList.Add(s); + ParentArea.AreaList.Remove(this); + } + } + m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + } + } + internal void SetSplitQtyHoriz(int QtyHoriz, bool NotifyProperty = false) + { + if (QtyHoriz > m_SplitHorizList.Count) + { + // recupero larghezza ultimo + double dLastDimension = 100; + double dNewDimension = 100; + if (m_SplitHorizList.Count > 0) + { + dLastDimension = m_SplitHorizList[m_SplitHorizList.Count - 1].dDimension; + dNewDimension = dLastDimension / (QtyHoriz + 1 - nSplitQtyHoriz); + m_SplitHorizList[m_SplitHorizList.Count - 1].dDimension = dNewDimension; + } + else + dNewDimension = dLastDimension / (QtyHoriz + 1 - nSplitQtyHoriz); + // aggiungo area Split di default + for (var SplitIndex = m_SplitHorizList.Count; SplitIndex <= QtyHoriz; SplitIndex++) + m_SplitHorizList.Add(new SplitDimension(dNewDimension, true, this, false)); + } + else if (QtyHoriz < m_SplitHorizList.Count) + { + for (var SplitIndex = m_SplitHorizList.Count - 1; SplitIndex >= QtyHoriz; SplitIndex += -1) + m_SplitHorizList.RemoveAt(SplitIndex); } } @@ -1525,6 +1696,39 @@ namespace WebWindowComplex set { m_SelSplitShape = (SplitShapes)IdNameStruct.IdFromInd(value, m_SplitShapeList); + // Cancello elementi nello split e azzero quantità orizzontale e verticale + AreaList.Clear(); + SetSplitQtyVert(0); + SetSplitQtyHoriz(0); + if (m_SelSplitShape == SplitShapes.VERTICAL) + { + // Inserisco valori di default + SetSplitQtyVert(1); + SetSplitStartVert(true); + } + else if (m_SelSplitShape == SplitShapes.HORIZONTAL) + { + // Inserisco valori di default + SetSplitQtyHoriz(1); + SetSplitStartVert(false); + } + else + { + // Inserisco valori di default + SetSplitQtyVert(1); + SetSplitQtyHoriz(1); + SetSplitStartVert(true); + } + // Aggiungo area Splitted e vetro + int nVert = m_SplitVertList.Count > 0 ? m_SplitVertList.Count : 1; + int nHoriz = m_SplitHorizList.Count > 0 ? m_SplitHorizList.Count : 1; + for (var SplitIndex = 0; SplitIndex <= (nVert * nHoriz) - 1; SplitIndex++) + { + AreaList.Add(Splitted.CreateSplitted(this)); + Fill newFill = Fill.CreateFill(AreaList[SplitIndex], FillTypes.GLASS); + newFill.SetAreaType(AreaTypes.FILL); + AreaList[SplitIndex].AreaList.Add(newFill); + } m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -1562,6 +1766,32 @@ namespace WebWindowComplex } } + private ObservableCollection m_SplitVertList = new ObservableCollection(); + public ObservableCollection SplitVertList + { + get + { + return m_SplitVertList; + } + set + { + m_SplitVertList = value; + } + } + + private ObservableCollection m_SplitHorizList = new ObservableCollection(); + public ObservableCollection SplitHorizList + { + get + { + return m_SplitHorizList; + } + set + { + m_SplitHorizList = value; + } + } + public Split(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow) { } @@ -1569,6 +1799,8 @@ namespace WebWindowComplex internal static Split CreateSplit(Area Area, SplitShapes SplitShape) { Split Split = new Split(Area, Area.ParentWindow); + AddCounterGroup(); + Split.SetIdGroup(nCounterGroup); Split.SetAreaType(AreaTypes.SPLIT); Split.SetSplitShape(SplitShape, true); return Split; @@ -1577,7 +1809,11 @@ namespace WebWindowComplex public override Split Copy(Area newParentArea) { Split newSplit = new Split(newParentArea, ParentWindow); - newSplit.SetSplitQty(nSplitQty); + AddCounterGroup(); + newSplit.SetIdGroup(nCounterGroup); + newSplit.SetSplitStartVert(bSplitStartVert); + newSplit.SetSplitQtyVert(nSplitQtyVert); + newSplit.SetSplitQtyHoriz(nSplitQtyHoriz); newSplit.SetSplitShape(SelSplitShape, true); newSplit.SetAreaType(AreaType); foreach (var item in AreaList) @@ -1588,11 +1824,27 @@ namespace WebWindowComplex return newSplit; } + public void Remove() + { + ParentArea.AreaList.Remove(this); + Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS); + newFill.SetAreaType(AreaTypes.FILL); + ParentArea.AreaList.Add(newFill); + m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + } + internal override JsonArea Serialize() { - JsonSplit JsonSplit = new JsonSplit(m_SelSplitShape); - foreach (var SplitPosition in m_SplitPositionList) - JsonSplit.SplitPositionList.Add(SplitPosition.Serialize()); + if (nCounterGroup < IdGroup) + Area.nCounterGroup = IdGroup; + JsonSplit JsonSplit = new JsonSplit(m_SelSplitShape, IdGroup); + //foreach (var SplitPosition in m_SplitPositionList) + // JsonSplit.SplitPositionList.Add(SplitPosition.Serialize()); + JsonSplit.SplitStartVert = bSplitStartVert; + foreach (var SplitVert in m_SplitVertList) + JsonSplit.SplitVertList.Add(SplitVert.Serialize()); + foreach (var SplitHoriz in m_SplitHorizList) + JsonSplit.SplitHorizList.Add(SplitHoriz.Serialize()); foreach (var Area in AreaList) JsonSplit.AreaList.Add(Area.Serialize()); return JsonSplit; @@ -1601,7 +1853,6 @@ namespace WebWindowComplex public class Splitted : Area { - public Splitted(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow) { } @@ -1609,6 +1860,8 @@ namespace WebWindowComplex internal static Splitted CreateSplitted(Area ParentArea) { Splitted Splitted = new Splitted(ParentArea, ParentArea.ParentWindow); + AddCounterGroup(); + Splitted.SetIdGroup(nCounterGroup); Splitted.SetAreaType(AreaTypes.SPLITTED); return Splitted; } @@ -1616,6 +1869,8 @@ namespace WebWindowComplex public override Splitted Copy(Area newParentArea) { Splitted newSplitted = new Splitted(newParentArea, ParentWindow); + AddCounterGroup(); + newSplitted.SetIdGroup(nCounterGroup); newSplitted.SetAreaType(AreaType); foreach (var item in AreaList) { @@ -1627,7 +1882,9 @@ namespace WebWindowComplex internal override JsonArea Serialize() { - JsonSplitted JsonSplitted = new JsonSplitted(); + if (nCounterGroup < IdGroup) + Area.nCounterGroup = IdGroup; + JsonSplitted JsonSplitted = new JsonSplitted(IdGroup); foreach (var Area in AreaList) JsonSplitted.AreaList.Add(Area.Serialize()); return JsonSplitted; @@ -1692,6 +1949,8 @@ namespace WebWindowComplex internal static Fill CreateFill(Area AreaParent, FillTypes FillType) { Fill Fill = new Fill(AreaParent, AreaParent.ParentWindow); + AddCounterGroup(); + Fill.SetIdGroup(nCounterGroup); Fill.SetAreaType(AreaTypes.FILL); Fill.SetFillType(FillType); return Fill; @@ -1700,6 +1959,8 @@ namespace WebWindowComplex public override Fill Copy(Area newParentArea) { Fill newFill = new Fill(newParentArea, m_ParentWindow); + AddCounterGroup(); + newFill.SetIdGroup(nCounterGroup); newFill.SetFillType(SelFillType); newFill.SetAreaType(AreaType); return newFill; @@ -1707,7 +1968,9 @@ namespace WebWindowComplex internal override JsonArea Serialize() { - JsonFill JsonFill = new JsonFill(FillType); + if (nCounterGroup < IdGroup) + Area.nCounterGroup = IdGroup; + JsonFill JsonFill = new JsonFill(FillType, IdGroup); foreach (var Area in AreaList) JsonFill.AreaList.Add(Area.Serialize()); return JsonFill; @@ -1724,6 +1987,7 @@ namespace WebWindowComplex return m_ParentArea; } } + private int m_nIndex; public int nIndex { @@ -1797,82 +2061,82 @@ namespace WebWindowComplex } } - public class Hardware - { - private string m_sId; - public string sId - { - get - { - return m_sId; - } - } + //public class Hardware + //{ + // private string m_sId; + // public string sId + // { + // get + // { + // return m_sId; + // } + // } - private string m_sFamily; - public string sFamily - { - get - { - return m_sFamily; - } - } + // private string m_sFamily; + // public string sFamily + // { + // get + // { + // return m_sFamily; + // } + // } - private string m_sName; - public string sName - { - get - { - return m_sName; - } - } + // private string m_sName; + // public string sName + // { + // get + // { + // return m_sName; + // } + // } - private string m_sOpeningType; - public string sOpeningType - { - get - { - return m_sOpeningType; - } - } + // private string m_sOpeningType; + // public string sOpeningType + // { + // get + // { + // return m_sOpeningType; + // } + // } - private string m_sShape; - public string sShape - { - get - { - return m_sShape; - } - } + // private string m_sShape; + // public string sShape + // { + // get + // { + // return m_sShape; + // } + // } - private int m_nSashQty; - public int nSashQty - { - get - { - return m_nSashQty; - } - } + // private int m_nSashQty; + // public int nSashQty + // { + // get + // { + // return m_nSashQty; + // } + // } - private int m_nSashPosition; - public int nSashPosition - { - get - { - return m_nSashPosition; - } - } + // private int m_nSashPosition; + // public int nSashPosition + // { + // get + // { + // return m_nSashPosition; + // } + // } - public Hardware(string sId, string sFamily, string sName, string sOpeningType, string sShape, int nSashQty, int nSashPosition) - { - m_sId = sId; - m_sFamily = sFamily; - m_sName = sName; - m_sOpeningType = sOpeningType; - m_sShape = sShape; - m_nSashQty = nSashQty; - m_nSashPosition = nSashPosition; - } - } + // public Hardware(string sId, string sFamily, string sName, string sOpeningType, string sShape, int nSashQty, int nSashPosition) + // { + // m_sId = sId; + // m_sFamily = sFamily; + // m_sName = sName; + // m_sOpeningType = sOpeningType; + // m_sShape = sShape; + // m_nSashQty = nSashQty; + // m_nSashPosition = nSashPosition; + // } + //} public partial class ParametriOpzioni { @@ -2087,6 +2351,15 @@ namespace WebWindowComplex // reference private Sash m_Parent; + private int m_nSashId; + public int nSashId + { + get + { + return m_nSashId; + } + } + private bool m_bIsRelative = false; public bool bIsRelative { @@ -2264,17 +2537,18 @@ namespace WebWindowComplex public SashDimension Copy() { - SashDimension newSashDim = new SashDimension(dDimension, bIsRelative, m_Parent); + SashDimension newSashDim = new SashDimension(dDimension, bIsRelative, m_Parent, m_nSashId); newSashDim.SetOpeningType(SelOpeningType); newSashDim.SetHasHandle(bHasHandle); return newSashDim; } - public SashDimension(double dDimension, bool bIsRelative, Sash Parent) + public SashDimension(double dDimension, bool bIsRelative, Sash Parent, int nSashId) { m_dDimension = dDimension; m_bIsRelative = bIsRelative; m_Parent = Parent; + m_nSashId = nSashId; // assengno maniglia if (Parent.SashList.Count == 0 || !Parent.SashList.Any(x => x.bHasHandle)) m_bHasHandle = true; @@ -2299,13 +2573,13 @@ namespace WebWindowComplex case Openings.TILTTURN_LEFT: { - SetOpeningType(Openings.TILTTURN_RIGHT); + SetOpeningType(Openings.TURNONLY_RIGHT); break; } case Openings.TILTTURN_RIGHT: { - SetOpeningType(Openings.TILTTURN_LEFT); + SetOpeningType(Openings.TURNONLY_LEFT); break; } @@ -2352,7 +2626,7 @@ namespace WebWindowComplex internal JsonSashDimension Serialize() { - JsonSashDimension JsonSashDimension = new JsonSashDimension(OpeningType, m_bHasHandle, m_dDimension); + JsonSashDimension JsonSashDimension = new JsonSashDimension(OpeningType, m_bHasHandle, m_dDimension, m_nSashId); return JsonSashDimension; } } @@ -2375,6 +2649,20 @@ namespace WebWindowComplex m_bIsRelative = value; } + private bool m_bIsVertListDim = false; + public bool bIsVertListDim + { + get + { + return m_bIsVertListDim; + } + } + internal void SetIsVertListDim(bool value) + { + m_bIsVertListDim = value; + } + + private double m_dDimension; public double dDimension { @@ -2390,8 +2678,13 @@ namespace WebWindowComplex // se sono in percentuale if (m_bIsRelative) { + List RelativeDimList = new List(); + if (bIsVertListDim) + RelativeDimList = m_Parent.SplitVertList.Where(x => x.bIsRelative).ToList(); + else + RelativeDimList = m_Parent.SplitHorizList.Where(x => x.bIsRelative).ToList(); // verifico se ci sono assoluti - List RelativeDimList = m_Parent.SplitPositionList.Where(x => x.bIsRelative).ToList(); + //List RelativeDimList = m_Parent.SplitPositionList.Where(x => x.bIsRelative).ToList(); if (RelativeDimList.Count > 0) { if (m_Parent.bIsPercentage) @@ -2462,14 +2755,15 @@ namespace WebWindowComplex public SplitDimension Copy() { - SplitDimension newSplitDim = new SplitDimension(dDimension, bIsRelative, m_Parent); + SplitDimension newSplitDim = new SplitDimension(dDimension, bIsRelative, m_Parent, bIsVertListDim); return newSplitDim; } - public SplitDimension(double dDimension, bool bIsRelative, Split Parent) + public SplitDimension(double dDimension, bool bIsRelative, Split Parent, bool IsVertList) { m_dDimension = dDimension; m_bIsRelative = bIsRelative; m_Parent = Parent; + m_bIsVertListDim = IsVertList; } internal JsonSplitDimension Serialize() diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index 4594b76..b86a03a 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.9.3009 + 2.7.9.3011 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -111,6 +111,18 @@ + + + + + + + + + + + + diff --git a/WebWindowTest/Test.razor b/WebWindowTest/Test.razor index e4ca63f..1eb7ad8 100644 --- a/WebWindowTest/Test.razor +++ b/WebWindowTest/Test.razor @@ -310,7 +310,7 @@
- +
@@ -460,7 +460,7 @@
- +
diff --git a/WebWindowTest/Test.razor.cs b/WebWindowTest/Test.razor.cs index 1507bce..d409a29 100644 --- a/WebWindowTest/Test.razor.cs +++ b/WebWindowTest/Test.razor.cs @@ -785,17 +785,6 @@ namespace WebWindowTest await DoPreviewSvg(); } - /// - /// Metodo per scambiare due aree di uno split - /// - /// Area corrente - /// - private async Task SwapTwoAree(Area currArea) - { - currArea.SwapAree(); - await DoPreviewSvg(); - } - #endregion Protected Methods #region Private Fields @@ -824,6 +813,33 @@ namespace WebWindowTest #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.Gerarchia; + } + /// /// Metodo per cambiare step e aggiornare preview svg /// diff --git a/WebWindowTest/Window.cs b/WebWindowTest/Window.cs index 62d708b..c357f8f 100644 --- a/WebWindowTest/Window.cs +++ b/WebWindowTest/Window.cs @@ -129,10 +129,6 @@ namespace WebWindowTest { m_CounterGroup++; } - //public static void DelCounterGroup() - //{ - // m_CounterGroup--; - //} public static int nCounterGroup { get => m_CounterGroup;