diff --git a/Test.UI/Components/Pages/EditJWD.razor b/Test.UI/Components/Pages/EditJWD.razor index 4b6c9cb..3b1d466 100644 --- a/Test.UI/Components/Pages/EditJWD.razor +++ b/Test.UI/Components/Pages/EditJWD.razor @@ -3,6 +3,68 @@ EditJWD +@*
+
+
+ FamilyHw + +
+
+ +
+
+ Color + +
+
+
+
+ Material + +
+
+
+
+ Glass + +
+
+
+
+ Profile + +
+
+
+ +
+
+ *@ } -

- @currJwd -

+
+
+ @JsonSer +
+
diff --git a/Test.UI/Components/Pages/EditJWD.razor.cs b/Test.UI/Components/Pages/EditJWD.razor.cs index 20a632a..1ad2670 100644 --- a/Test.UI/Components/Pages/EditJWD.razor.cs +++ b/Test.UI/Components/Pages/EditJWD.razor.cs @@ -1,4 +1,5 @@ -using EgwCoreLib.Lux.Core; +using Egw.Window.Data; +using EgwCoreLib.Lux.Core; using EgwCoreLib.Lux.Core.RestPayload; using EgwCoreLib.Lux.Data.Services; using Microsoft.AspNetCore.Components; @@ -6,7 +7,6 @@ using Newtonsoft.Json; using NLog; using System.Diagnostics; using System.Security.AccessControl; -using Egw.Window.Data; using WebWindowComplex; using WebWindowComplex.DTO; @@ -64,8 +64,8 @@ namespace Test.UI.Components.Pages protected List AvailFamilyHardwareList { get; set; } = new List() { - new string("Arc"), - new string("Profilo78") + new string("ArTech"), + new string("ArTechPlana") }; protected List AvailGlassList { get; set; } = new List() @@ -85,6 +85,13 @@ namespace Test.UI.Components.Pages new string("Abete") }; + protected List AvailProfileList { get; set; } = new List() + { + new string("Profilo60"), + new string("Profilo78"), + new string("Profilo90") + }; + protected List AvailTemplateList { get; set; } = new List(); [Inject] protected IConfiguration Config { get; set; } = null!; @@ -112,20 +119,21 @@ namespace Test.UI.Components.Pages protected override async Task OnInitializedAsync() { ConfInit(); - InitialJwd = File.ReadAllText("Data\\AntaDoppia.jwd"); + InitialJwd = File.ReadAllText("Data\\AntaSingola.jwd"); currJwd = InitialJwd; // rileggo altri dati await ReloadData(); // preparo conf oggetti x controllo - SetupList = SetupList = new BaseListPayload() + SetupList = new BaseListPayload() { ColorMaterial = AvailColorMaterialList, FamilyHardware = AvailFamilyHardwareList, Glass = AvailGlassList, - //Hardware = new List(), + //FamilyHardware = new List(), //Material = new List(), Hardware = AvailHardwareList, Material = AvailMaterialList, + Profile = AvailProfileList, TemplateDTO = null }; CurrData = new LivePayload() @@ -270,5 +278,17 @@ namespace Test.UI.Components.Pages } #endregion Private Methods + + private void updateInfoJwd(string currSer, string? newFamilyHardware, Hardware? newHardware, string? newColorMaterial, string? newMaterial, string? newGlass, string? newProfile) + { + var newJwd = SerialMan.MassUpdate(currSer, newFamilyHardware, newHardware, newColorMaterial, newMaterial, newGlass, newProfile); + CurrData.CurrJwd = newJwd; + } + private string familyHWMassUpdate; + private Hardware hardwareMassUpdate; + private string materialMassUpdate; + private string colorMassUpdate; + private string glassMassUpdate; + private string profileMassUpdate; } } \ No newline at end of file diff --git a/Test.UI/Data/AntaDoppia.jwd b/Test.UI/Data/AntaDoppia.jwd index 141654e..daa1816 100644 --- a/Test.UI/Data/AntaDoppia.jwd +++ b/Test.UI/Data/AntaDoppia.jwd @@ -1,7 +1,7 @@ { "ProfilePath": "Profilo78", "Material": "Pino", - "ColorMaterial": "Nero", + "ColorMaterial": "Black", "Glass": "Vetro BE 2S 4T/16/4T", "AreaList": [ { @@ -75,7 +75,7 @@ "JointType": "FULL_V" } ], - "Hardware": "000559", + "Hardware": "000631", "IdGroup": 2, "AreaList": [ { diff --git a/Test.UI/Data/AntaSingola.jwd b/Test.UI/Data/AntaSingola.jwd index 363ec74..60f3330 100644 --- a/Test.UI/Data/AntaSingola.jwd +++ b/Test.UI/Data/AntaSingola.jwd @@ -69,7 +69,7 @@ "JointType": "FULL_H" } ], - "Hardware": "000558", + "Hardware": "000635", "IdGroup": 2, "AreaList": [ { diff --git a/Test.UI/Data/FinDueAnteBottomFisso.jwd b/Test.UI/Data/FinDueAnteBottomFisso.jwd index 6b19f59..f36e5e4 100644 --- a/Test.UI/Data/FinDueAnteBottomFisso.jwd +++ b/Test.UI/Data/FinDueAnteBottomFisso.jwd @@ -106,7 +106,7 @@ "JointType": "FULL_H" } ], - "Hardware": "000559", + "Hardware": "000631", "IdGroup": 6, "AreaList": [ { diff --git a/Test.UI/Hardware/Setup.json b/Test.UI/Hardware/Setup.json index d587146..25b20a0 100644 --- a/Test.UI/Hardware/Setup.json +++ b/Test.UI/Hardware/Setup.json @@ -1,370 +1,613 @@ [ { - "id": "000548", - "familyName": "Rect", - "description": "Rect_DoubleSash", - "openingType": "TiltTurn", - "shape": "Rectangular", - "sashQty": 2, - "sashPosition": 1 - }, - { - "id": "000546", - "familyName": "Trap", - "description": "Trap_Sash", - "openingType": "TiltTurn", - "shape": "Trapezoidal", - "sashQty": 1, - "sashPosition": 1 - }, - { - "id": "000547", - "familyName": "Rect", - "description": "Rect_Sash_Compl", - "openingType": "ComplanarSlide", - "shape": "Rectangular", - "sashQty": 2, - "sashPosition": 1 - }, - { - "id": "000561", - "familyName": "Profilo78", - "description": "Profilo78_Rect_TripleSash_HiddenHinges", + "id": "000625", + "familyName": "ArTech", + "description": "ArTech_Aria12", "openingType": "TiltTurn", "shape": "Rectangular", "sashQty": 3, "sashPosition": 1 }, { - "id": "000563", - "familyName": "Profilo78", - "description": "Profilo78_TurnOnly_Rect_DoubleSash", + "id": "000666", + "familyName": "ArTechPlana", + "description": "ArTechPlana_Aria4", "openingType": "TurnOnly", "shape": "Rectangular", "sashQty": 2, "sashPosition": 1 }, { - "id": "000564", - "familyName": "Profilo78", - "description": "Profilo78_TurnOnly_Rect_TripleSash", - "openingType": "TurnOnly", - "shape": "Rectangular", - "sashQty": 3, - "sashPosition": 2 - }, - { - "id": "000603", - "familyName": "SegArc", - "description": "SegArc_2S_TurnOnly", - "openingType": "TurnOnly", - "shape": "Arc", - "sashQty": 2, - "sashPosition": 1 - }, - { - "id": "000602", - "familyName": "Arc", - "description": "Arc_2S_TurnOnly", - "openingType": "TurnOnly", - "shape": "FullArc", - "sashQty": 2, - "sashPosition": 1 - }, - { - "id": "000601", - "familyName": "SegArc", - "description": "SegArc_1S_TurnOnly", - "openingType": "TurnOnly", - "shape": "Arc", - "sashQty": 1, - "sashPosition": 1 - }, - { - "id": "000610", - "familyName": "SemiArc", - "description": "SemiArc_1S", - "openingType": "TiltTurn", - "shape": "SemiFullArc", - "sashQty": 1, - "sashPosition": 1 - }, - { - "id": "000611", - "familyName": "SemiSegArc", - "description": "SemiSegArc_S1", + "id": "000642", + "familyName": "ArTech", + "description": "ArTech_Aria4", "openingType": "TiltTurn", "shape": "SemiArc", "sashQty": 1, "sashPosition": 1 }, { - "id": "000596", - "familyName": "Arc", - "description": "Arc_1S", - "openingType": "TiltTurn", - "shape": "FullArc", + "id": "000665", + "familyName": "ArTechPlana", + "description": "ArTechPlana_Aria4", + "openingType": "TurnOnly", + "shape": "Rectangular", "sashQty": 1, "sashPosition": 1 }, { - "id": "000599", - "familyName": "SegArc", - "description": "SegArc_2S", + "id": "000693", + "familyName": "ArTech", + "description": "ArTech_Aria4", + "openingType": "TurnOnly", + "shape": "FullArc", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000644", + "familyName": "ArTech", + "description": "ArTech_Aria4", "openingType": "TiltTurn", "shape": "Arc", "sashQty": 2, "sashPosition": 1 }, { - "id": "000597", - "familyName": "SegArc", - "description": "SegArc_1S", + "id": "000637", + "familyName": "ArTechPlana", + "description": "ArTechPlana_Aria4", + "openingType": "TiltTurn", + "shape": "Rectangular", + "sashQty": 3, + "sashPosition": 1 + }, + { + "id": "000656", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TurnOnly", + "shape": "Rectangular", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000686", + "familyName": "ArTech", + "description": "ArTech_Aria4", + "openingType": "TurnOnly", + "shape": "Arc", + "sashQty": 1, + "sashPosition": 1 + }, + { + "id": "000678", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TurnOnly", + "shape": "Arc", + "sashQty": 1, + "sashPosition": 1 + }, + { + "id": "000635", + "familyName": "ArTechPlana", + "description": "ArTechPlana_Aria4", + "openingType": "TiltTurn", + "shape": "Rectangular", + "sashQty": 1, + "sashPosition": 1 + }, + { + "id": "000685", + "familyName": "ArTech", + "description": "ArTech_Aria4", + "openingType": "TurnOnly", + "shape": "Arc", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000631", + "familyName": "ArTech", + "description": "ArTech_Aria4", + "openingType": "TiltTurn", + "shape": "Rectangular", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000649", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TiltTurn", + "shape": "FullArc", + "sashQty": 1, + "sashPosition": 1 + }, + { + "id": "000662", + "familyName": "ArTech", + "description": "ArTech_Aria4_Centrale", + "openingType": "TurnOnly", + "shape": "Rectangular", + "sashQty": 3, + "sashPosition": 2 + }, + { + "id": "000652", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TiltTurn", + "shape": "Trapezoidal", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000630", + "familyName": "ArTech", + "description": "ArTech_Aria4_CerniereScomparsa", + "openingType": "TiltTurn", + "shape": "Rectangular", + "sashQty": 3, + "sashPosition": 1 + }, + { + "id": "000623", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TiltTurn", + "shape": "Rectangular", + "sashQty": 1, + "sashPosition": 1 + }, + { + "id": "000674", + "familyName": "ArTechPlana", + "description": "ArTechPlana_Aria12", + "openingType": "TurnOnly", + "shape": "Rectangular", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000670", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TurnOnly", + "shape": "Rectangular", + "sashQty": 4, + "sashPosition": 2 + }, + { + "id": "000640", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TiltTurn", + "shape": "SemiArc", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000673", + "familyName": "ArTechPlana", + "description": "ArTechPlana_Aria12_Centrale", + "openingType": "TurnOnly", + "shape": "Rectangular", + "sashQty": 3, + "sashPosition": 2 + }, + { + "id": "000647", + "familyName": "ArTech", + "description": "ArTech_Aria4", + "openingType": "TiltTurn", + "shape": "FullArc", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000690", + "familyName": "ArTech", + "description": "ArTech_Aria4", + "openingType": "TurnOnly", + "shape": "Arc", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000632", + "familyName": "ArTechPlana", + "description": "ArTechPlana_Aria12", + "openingType": "TiltTurn", + "shape": "Rectangular", + "sashQty": 1, + "sashPosition": 1 + }, + { + "id": "000669", + "familyName": "ArTechPlana", + "description": "ArTechPlana_Aria4", + "openingType": "TurnOnly", + "shape": "Rectangular", + "sashQty": 4, + "sashPosition": 2 + }, + { + "id": "000624", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TiltTurn", + "shape": "Rectangular", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000667", + "familyName": "ArTechPlana", + "description": "ArTechPlana_Aria4_Centrale", + "openingType": "TurnOnly", + "shape": "Rectangular", + "sashQty": 3, + "sashPosition": 2 + }, + { + "id": "000629", + "familyName": "ArTech", + "description": "ArTech_Aria4", + "openingType": "TiltTurn", + "shape": "Rectangular", + "sashQty": 3, + "sashPosition": 1 + }, + { + "id": "000657", + "familyName": "ArTech", + "description": "ArTech_Aria12_Centrale", + "openingType": "TurnOnly", + "shape": "Rectangular", + "sashQty": 3, + "sashPosition": 2 + }, + { + "id": "000691", + "familyName": "ArTech", + "description": "ArTech_Aria4", + "openingType": "TurnOnly", + "shape": "SemiArc", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000683", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TurnOnly", + "shape": "SemiFullArc", + "sashQty": 1, + "sashPosition": 1 + }, + { + "id": "000633", + "familyName": "ArTechPlana", + "description": "ArTechPlana_Aria12", + "openingType": "TiltTurn", + "shape": "Rectangular", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000675", + "familyName": "ArTechPlana", + "description": "ArTechPlana_Aria12", + "openingType": "TurnOnly", + "shape": "Rectangular", + "sashQty": 1, + "sashPosition": 1 + }, + { + "id": "000692", + "familyName": "ArTech", + "description": "ArTech_Aria4", + "openingType": "TurnOnly", + "shape": "SemiFullArc", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000676", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TurnOnly", + "shape": "Arc", + "sashQty": 1, + "sashPosition": 1 + }, + { + "id": "000684", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TurnOnly", + "shape": "SemiFullArc", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000660", + "familyName": "ArTech", + "description": "ArTech_Aria4", + "openingType": "TurnOnly", + "shape": "Rectangular", + "sashQty": 4, + "sashPosition": 2 + }, + { + "id": "000627", + "familyName": "ArTech", + "description": "ArTech_Aria4", + "openingType": "TiltTurn", + "shape": "Rectangular", + "sashQty": 1, + "sashPosition": 1 + }, + { + "id": "000688", + "familyName": "ArTech", + "description": "ArTech_Aria4", + "openingType": "TurnOnly", + "shape": "SemiFullArc", + "sashQty": 1, + "sashPosition": 1 + }, + { + "id": "000689", + "familyName": "ArTech", + "description": "ArTech_Aria4", + "openingType": "TurnOnly", + "shape": "FullArc", + "sashQty": 1, + "sashPosition": 1 + }, + { + "id": "000658", + "familyName": "ArTech", + "description": "ArTech_Aria12_Laterale", + "openingType": "TurnOnly", + "shape": "Rectangular", + "sashQty": 3, + "sashPosition": 1 + }, + { + "id": "000653", + "familyName": "ArTech", + "description": "ArTech_Aria4", + "openingType": "TiltTurn", + "shape": "Trapezoidal", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000668", + "familyName": "ArTechPlana", + "description": "ArTechPlana_Aria4_Laterale", + "openingType": "TurnOnly", + "shape": "Rectangular", + "sashQty": 3, + "sashPosition": 1 + }, + { + "id": "000626", + "familyName": "ArTech", + "description": "ArTech_Aria12_CernieraScomparsa", + "openingType": "TiltTurn", + "shape": "Rectangular", + "sashQty": 3, + "sashPosition": 1 + }, + { + "id": "000679", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TurnOnly", + "shape": "SemiArc", + "sashQty": 1, + "sashPosition": 1 + }, + { + "id": "000643", + "familyName": "ArTech", + "description": "ArTech_Aria4", + "openingType": "TiltTurn", + "shape": "SemiArc", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000650", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TiltTurn", + "shape": "FullArc", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000661", + "familyName": "ArTech", + "description": "ArTech_Aria4_Laterale", + "openingType": "TurnOnly", + "shape": "Rectangular", + "sashQty": 3, + "sashPosition": 1 + }, + { + "id": "000639", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TiltTurn", + "shape": "Arc", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000663", + "familyName": "ArTech", + "description": "ArTech_Aria4", + "openingType": "TurnOnly", + "shape": "Rectangular", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000664", + "familyName": "ArTech", + "description": "ArTech_Aria4", + "openingType": "TurnOnly", + "shape": "Rectangular", + "sashQty": 1, + "sashPosition": 1 + }, + { + "id": "000682", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TurnOnly", + "shape": "FullArc", + "sashQty": 1, + "sashPosition": 1 + }, + { + "id": "000681", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TurnOnly", + "shape": "FullArc", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000645", + "familyName": "ArTech", + "description": "ArTech_Aria4", "openingType": "TiltTurn", "shape": "Arc", "sashQty": 1, "sashPosition": 1 }, { - "id": "000598", - "familyName": "Arc", - "description": "Arc_2S", - "openingType": "TiltTurn", - "shape": "FullArc", + "id": "000672", + "familyName": "ArTechPlana", + "description": "ArTechPlana_Aria12_Laterale", + "openingType": "TurnOnly", + "shape": "Rectangular", + "sashQty": 3, + "sashPosition": 1 + }, + { + "id": "000671", + "familyName": "ArTechPlana", + "description": "ArTechPlana_Aria12", + "openingType": "TurnOnly", + "shape": "Rectangular", + "sashQty": 4, + "sashPosition": 2 + }, + { + "id": "000687", + "familyName": "ArTech", + "description": "ArTech_Aria4", + "openingType": "TurnOnly", + "shape": "SemiArc", + "sashQty": 1, + "sashPosition": 1 + }, + { + "id": "000677", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TurnOnly", + "shape": "Arc", "sashQty": 2, "sashPosition": 1 }, { - "id": "000600", - "familyName": "Arc", - "description": "Arc_1S_TurnOnly", + "id": "000636", + "familyName": "ArTechPlana", + "description": "ArTechPlana_Aria4", + "openingType": "TiltTurn", + "shape": "Rectangular", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000638", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TiltTurn", + "shape": "Arc", + "sashQty": 1, + "sashPosition": 1 + }, + { + "id": "000634", + "familyName": "ArTechPlana", + "description": "ArTechPlana_Aria12", + "openingType": "TiltTurn", + "shape": "Rectangular", + "sashQty": 3, + "sashPosition": 1 + }, + { + "id": "000655", + "familyName": "ArTech", + "description": "ArTech_Aria12", "openingType": "TurnOnly", + "shape": "Rectangular", + "sashQty": 1, + "sashPosition": 1 + }, + { + "id": "000680", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TurnOnly", + "shape": "SemiArc", + "sashQty": 2, + "sashPosition": 1 + }, + { + "id": "000651", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TiltTurn", + "shape": "Trapezoidal", + "sashQty": 1, + "sashPosition": 1 + }, + { + "id": "000648", + "familyName": "ArTech", + "description": "ArTech_Aria4", + "openingType": "TiltTurn", "shape": "FullArc", "sashQty": 1, "sashPosition": 1 }, { - "id": "000606", - "familyName": "Trap", - "description": "Trap_S1_TurnOnly", - "openingType": "TurnOnly", - "shape": "Trapezoidal", + "id": "000641", + "familyName": "ArTech", + "description": "ArTech_Aria12", + "openingType": "TiltTurn", + "shape": "SemiArc", "sashQty": 1, "sashPosition": 1 }, { - "id": "000605", - "familyName": "Trap", - "description": "Trap_S2", + "id": "000654", + "familyName": "ArTech", + "description": "ArTech_Aria4", "openingType": "TiltTurn", "shape": "Trapezoidal", - "sashQty": 2, - "sashPosition": 1 - }, - { - "id": "000607", - "familyName": "Trap", - "description": "Trap_S2_TurnOnly", - "openingType": "TurnOnly", - "shape": "Trapezoidal", - "sashQty": 2, - "sashPosition": 1 - }, - { - "id": "000604", - "familyName": "Trap", - "description": "Trap_S1", - "openingType": "TiltTurn", - "shape": "Trapezoidal", - "sashQty": 1, - "sashPosition": 1 - }, - { - "id": "000595", - "familyName": "Slide", - "description": "Slide_quadruple", - "openingType": "LiftSlide", - "shape": "Rectangular", - "sashQty": 4, - "sashPosition": 2 - }, - { - "id": "000592", - "familyName": "Slide", - "description": "Slide_2S", - "openingType": "LiftSlide", - "shape": "Rectangular", - "sashQty": 2, - "sashPosition": 1 - }, - { - "id": "000594", - "familyName": "Slide", - "description": "Slide_4S", - "openingType": "LiftSlide", - "shape": "Rectangular", - "sashQty": 4, - "sashPosition": 2 - }, - { - "id": "000593", - "familyName": "Slide", - "description": "Slide_double", - "openingType": "LiftSlide", - "shape": "Rectangular", - "sashQty": 2, - "sashPosition": 1 - }, - { - "id": "000575", - "familyName": "Profilo78", - "description": "Profilo78_TurnOnly_Rect_QuadrupleSash", - "openingType": "TurnOnly", - "shape": "Rectangular", - "sashQty": 4, - "sashPosition": 2 - }, - { - "id": "000558", - "familyName": "Profilo78", - "description": "Profilo78_Rect_Sash", - "openingType": "TiltTurn", - "shape": "Rectangular", - "sashQty": 1, - "sashPosition": 1 - }, - { - "id": "000559", - "familyName": "Profilo78", - "description": "Profilo78_Rect_DoubleSash", - "openingType": "TiltTurn", - "shape": "Rectangular", - "sashQty": 2, - "sashPosition": 1 - }, - { - "id": "000566", - "familyName": "Profilo78", - "description": "Profilo78_TurnOnly_Rect_TripleSash_CenterHandle", - "openingType": "TurnOnly", - "shape": "Rectangular", - "sashQty": 3, - "sashPosition": 2 - }, - { - "id": "000565", - "familyName": "Profilo78", - "description": "Profilo78_TurnOnly_Rect_TripleSash_SideHandle", - "openingType": "TurnOnly", - "shape": "Rectangular", - "sashQty": 3, - "sashPosition": 1 - }, - { - "id": "000562", - "familyName": "Profilo78", - "description": "Profilo78_Rect_Sash", - "openingType": "TurnOnly", - "shape": "Rectangular", - "sashQty": 1, - "sashPosition": 1 - }, - { - "id": "000560", - "familyName": "Profilo78", - "description": "Profilo78_Rect_TripleSash", - "openingType": "TiltTurn", - "shape": "Rectangular", - "sashQty": 3, - "sashPosition": 1 - }, - { - "id": "000550", - "familyName": "Rect", - "description": "Rect_DoubleSash_4", - "openingType": "TiltTurn", - "shape": "Rectangular", - "sashQty": 2, - "sashPosition": 1 - }, - { - "id": "000552", - "familyName": "Rect", - "description": "Rect_DoubleSashStrana", - "openingType": "TiltTurn", - "shape": "Rectangular", - "sashQty": 3, - "sashPosition": 1 - }, - { - "id": "000549", - "familyName": "Rect", - "description": "Rect_DoubleSash", - "openingType": "TiltTurn", - "shape": "Rectangular", - "sashQty": 2, - "sashPosition": 1 - }, - { - "id": "000555", - "familyName": "Round", - "description": "Round_Sash", - "openingType": "Pivot", - "shape": "Circular", - "sashQty": 1, - "sashPosition": 1 - }, - { - "id": "000556", - "familyName": "Rect", - "description": "Rect_Sash_Bilico", - "openingType": "Pivot", - "shape": "Rectangular", - "sashQty": 1, - "sashPosition": 1 - }, - { - "id": "000554", - "familyName": "Rect", - "description": "Rect_QuadrupolSash_Bandiera", - "openingType": "TurnOnly", - "shape": "Rectangular", - "sashQty": 4, - "sashPosition": 2 - }, - { - "id": "000551", - "familyName": "Rect", - "description": "Rect_Sash_Bandiera", - "openingType": "TurnOnly", - "shape": "Rectangular", - "sashQty": 1, - "sashPosition": 1 - }, - { - "id": "000544", - "familyName": "Rect", - "description": "Rect_Sash", - "openingType": "TiltTurn", - "shape": "Rectangular", - "sashQty": 1, - "sashPosition": 1 - }, - { - "id": "000553", - "familyName": "Rect", - "description": "Rect_TripleSash", - "openingType": "TiltTurn", - "shape": "Rectangular", - "sashQty": 3, - "sashPosition": 1 - }, - { - "id": "000545", - "familyName": "Rect", - "description": "Rect_Sash_4", - "openingType": "TiltTurn", - "shape": "Rectangular", "sashQty": 1, "sashPosition": 1 } diff --git a/WebAedificaConfigurator/WebAedificaConfigurator.csproj b/WebAedificaConfigurator/WebAedificaConfigurator.csproj index 127bb1f..9e3b60b 100644 --- a/WebAedificaConfigurator/WebAedificaConfigurator.csproj +++ b/WebAedificaConfigurator/WebAedificaConfigurator.csproj @@ -12,7 +12,7 @@ - + diff --git a/WebWindowComplex/AreaFrame.razor b/WebWindowComplex/Compo/AreaFrame.razor similarity index 60% rename from WebWindowComplex/AreaFrame.razor rename to WebWindowComplex/Compo/AreaFrame.razor index 6920bad..749d861 100644 --- a/WebWindowComplex/AreaFrame.razor +++ b/WebWindowComplex/Compo/AreaFrame.razor @@ -1,23 +1,22 @@ -
-
-
-
-

Area frame

+
+
+
+
+
Area frame
-
+
@if (CurrSashList.Count == 0 && CurrSplitList.Count == 0) { -
}
-
+
@if (!(CurrFrameWindow.AreaList[0] is Split)) {
- +
}
diff --git a/WebWindowComplex/AreaFrame.razor.cs b/WebWindowComplex/Compo/AreaFrame.razor.cs similarity index 81% rename from WebWindowComplex/AreaFrame.razor.cs rename to WebWindowComplex/Compo/AreaFrame.razor.cs index e48429e..b74d237 100644 --- a/WebWindowComplex/AreaFrame.razor.cs +++ b/WebWindowComplex/Compo/AreaFrame.razor.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Components; +using WebWindowComplex.Models; -namespace WebWindowComplex +namespace WebWindowComplex.Compo { public partial class AreaFrame { @@ -19,7 +20,7 @@ namespace WebWindowComplex public EventCallback EC_AddSash { get; set; } [Parameter] - public EventCallback EC_AddWindow { get; set; } + public EventCallback EC_AddSplit { get; set; } #endregion Public Properties @@ -38,9 +39,9 @@ namespace WebWindowComplex /// Sollevo evento richiesta aggiunta window /// /// - private async Task RaiseAddWindow() + private async Task RaiseAddSplit() { - await EC_AddWindow.InvokeAsync(true); + await EC_AddSplit.InvokeAsync(true); } #endregion Private Methods diff --git a/WebWindowComplex/Compo/AreaSash.razor b/WebWindowComplex/Compo/AreaSash.razor new file mode 100644 index 0000000..e053a2d --- /dev/null +++ b/WebWindowComplex/Compo/AreaSash.razor @@ -0,0 +1,65 @@ +
+
+
Sash @(CurrSashGroup.SashList.Count == 1 ? "" : (IndexSash + 1))
+
+
+ + +
+
+ Dimension + + % +
+
+
+ +
+
+ +
+
+ @if (!(CurrAnta.AreaList[0] is Split)) + { +
+
+
+ +
+
+
+
+ +
+
+
+ } +
+ @for (int k = 0; k <= CurrSashGroup.SashList.Count - 1; k++) + { + @if (k != IndexSash) + { + int IndexCopy = k; + int IndexModify = IndexSash; +
+
+ +
+
+ } + } +
+
diff --git a/WebWindowComplex/Compo/AreaSash.razor.cs b/WebWindowComplex/Compo/AreaSash.razor.cs new file mode 100644 index 0000000..997b23d --- /dev/null +++ b/WebWindowComplex/Compo/AreaSash.razor.cs @@ -0,0 +1,106 @@ +using Microsoft.AspNetCore.Components; +using WebWindowComplex.Models; + +namespace WebWindowComplex.Compo +{ + public partial class AreaSash + { + /// + /// Sash group corrente + /// + [Parameter] + public Sash CurrSashGroup { get; set; } = null!; + + /// + /// Sash dimension corrente + /// + [Parameter] + public SashDimension CurrSashDim { get; set; } = null!; + + /// + /// Indice della sash corrente + /// + [Parameter] + public int IndexSash { get; set; } = 0; + + /// + /// Evento per cambiare l'anta su cui presente la maniglia + /// + [Parameter] + public EventCallback EC_ChangeHandle { get; set; } + + /// + /// Evento per cambiare l'anta su cui presente la maniglia + /// + [Parameter] + public EventCallback EC_CopyContentSash { get; set; } + + /// + /// Anta corrente + /// + public Area CurrAnta + { + get + { + if(CurrSashGroup.AreaList[IndexSash] is Splitted) +{ + return CurrSashGroup.AreaList[IndexSash]; + } + else + { + return CurrSashGroup; + } + } + set + { + CurrAnta = value; + } + } + + /// + /// Sollevo evento per cambiare l'anta su cui presente la maniglia + /// + /// + private async Task RaiseChangeHandle(SashDimension sashDim, Sash currSash) + { + var Args = new DataChangeHandle + { + currSashDimension = sashDim, + currItem = currSash, + }; + await EC_ChangeHandle.InvokeAsync(Args); + } + + /// + /// Sollevo evento per cambiare l'anta su cui presente la maniglia + /// + /// + private async Task RaiseCopyContentSash(Sash currSash, int indexC, int indexM) + { + var Args = new DataCopyContentSash + { + currItem = currSash, + indexCopy = indexC, + indexModify = indexM, + }; + await EC_CopyContentSash.InvokeAsync(Args); + } + } + + public class DataChangeHandle + { + public SashDimension currSashDimension { get; set; } = null!; + public Sash currItem { get; set; } = null!; + + } + + public class DataCopyContentSash + { + public Sash currItem { get; set; } = null!; + + public int indexCopy { get; set; } = 0; + + public int indexModify { get; set; } = 0; + + } +} \ No newline at end of file diff --git a/WebWindowComplex/Compo/AreaSplit.razor b/WebWindowComplex/Compo/AreaSplit.razor new file mode 100644 index 0000000..dcd0424 --- /dev/null +++ b/WebWindowComplex/Compo/AreaSplit.razor @@ -0,0 +1,23 @@ +
+
+
+
+
Area split @(CurrSplittedList.Count > 1 ? (CurrSplittedList.IndexOf(CurrSplitted) + 1) : "")
+
+
+
+ +
+
+
+ @for (int j = 0; j < CurrSashList.Count; j++) + { + int Index = j; +
+ +
+ } +
+
+
+
diff --git a/WebWindowComplex/Compo/AreaSplit.razor.cs b/WebWindowComplex/Compo/AreaSplit.razor.cs new file mode 100644 index 0000000..c7c87b4 --- /dev/null +++ b/WebWindowComplex/Compo/AreaSplit.razor.cs @@ -0,0 +1,65 @@ +using Egw.Window.Data; +using Microsoft.AspNetCore.Components; +using WebWindowComplex.Models; + +namespace WebWindowComplex.Compo +{ + public partial class AreaSplit + { + #region Public Properties + + /// + /// Lista delle sash + /// + [Parameter] + public List CurrSashList { get; set; } = null; + + /// + /// Oggetto splitted corrente + /// + [Parameter] + public Splitted CurrSplitted { get; set; } = null; + + /// + /// Lista degli Splitted + /// + [Parameter] + public List CurrSplittedList { get; set; } = null; + + /// + /// Evento per copiare Sash + /// + [Parameter] + public EventCallback EC_CopySash { get; set; } + + #endregion Public Properties + + #region Private Methods + + /// + /// Sollevo evento richiesta copia sash + /// + /// + private async Task RaiseCopySash(Splitted item, int indexCurrSash) + { + var Args = new DataAreaSplit + { + splitted = item, + index = indexCurrSash, + }; + await EC_CopySash.InvokeAsync(Args); + } + + #endregion Private Methods + + } + + /// + /// Classe per raggruppare oggetti che servono per copiare Sash + /// + public class DataAreaSplit + { + public Splitted splitted { get; set; } + public int index { get; set; } + } +} \ No newline at end of file diff --git a/WebWindowComplex/Compo/CardFill.razor b/WebWindowComplex/Compo/CardFill.razor new file mode 100644 index 0000000..f09bdec --- /dev/null +++ b/WebWindowComplex/Compo/CardFill.razor @@ -0,0 +1,53 @@ + +
+
+
+
+
Fill @(CurrIndex + 1)
+
+
+ +
+
+
+
+
+
+
Select only current fill
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
Selected all fill
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+@foreach (var currSplitted in SplittedList) +{ + @if (currSplitted.AreaList.First().Equals(CurrItem)) + { + + } +} + diff --git a/WebWindowComplex/Compo/CardFill.razor.cs b/WebWindowComplex/Compo/CardFill.razor.cs new file mode 100644 index 0000000..36e4f4f --- /dev/null +++ b/WebWindowComplex/Compo/CardFill.razor.cs @@ -0,0 +1,124 @@ +using Microsoft.AspNetCore.Components; +using WebWindowComplex.Models; +using static WebWindowComplex.Json.WindowConst; + +namespace WebWindowComplex.Compo +{ + public partial class CardFill + { + #region Public Properties + + /// + /// Indice del fill corrente rispetto alla lista fill + /// + [Parameter] + public int CurrIndex { get; set; } = 0; + + /// + /// Fill corrente rispetto alla lista fill + /// + [Parameter] + public Fill CurrItem { get; set; } = null!; + + /// + /// Evento per cambiare tutti i fill + /// + [Parameter] + public EventCallback EC_ChangeAllType { get; set; } + + /// + /// Evento per cambiare solo il fill corrente + /// + [Parameter] + public EventCallback EC_ChangeType { get; set; } + + /// + /// Evento per copiare sash + /// + [Parameter] + public EventCallback EC_CopySash { get; set; } + + /// + /// Evento per tornare nella pagine Tree + /// + [Parameter] + public EventCallback EC_ReqClose { get; set; } + + /// + /// Lista dei Fill + /// + [Parameter] + public List FillList { get; set; } = null!; + + /// + /// Lista delle sash + /// + [Parameter] + public List SashList { get; set; } = null!; + + /// + /// Lista degli Splitted + /// + [Parameter] + public List SplittedList { get; set; } = null!; + + + #endregion Public Properties + + #region Protected Methods + + /// + /// Sollevo evento per cambiare tutti i Fill + /// + /// tipo di fill richiesto + /// + protected async Task ChangeAllFill(FillTypes reqFillType) + { + await EC_ChangeAllType.InvokeAsync(reqFillType); + } + + /// + /// Sollevo evento per cambiare solo il Fill corrente + /// + /// tipo di fill richiesto + /// + protected async Task ChangeOneFill(FillTypes reqFillType) + { + await EC_ChangeType.InvokeAsync(reqFillType); + } + + /// + /// Sollevo evento per copiare sash + /// + /// + /// + protected async Task CopySash(DataAreaSplit Args) + { + await EC_CopySash.InvokeAsync(Args); + } + + #endregion Protected Methods + + #region Private Methods + + /// + /// Sollevo evento per tornare alla pagina Tree + /// + private void ReqClose() + { + _ = EC_ReqClose.InvokeAsync(true); + } + + /// + /// Calcola bottone selezionato per il Fill + /// + /// + private string buttonFillCss(FillTypes reqFillTypes) + { + return (FillList.ElementAt(CurrIndex).SelFillType == reqFillTypes) ? "btn btn-secondary btn-sm" : "btn btn-outline-secondary btn-sm"; + } + + #endregion Private Methods + + } +} \ No newline at end of file diff --git a/WebWindowComplex/Compo/CardFrame.razor b/WebWindowComplex/Compo/CardFrame.razor new file mode 100644 index 0000000..d14199e --- /dev/null +++ b/WebWindowComplex/Compo/CardFrame.razor @@ -0,0 +1,108 @@ +@using static WebWindowComplex.LayoutConst + +
+
+
+
+
Frame
+
+
+ +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
Dimension
+
+ @foreach (FrameDimension dimension in FrameWindow.DimensionList) + { + + } +
+
+
+
Threshold
+
+
+ + +
+
+
+
+
+
+
+
+
Joints
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ @foreach (Joint joint in FrameWindow.JointList) + { + + } +
+
+
+ @if (SashList.Count == 0) + { +
+
Bottom rail
+
+
+
+ Quantity + +
+
+ } +
+
+
+
+ +@if (!(FrameWindow.AreaList[0] is Split) || (SashList.Count == 0 && SplitList.Count == 0)) +{ + +} + \ No newline at end of file diff --git a/WebWindowComplex/Compo/CardFrame.razor.cs b/WebWindowComplex/Compo/CardFrame.razor.cs new file mode 100644 index 0000000..1f33a46 --- /dev/null +++ b/WebWindowComplex/Compo/CardFrame.razor.cs @@ -0,0 +1,150 @@ +using Microsoft.AspNetCore.Components; +using WebWindowComplex.Models; + +namespace WebWindowComplex.Compo +{ + public partial class CardFrame + { + #region Public Properties + + /// + /// Evento per aggiungere sash + /// + [Parameter] + public EventCallback EC_AddSash { get; set; } + + /// + /// Evento per aggiungere split + /// + [Parameter] + public EventCallback EC_AddSplit { get; set; } + + /// + /// Evento per cambiare tutti i Joints + /// + [Parameter] + public EventCallback EC_ChangeAllJoints { get; set; } + + /// + /// Evento per tornare nella pagine Tree + /// + [Parameter] + public EventCallback EC_ReqClose { get; set; } + + /// + /// Evento per cambiare tutti i Joints + /// + [Parameter] + public EventCallback EC_UpdateFrame { get; set; } + + /// + /// Frame corrente + /// + [Parameter] + public Frame FrameWindow { get; set; } = null!; + + /// + /// Lista di sash + /// + [Parameter] + public List SashList { get; set; } = null!; + + /// + /// Lista di split + /// + [Parameter] + public List SplitList { get; set; } = null!; + + #endregion Public Properties + + #region Private Methods + + /// + /// Sollevo evento richiesta aggiunta sash + /// + /// + private async Task AddSash() + { + await EC_AddSash.InvokeAsync(true); + } + + /// + /// Sollevo evento richiesta aggiunta window + /// + /// + private async Task AddSplit() + { + await EC_AddSplit.InvokeAsync(true); + } + + /// + /// Sollevo evento richiesta copia sash + /// + /// + private async Task ChangeAllJoints(Json.WindowConst.Joints JointType, Area a) + { + var Args = new DataChangeJoints + { + currJointType = JointType, + currArea = a, + }; + await EC_ChangeAllJoints.InvokeAsync(Args); + } + + /// + /// Sollevo evento per tornare alla pagina Tree + /// + private void ReqClose() + { + _ = EC_ReqClose.InvokeAsync(true); + } + + /// + /// Aggiornamento dimensione editata + /// + /// + private async Task UpdateDim(FrameDimension updRec) + { + // cerco il record + var currRec = FrameWindow.DimensionList.FirstOrDefault(x => x.ParentFrame == updRec.ParentFrame && x.nIndex == updRec.nIndex); + // lo aggiorno + if (updRec != null) + { + currRec = updRec; + await EC_UpdateFrame.InvokeAsync(FrameWindow); + } + } + + /// + /// Report aggiornamento joint + /// + /// + /// + private async Task UpdateJoint(Joint updRec) + { + // cerco il record + var currRec = FrameWindow.JointList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex); + // lo aggiorno + if (updRec != null) + { + currRec = updRec; + await EC_UpdateFrame.InvokeAsync(FrameWindow); + } + } + + #endregion Private Methods + } + + /// + /// Classe per raggruppare oggetti che servono per copiare Sash + /// + public class DataChangeJoints + { + #region Public Properties + + public Area currArea { get; set; } = null!; + public Json.WindowConst.Joints currJointType { get; set; } + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/WebWindowComplex/Compo/CardSashGroup.razor b/WebWindowComplex/Compo/CardSashGroup.razor new file mode 100644 index 0000000..7445425 --- /dev/null +++ b/WebWindowComplex/Compo/CardSashGroup.razor @@ -0,0 +1,128 @@ +@using static WebWindowComplex.LayoutConst + +
+
+
+
+
Sash group @(SashList.Count > 1 ? (CurrIndex + 1) : "")
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+ Qty sash + +
+
+
+
+
+
+ + +
+
+
+
+ Qty bottom rail + +
+
+
+
+
+
+
+
+
Joints
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+ @foreach (Joint joint in CurrItem.JointList) + { + + } +
+
+
+
+
Hardware
+
+
+
+ + +
+
+ + +
+
+
+
+
+ +
+
+
+ @for (int i = 0; i < CurrItem.SashList.Count; i++) + { + + } +
+
+
+ + + \ No newline at end of file diff --git a/WebWindowComplex/Compo/CardSashGroup.razor.cs b/WebWindowComplex/Compo/CardSashGroup.razor.cs new file mode 100644 index 0000000..995c11a --- /dev/null +++ b/WebWindowComplex/Compo/CardSashGroup.razor.cs @@ -0,0 +1,131 @@ +using Microsoft.AspNetCore.Components; +using WebWindowComplex.Models; + +namespace WebWindowComplex.Compo +{ + public partial class CardSashGroup + { + /// + /// Indice della sash corrente rispetto alla lista sash + /// + [Parameter] + public int CurrIndex { get; set; } = 0; + + /// + /// Sash corrente rispetto alla lista Sash + /// + [Parameter] + public Sash CurrItem { get; set; } = null!; + + /// + /// Lista di sash + /// + [Parameter] + public List SashList { get; set; } = null!; + + /// + /// Evento per cambiare tutti i fill + /// + [Parameter] + public EventCallback EC_RemoveArea { get; set; } + + /// + /// Evento per cambiare tutti i Joints + /// + [Parameter] + public EventCallback EC_ChangeAllJoints { get; set; } + + /// + /// Evento per cambiare l'anta su cui presente la maniglia + /// + [Parameter] + public EventCallback EC_ChangeHandle { get; set; } + + /// + /// Evento per cambiare l'anta su cui presente la maniglia + /// + [Parameter] + public EventCallback EC_CopyContentSash { get; set; } + + /// + /// Evento per cambiare tutti i Joints + /// + [Parameter] + public EventCallback EC_UpdateSash { get; set; } + + /// + /// Evento per tornare nella pagine Tree + /// + [Parameter] + public EventCallback EC_ReqClose { get; set; } + + /// + /// Sollevo evento per rimuovere area + /// + /// area da rimuovere + /// + protected async Task RemoveArea(Area currArea) + { + await EC_RemoveArea.InvokeAsync(currArea); + } + + /// + /// Sollevo evento richiesta per cambiare tutti i Joint + /// + /// + private async Task ChangeAllJoints(Json.WindowConst.Joints JointType, Area a) + { + var Args = new DataChangeJoints + { + currJointType = JointType, + currArea = a, + }; + await EC_ChangeAllJoints.InvokeAsync(Args); + } + + /// + /// Sollevo evento per cambiare l'anta su cui presente la maniglia + /// + /// + private async Task ChangeHandle(DataChangeHandle Args) + { + await EC_ChangeHandle.InvokeAsync(Args); + } + + /// + /// Sollevo evento per cambiare l'anta su cui presente la maniglia + /// + /// + private async Task CopyContentSash(DataCopyContentSash Args) + { + await EC_CopyContentSash.InvokeAsync(Args); + } + + /// + /// Report aggiornamento joint + /// + /// + /// + private async Task UpdateJoint(Joint updRec) + { + // cerco il record + var currRec = CurrItem.JointList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex); + // lo aggiorno + if (updRec != null) + { + currRec = updRec; + await EC_UpdateSash.InvokeAsync(CurrItem); + } + } + + /// + /// Sollevo evento per tornare alla pagina Tree + /// + private void ReqClose() + { + _ = EC_ReqClose.InvokeAsync(true); + } + + } + +} \ No newline at end of file diff --git a/WebWindowComplex/Compo/CardSplit.razor b/WebWindowComplex/Compo/CardSplit.razor new file mode 100644 index 0000000..f2fa5e4 --- /dev/null +++ b/WebWindowComplex/Compo/CardSplit.razor @@ -0,0 +1,132 @@ + +
+
+
+
+
@(descParentSplit(CurrItem))
+
+
+ +
+
+
+
+
+
+
Split
+
+
+ @if ((CurrItem.nSplitQtyVert == 1 && CurrItem.nSplitQtyHoriz == 0) || (CurrItem.nSplitQtyVert == 0 && CurrItem.nSplitQtyHoriz == 1)) + { +
+ +
+ } +
+
+
+ +
+
+
+
+
+
+ + +
+
+
+
+ @if (CurrItem.nSplitQtyVert > 0) + { +
+
+ QtyVert + +
+
+ } + @if (CurrItem.nSplitQtyHoriz > 0) + { +
+
+ QtyHoriz + +
+
+ } +
+
+ @if (CurrItem.SplitVertList.Count > 0 && CurrItem.SplitHorizList.Count > 0) + { +
+ @foreach (var dim in CurrItem.SplitVertList) + { +
+ Width + + % +
+ } +
+
+ @foreach (var dim in CurrItem.SplitHorizList) + { +
+ Height + + % +
+ } +
+ } + else if (CurrItem.SplitHorizList.Count > 0) + { + @foreach (var dim in CurrItem.SplitHorizList) + { +
+
+ Height + + % +
+
+ } + } + else if (CurrItem.SplitVertList.Count > 0) + { + @foreach (var dim in CurrItem.SplitVertList) + { +
+
+ Width + + % +
+
+ } + } +
+ @if (CurrItem.SelSplitShape == Json.WindowConst.SplitShapes.GRID) + { +
+
+
+
+ +
+
+ +
+
+
+
+ } +
+
diff --git a/WebWindowComplex/Compo/CardSplit.razor.cs b/WebWindowComplex/Compo/CardSplit.razor.cs new file mode 100644 index 0000000..2b952dd --- /dev/null +++ b/WebWindowComplex/Compo/CardSplit.razor.cs @@ -0,0 +1,139 @@ +using Microsoft.AspNetCore.Components; +using WebWindowComplex.Models; + +namespace WebWindowComplex.Compo +{ + public partial class CardSplit + { + /// + /// Indice del fill corrente rispetto alla lista fill + /// + [Parameter] + public int CurrIndex { get; set; } = 0; + + /// + /// Fill corrente rispetto alla lista fill + /// + [Parameter] + public Split CurrItem { get; set; } = null!; + + /// + /// Lista di sash + /// + [Parameter] + public List SashList { get; set; } = null!; + + /// + /// Lista di split + /// + [Parameter] + public List SplitList { get; set; } = null!; + + /// + /// Evento per scambiare le aree di uno split + /// + [Parameter] + public EventCallback EC_SwapTwoAree { get; set; } + + /// + /// Evento per rimuovere split + /// + [Parameter] + public EventCallback EC_RemoveArea { get; set; } + + /// + /// Evento per cambiare nel caso di split a griglia se inizia con lo split verticale + /// + [Parameter] + public EventCallback EC_ChangeStartVert { get; set; } + + /// + /// Evento per tornare nella pagine Tree + /// + [Parameter] + public EventCallback EC_ReqClose { get; set; } + + /// + /// Sollevo evento per scambiare le aree di uno split + /// + /// split corrente + /// + protected async Task SwapTwoAree(Split item) + { + await EC_SwapTwoAree.InvokeAsync(item); + } + + /// + /// Sollevo evento per rimuovere split + /// + /// split corrente + /// + protected async Task RemoveArea(Split item) + { + await EC_RemoveArea.InvokeAsync(item); + } + + /// + /// Sollevo evento per rimuovere split + /// + /// split corrente + /// + protected async Task ChangeStartVert(ChangeEventArgs e, Split item) + { + var Args = new DataChangeStartVert + { + eventArg = e, + currItem = item, + }; + await EC_ChangeStartVert.InvokeAsync(Args); + } + + /// + /// 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 group " + (j + 1) + " - sash " + (k + 1); + } + } + } + } + } + else + { + return "Frame"; + } + return ""; + } + + /// + /// Sollevo evento per tornare alla pagina Tree + /// + private void ReqClose() + { + _ = EC_ReqClose.InvokeAsync(true); + } + } + + public class DataChangeStartVert + { + public ChangeEventArgs eventArg { get; set; } = null!; + public Split currItem { get; set; } + } +} \ No newline at end of file diff --git a/WebWindowComplex/Compo/CardTree.razor b/WebWindowComplex/Compo/CardTree.razor new file mode 100644 index 0000000..214df6d --- /dev/null +++ b/WebWindowComplex/Compo/CardTree.razor @@ -0,0 +1,45 @@ +@using static WebWindowComplex.LayoutConst + + + + @for (int i = 0; i < ItemTableList.Count; i++) + { + + @for (int j = 0; j < maxCol; j++) + { + CompileStep cs = CompileStep.Frame; + int ind = -1; + @if (j + 1 == ItemTableList[i].Col) + { + @if (ItemTableList[i].Type is Json.WindowConst.AreaTypes.FRAME) + { + cs = CompileStep.Frame; + } + else if (ItemTableList[i].Type is Json.WindowConst.AreaTypes.SPLIT) + { + cs = CompileStep.Split; + ind = ItemTableList[i].IndexItem; + } + else if (ItemTableList[i].Type is Json.WindowConst.AreaTypes.SASH) + { + cs = CompileStep.Sash; + ind = ItemTableList[i].IndexItem; + } + else if (ItemTableList[i].Type is Json.WindowConst.AreaTypes.FILL) + { + cs = CompileStep.Fill; + ind = ItemTableList[i].IndexItem; + } + + } + else + { + + } + } + + } + +
+ + @FillTable(i, j)
\ No newline at end of file diff --git a/WebWindowComplex/Compo/CardTree.razor.cs b/WebWindowComplex/Compo/CardTree.razor.cs new file mode 100644 index 0000000..923541a --- /dev/null +++ b/WebWindowComplex/Compo/CardTree.razor.cs @@ -0,0 +1,139 @@ +using Microsoft.AspNetCore.Components; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static WebWindowComplex.LayoutConst; + +namespace WebWindowComplex.Compo +{ + public partial class CardTree + { + /// + /// Lista oggetti ItemTable + /// + [Parameter] + public List ItemTableList { get; set; } = null!; + + /// + /// Numero massimo di colonne + /// + [Parameter] + public int maxCol { get; set; } = 0; + + /// + /// Evento richiesta prossimo step + /// + [Parameter] + public EventCallback EC_NextStep { get; set; } + + /// + /// Sollevo evento richiesta prossimo step + /// + /// + private async Task RaiseNextStep(CompileStep cs, int indexStep) + { + var Args = new DataNextStep + { + currCompileStep = cs, + index = indexStep, + }; + await EC_NextStep.InvokeAsync(Args); + } + + /// + /// Metodo per riempire tabella con contenuto vuoto o con i simboli per rappresentare la struttura + /// + /// riga della cella + /// colonna della cella + /// + private string FillTable(int row, int col) + { + List itemSameCol = new List(); + for (int k = 0; k < row; k++) + { + if (ItemTableList[k].Col == col + 1) + { + itemSameCol.Add(ItemTableList[k]); + } + continue; + } + int numItemNextCol = 0; + for (int k = 0; k < row; k++) + { + if (ItemTableList[k].Row <= row && ItemTableList[k].Col == col + 2) + { + numItemNextCol++; + } + continue; + } + if (itemSameCol.Count > 1) + { + for (int i = 0; i <= itemSameCol.Count - 2; i++) + { + if (itemSameCol[i].NumChild > 0) + numItemNextCol = numItemNextCol - itemSameCol[i].NumChild; + } + } + if (itemSameCol.Count > 0) + { + // Sono alla riga successiva di un elemento e nella stessa colonna + if (itemSameCol.Last().Row == row) + { + // se ha un solo figlio + if (itemSameCol.Last().NumChild == 1) + { + return "└"; + } + else if (itemSameCol.Last().NumChild == 0) + { + return " "; + } + else + { + return "├"; + } + } + // Non sono alla riga successiva + else + { + // se ha un solo figlio + if (itemSameCol.Last().NumChild == 1) + { + return " "; + } + else if (col + 2 <= maxCol && ItemTableList[row].Col == col + 2) + { + if (numItemNextCol < itemSameCol.Last().NumChild && numItemNextCol != (itemSameCol.Last().NumChild - 1)) + { + return "├"; + } + return "└"; + } + else if (numItemNextCol < itemSameCol.Last().NumChild) + { + return "│"; + } + else + { + return " "; + } + } + } + else + { + return " "; + } + } + } + + /// + /// Classe per inserire dati per NextStep + /// + public class DataNextStep + { + public CompileStep currCompileStep { get; set; } + public int index { get; set; } + } +} diff --git a/WebWindowComplex/Compo/EditDimensions.razor b/WebWindowComplex/Compo/EditDimensions.razor new file mode 100644 index 0000000..9ac6cfe --- /dev/null +++ b/WebWindowComplex/Compo/EditDimensions.razor @@ -0,0 +1,7 @@ + +
+ @CurrRec.sName + + mm +
+ diff --git a/WebWindowComplex/Compo/EditDimensions.razor.cs b/WebWindowComplex/Compo/EditDimensions.razor.cs new file mode 100644 index 0000000..d94acb8 --- /dev/null +++ b/WebWindowComplex/Compo/EditDimensions.razor.cs @@ -0,0 +1,35 @@ +using Microsoft.AspNetCore.Components; +using WebWindowComplex.Models; + +namespace WebWindowComplex.Compo +{ + public partial class EditDimensions + { + #region Public Properties + + [Parameter] + public FrameDimension CurrRec { get; set; } = null!; + + [Parameter] + public EventCallback EC_Update { get; set; } + + #endregion Public Properties + + #region Private Properties + + private double CurrVal + { + get => CurrRec.dValue; + set + { + if (CurrRec.dValue != value) + { + CurrRec.dValue = value; + _ = EC_Update.InvokeAsync(CurrRec); + } + } + } + + #endregion Private Properties + } +} \ No newline at end of file diff --git a/WebWindowComplex/Compo/EditJoint.razor b/WebWindowComplex/Compo/EditJoint.razor new file mode 100644 index 0000000..1ffcd67 --- /dev/null +++ b/WebWindowComplex/Compo/EditJoint.razor @@ -0,0 +1,9 @@ +@using static WebWindowComplex.LayoutConst +
+ + +
\ No newline at end of file diff --git a/WebWindowComplex/Compo/EditJoint.razor.cs b/WebWindowComplex/Compo/EditJoint.razor.cs new file mode 100644 index 0000000..2835920 --- /dev/null +++ b/WebWindowComplex/Compo/EditJoint.razor.cs @@ -0,0 +1,35 @@ +using Microsoft.AspNetCore.Components; +using WebWindowComplex.Models; + +namespace WebWindowComplex.Compo +{ + public partial class EditJoint + { + #region Public Properties + + [Parameter] + public Joint CurrRec { get; set; } = null!; + + [Parameter] + public EventCallback EC_Update { get; set; } + + #endregion Public Properties + + #region Private Properties + + private int CurrVal + { + get => CurrRec.SelJointTypeIndex; + set + { + if (CurrRec.SelJointTypeIndex != value) + { + CurrRec.SelJointTypeIndex = value; + _ = EC_Update.InvokeAsync(CurrRec); + } + } + } + + #endregion Private Properties + } +} \ No newline at end of file diff --git a/WebWindowComplex/Compo/General.razor b/WebWindowComplex/Compo/General.razor new file mode 100644 index 0000000..8088a81 --- /dev/null +++ b/WebWindowComplex/Compo/General.razor @@ -0,0 +1,88 @@ + +
+
+
+
+
General
+
+
+ +
+
+
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
+
Fill type
+
+
+
+ + +
+
+ + +
+
+
+
+
+
Color
+
+
+
+ + +
+
+ + +
+
+
+
+
+
diff --git a/WebWindowComplex/General.razor.cs b/WebWindowComplex/Compo/General.razor.cs similarity index 79% rename from WebWindowComplex/General.razor.cs rename to WebWindowComplex/Compo/General.razor.cs index 4eb2303..9ed2b11 100644 --- a/WebWindowComplex/General.razor.cs +++ b/WebWindowComplex/Compo/General.razor.cs @@ -1,7 +1,8 @@ using Microsoft.AspNetCore.Components; using WebWindowComplex.DTO; +using WebWindowComplex.Models; -namespace WebWindowComplex +namespace WebWindowComplex.Compo { public partial class General { @@ -22,6 +23,12 @@ namespace WebWindowComplex [Parameter] public EventCallback EC_SelWindMat { get; set; } + [Parameter] + public EventCallback EC_SelProfile { get; set; } + + [Parameter] + public EventCallback EC_ReqClose { get; set; } + /// /// Elenco anagrafiche di base /// @@ -68,6 +75,16 @@ namespace WebWindowComplex } } + protected string CurrProfile + { + get => currProfile; + set + { + currProfile = value; + _ = EC_SelProfile.InvokeAsync(value); + } + } + #endregion Protected Properties #region Protected Methods @@ -87,6 +104,7 @@ namespace WebWindowComplex currColor = CurrWindow.sColorMaterial; currGlass = CurrWindow.sGlass; currMaterial = CurrWindow.sMaterial; + currProfile = CurrWindow.sProfilePath; } #endregion Protected Methods @@ -96,7 +114,13 @@ namespace WebWindowComplex private string currColor = ""; private string currGlass = ""; private string currMaterial = ""; + private string currProfile = ""; #endregion Private Fields + + private void ReqClose() + { + _ = EC_ReqClose.InvokeAsync(true); + } } } \ No newline at end of file diff --git a/WebWindowComplex/DTO/BaseListPayload.cs b/WebWindowComplex/DTO/BaseListPayload.cs index f9ece32..7690641 100644 --- a/WebWindowComplex/DTO/BaseListPayload.cs +++ b/WebWindowComplex/DTO/BaseListPayload.cs @@ -44,6 +44,11 @@ namespace WebWindowComplex.DTO /// public List Glass { get; set; } = null!; + /// + /// Elenco profili ammessi + /// + public List Profile { get; set; } = null!; + /// /// Verifica di validità dell'intero Payload /// @@ -55,7 +60,8 @@ namespace WebWindowComplex.DTO 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; + bool profileOK = Profile != null && Profile.Count > 0; + return famHwOK && glassOK && hwOK && colorOK && matOK && profileOK; } /// /// Verifica che Payload sia almeno parzialmente popolato @@ -68,7 +74,8 @@ namespace WebWindowComplex.DTO 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; + bool profileOK = Profile != null && Profile.Count > 0; + return famHwOK || glassOK || hwOK || colorOK || matOK || profileOK; } } } diff --git a/WebWindowComplex/DTO/SelectPayload.cs b/WebWindowComplex/DTO/SelectPayload.cs index 27d1460..4ed2efe 100644 --- a/WebWindowComplex/DTO/SelectPayload.cs +++ b/WebWindowComplex/DTO/SelectPayload.cs @@ -34,6 +34,11 @@ namespace WebWindowComplex.DTO /// public string Glass { get; set; } = string.Empty; + /// + /// Tipologia profilo selezionato + /// + public string Profile { get; set; } = string.Empty; + /// /// Template selezionato /// @@ -49,8 +54,9 @@ namespace WebWindowComplex.DTO bool colorOK = !string.IsNullOrEmpty(ColorMaterial); bool glassOk = !string.IsNullOrEmpty(Glass); bool matOK = !string.IsNullOrEmpty(Material); + bool profileOK = !string.IsNullOrEmpty(Profile); bool templateOK = Template != null; - return famHwOK && colorOK && matOK && glassOk && templateOK; + return famHwOK && colorOK && matOK && glassOk && templateOK && profileOK; } } } diff --git a/WebWindowComplex/General.razor b/WebWindowComplex/General.razor deleted file mode 100644 index b8264d3..0000000 --- a/WebWindowComplex/General.razor +++ /dev/null @@ -1,92 +0,0 @@ - -
-
-
-
-
-
-
-
-
-
General
-
-
-
-
-
- - -
-
- - -
-
-
-
-
-
-
-
Fill type
-
-
-
- - -
-
- - -
-
-
-
-
-
Color
-
-
-
- - -
-
- - -
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file diff --git a/WebWindowComplex/Json/JsonUtility.cs b/WebWindowComplex/Json/JsonUtility.cs index a1edcdf..c60fe9b 100644 --- a/WebWindowComplex/Json/JsonUtility.cs +++ b/WebWindowComplex/Json/JsonUtility.cs @@ -3,6 +3,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Serialization; +using WebWindowComplex.Models; using static WebWindowComplex.Json.WindowConst; namespace WebWindowComplex.Json diff --git a/WebWindowComplex/LayoutConst.cs b/WebWindowComplex/LayoutConst.cs new file mode 100644 index 0000000..0c16781 --- /dev/null +++ b/WebWindowComplex/LayoutConst.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebWindowComplex +{ + public partial class LayoutConst + { + public enum CompileStep + { + Template = 0, + Tree = 1, + Frame, + Split, + Sash, + Fill, + General + } + + public enum PositionJoints + { + BL = 0, // Bottom Left + BR = 1, // Bottom Right + TR, // Top Right + TL // Top Left + } + } +} diff --git a/WebWindowComplex/Models/AGBOptionCombo.cs b/WebWindowComplex/Models/AGBOptionCombo.cs new file mode 100644 index 0000000..8413114 --- /dev/null +++ b/WebWindowComplex/Models/AGBOptionCombo.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebWindowComplex.Models +{ + public class AGBOptionCombo : ParametriOpzioni + { + #region Public Constructors + + public AGBOptionCombo(ParametriOpzioniParametri HdwOptionParam) : base(HdwOptionParam) + { + m_Type = HDWOPTIONTYPES.COMBO; + foreach (var Value in HdwOptionParam.Opzioni) + m_ValueList.Add(new AGBOptionParameter(Value.Valore, Value.DescrizioneOpzione)); + m_sValue = m_ValueList.FirstOrDefault(x => x.sValue == HdwOptionParam.ValoreCorrente) ?? new AGBOptionParameter("", ""); + } + + #endregion Public Constructors + + #region Public Properties + + public AGBOptionParameter sValue + { + get + { + return m_sValue; + } + set + { + m_sValue = value; + } + } + + public List ValueList + { + get + { + return m_ValueList; + } + } + + #endregion Public Properties + + #region Private Fields + + private AGBOptionParameter m_sValue; + private List m_ValueList = new List(); + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/WebWindowComplex/Models/AGBOptionParameter.cs b/WebWindowComplex/Models/AGBOptionParameter.cs new file mode 100644 index 0000000..8e90c21 --- /dev/null +++ b/WebWindowComplex/Models/AGBOptionParameter.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebWindowComplex.Models +{ + public class AGBOptionParameter + { + #region Public Constructors + + public AGBOptionParameter(string sValue, string sDescription) + { + m_sValue = sValue; + m_sDescription = sDescription; + } + + #endregion Public Constructors + + #region Public Properties + + public string sDescription + { + get + { + return m_sDescription; + } + } + + public string sValue + { + get + { + return m_sValue; + } + } + + #endregion Public Properties + + #region Private Fields + + private string m_sDescription; + private string m_sValue; + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/WebWindowComplex/Models/AGBOptionText.cs b/WebWindowComplex/Models/AGBOptionText.cs new file mode 100644 index 0000000..252c814 --- /dev/null +++ b/WebWindowComplex/Models/AGBOptionText.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebWindowComplex.Models +{ + public class AGBOptionText : ParametriOpzioni + { + #region Public Constructors + + public AGBOptionText(ParametriOpzioniParametri HdwOptionParam) : base(HdwOptionParam) + { + m_Type = HDWOPTIONTYPES.TEXT; + m_sValue = HdwOptionParam.ValoreCorrente; + } + + #endregion Public Constructors + + #region Public Properties + + public string sValue + { + get + { + return m_sValue; + } + set + { + m_sValue = value; + } + } + + #endregion Public Properties + + #region Private Fields + + private string m_sValue; + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/WebWindowComplex/Models/Area.cs b/WebWindowComplex/Models/Area.cs new file mode 100644 index 0000000..8cac943 --- /dev/null +++ b/WebWindowComplex/Models/Area.cs @@ -0,0 +1,264 @@ +using WebWindowComplex.Json; +using static WebWindowComplex.Json.WindowConst; + +namespace WebWindowComplex.Models +{ + public abstract class Area + { + #region Public Constructors + + public Area(Area ParentArea, Window ParentWindow) + { + m_ParentWindow = ParentWindow; + m_ParentArea = ParentArea; + } + + #endregion Public Constructors + + #region Public Properties + + public static int nCounterGroup + { + get => m_CounterGroup; + set => m_CounterGroup = value; + } + + public List AreaList + { + get + { + return m_AreaList; + } + set + { + m_AreaList = value; + } + } + + public AreaTypes AreaType + { + get + { + return m_AreaType; + } + set + { + m_AreaType = value; + } + } + + public int IdGroup + { + get + { + return m_IdGroup; + } + + set + { + m_IdGroup = value; + } + } + + public int nAreaId + { + get + { + return m_nAreaId; + } + set + { + m_nAreaId = value; + m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + } + } + + public Area ParentArea + { + get + { + return m_ParentArea; + } + } + + public Window ParentWindow + { + get + { + return m_ParentWindow; + } + } + + #endregion Public Properties + + #region Public Methods + + public static void AddCounterGroup() + { + m_CounterGroup++; + } + + public bool AddFirstSash() + { + bool answ = false; + // Salvo il parent + Area ParentArea = AreaList[0].ParentArea; + // Creo area sash di default + Sash SashArea = Sash.CreateSash(ParentArea); + // ricerco tra ttuti gli hw disponibili... + string sShape = FindSashShape(); + var listHwValid = Sash + .m_HardwareCompleteList + .Where(x => x.Shape == sShape && x.SashQty == 1) + .FirstOrDefault(); + if (listHwValid != null) + { + // seleziono la famiglia del primo hw trovato... + SashArea.SelFamilyHardware = listHwValid.FamilyName; + SashArea.RefreshHardwareList(); + if (SashArea.HardwareList.Count == 0) + { + SashArea.Remove(); + answ = true; + } + else + { + SashArea.SetSelHardwareFromId(SashArea.HardwareList.First().Id); + // Salvo gli oggetti già presenti e li cancello da AreaList + List ContentArea = new List(); + ContentArea.Add(AreaList[0]); + AreaList.Remove(AreaList[0]); + // Aggiungo area + AreaList.Add(SashArea); + if (SashArea.nSashQty == 1) + { + // Inserisco il riempimento precedente + AreaList[0].AreaList.Add(ContentArea[0]); + AreaList[0].AreaList[0].SetParentArea(AreaList[0]); + } + else + { + // All'area Sash aggiunto uno Splitted per ogni anta + for (int i = 1; i < SashArea.nSashQty; i++) + { + AreaList[0].AreaList.Add(Splitted.CreateSplitted(SashArea)); + } + Fill fill2 = (Fill)ContentArea[0]; + for (int i = 1; i < SashArea.nSashQty; i++) + { + AreaList[0].AreaList[1].AreaList.Add(Fill.CreateFill(AreaList[0].AreaList[1], fill2.FillType)); + } + } + ParentWindow.OnUpdatePreview(ParentWindow.sSerialized()); + } + } + return answ; + } + + public void AddSplit(Area ParentArea) + { + List ContentArea = new List(); + // Salvo gli oggetti già presenti e li cancello da AreaList + ContentArea.Add(AreaList[0]); + AreaList.Remove(AreaList[0]); + // Aggiungo Area split di default + Split SplitArea = Split.CreateSplit(this, SplitShapes.HORIZONTAL); + // imposto i parametri di default + SplitArea.SetSplitQtyHoriz(1); + SplitArea.SetSplitStartVert(false); + // Aggiungo area + AreaList.Add(SplitArea); + // Creo le due aree Splitted + List newSplittedList = new List(); + for (int i = 0; i < 2; i++) + newSplittedList.Add(Splitted.CreateSplitted(SplitArea)); + // Inserisco nelle aree Splitted il Fill salvato e un Fill uguale (e setto ParentArea del fill) + ContentArea[0].SetParentArea(newSplittedList[0]); + newSplittedList[0].AreaList.Add(ContentArea[0]); + if (ContentArea[0] is Fill) + { + Fill fill1 = (Fill)ContentArea[0]; + Fill fill2 = Fill.CreateFill(newSplittedList[1], fill1.FillType); + newSplittedList[1].AreaList.Add(fill2); + } + else + { + Fill fill2 = Fill.CreateFill(newSplittedList[1], FillTypes.GLASS); + newSplittedList[1].AreaList.Add(fill2); + } + // All'area Split aggiunto le due aree Splitted + for (int i = 0; i < 2; i++) + AreaList[0].AreaList.Add(newSplittedList[i]); + ParentWindow.OnUpdatePreview(ParentWindow.sSerialized()); + } + + public abstract Area Copy(Area ParentArea); + + public void SetIdGroup(int nIdGroup) + { + m_IdGroup = nIdGroup; + } + + public void SwapAree() + { + Area tempArea; + if (this is Sash || this is Split) + { + tempArea = AreaList[0]; + AreaList[0] = AreaList[1]; + AreaList[1] = tempArea; + } + } + + #endregion Public Methods + + #region Internal Methods + + internal abstract JsonArea Serialize(); + + internal void SetAreaType(AreaTypes AreaType) + { + m_AreaType = AreaType; + } + + internal void SetParentArea(Area ParentArea) + { + m_ParentArea = ParentArea; + } + + #endregion Internal Methods + + #region Protected Fields + + protected int m_nAreaId = -1; + + protected Window m_ParentWindow; + + #endregion Protected Fields + + #region Private Fields + + // Conteggio dei macro elementi + private static int m_CounterGroup = 0; + + private List m_AreaList = new List(); + private AreaTypes m_AreaType; + private int m_IdGroup; + private Area m_ParentArea; + + #endregion Private Fields + + #region Private Methods + + /// + /// MockUp chiamata a c++ x scelta forma sash per Hw + /// + /// + private string FindSashShape() + { + return "Rectangular"; + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/WebWindowComplex/Models/Fill.cs b/WebWindowComplex/Models/Fill.cs new file mode 100644 index 0000000..5fe8ee1 --- /dev/null +++ b/WebWindowComplex/Models/Fill.cs @@ -0,0 +1,117 @@ +using WebWindowComplex.Json; +using static WebWindowComplex.Json.WindowConst; + +namespace WebWindowComplex.Models +{ + public class Fill : Area + { + #region Public Constructors + + public Fill(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow) + { + } + + #endregion Public Constructors + + #region Public Properties + + public FillTypes FillType + { + get + { + return (FillTypes)m_SelFillType; + } + } + + public List FillTypeList + { + get + { + return m_FillTypeList; + } + } + + public FillTypes SelFillType + { + get + { + return m_SelFillType; + } + set + { + m_SelFillType = value; + } + } + + public int SelFillTypeIndex + { + get + { + return IdNameStruct.IndFromId((int)m_SelFillType, m_FillTypeList); + } + set + { + m_SelFillType = (FillTypes)IdNameStruct.IdFromInd(value, m_FillTypeList); + m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + } + } + + #endregion Public Properties + + #region Public Methods + + 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; + } + + #endregion Public Methods + + #region Internal Methods + + 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; + } + + internal override JsonArea Serialize() + { + if (nCounterGroup < IdGroup) + Area.nCounterGroup = IdGroup; + JsonFill JsonFill = new JsonFill(FillType, IdGroup); + foreach (var Area in AreaList) + JsonFill.AreaList.Add(Area.Serialize()); + return JsonFill; + } + + internal void SetFillType(FillTypes value) + { + m_SelFillType = value; + m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + } + + #endregion Internal Methods + + #region Private Fields + + private List m_FillTypeList = new List + { + new IdNameStruct((int)FillTypes.GLASS, "Glass"), + new IdNameStruct((int)FillTypes.WOOD, "Wood") + }; + + private FillTypes m_SelFillType; + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/WebWindowComplex/Models/Frame.cs b/WebWindowComplex/Models/Frame.cs new file mode 100644 index 0000000..c83b55c --- /dev/null +++ b/WebWindowComplex/Models/Frame.cs @@ -0,0 +1,398 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WebWindowComplex.Json; +using static WebWindowComplex.Json.WindowConst; + +namespace WebWindowComplex.Models +{ + public class Frame : Area + { + #region Public Constructors + + public Frame(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow) + { + } + + #endregion Public Constructors + + #region Public Properties + + public bool BottomRail + { + get + { + return m_bBottomRail; + } + set + { + m_bBottomRail = value; + m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + } + } + + public int BottomRailQty + { + get + { + return m_nBottomRailQty; + } + set + { + if (m_nBottomRailQty >= 0) + { + m_nBottomRailQty = value; + if (m_nBottomRailQty > 0) + { + m_bBottomRail = true; + } + else + { + m_bBottomRail = false; + } + } + m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + } + } + + public List DimensionList + { + get => m_DimensionList; + set => m_DimensionList = value; + } + + public List JointList + { + get + { + return m_JointList; + } + set + { + m_JointList = value; + } + } + + public int SelShapeIndex + { + get + { + return IdNameStruct.IndFromId((int)m_Shape, m_ShapeList); + } + set + { + Shapes SelShape = (Shapes)IdNameStruct.IdFromInd(value, m_ShapeList); + if (m_Shape != SelShape) + { + // salvo vecchie dimensioni + List oldDimensionList = new List(DimensionList); + // verifico parametri Dimension + DimensionList.Clear(); + double widthVal = oldDimensionList.Where(x => x.sName.Equals("Width")).Select(x => x.dValue).First(); + // aggiungo Dimensioni + switch (SelShape) + { + case Shapes.RECTANGLE: + case Shapes.ARC_FULL: + { + DimensionList.Add(new FrameDimension(this, 1, "Width", widthVal, true)); + DimensionList.Add(new FrameDimension(this, 2, "Height", 1800, true)); + break; + } + + case Shapes.RIGHTCHAMFER: + { + DimensionList.Add(new FrameDimension(this, 1, "Width", widthVal, true)); + DimensionList.Add(new FrameDimension(this, 2, "Left Height", 1800, true)); + DimensionList.Add(new FrameDimension(this, 3, "Right Height", 1500, true)); + break; + } + + case Shapes.LEFTCHAMFER: + { + DimensionList.Add(new FrameDimension(this, 1, "Width", widthVal, true)); + DimensionList.Add(new FrameDimension(this, 2, "Left Height", 1500, true)); + DimensionList.Add(new FrameDimension(this, 3, "Right Height", 1800, true)); + break; + } + + case Shapes.DOUBLECHAMFER: + case Shapes.ARC: + { + DimensionList.Add(new FrameDimension(this, 1, "Width", widthVal, true)); + DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true)); + DimensionList.Add(new FrameDimension(this, 3, "Full Height", 1800, true)); + break; + } + + case Shapes.DOUBLEARC: + { + DimensionList.Add(new FrameDimension(this, 1, "Width", widthVal, true)); + DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true)); + DimensionList.Add(new FrameDimension(this, 3, "Full Height", 2400, true)); + break; + } + + case Shapes.TRIANGLE: + { + DimensionList.Add(new FrameDimension(this, 1, "Width", widthVal, true)); + DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true)); + DimensionList.Add(new FrameDimension(this, 3, "Height projection", 0, true)); + break; + } + + case Shapes.CUSTOM: + { + DimensionList.Clear(); + break; + } + } + // salvo tipo Joint + List oldJointType = new List(JointList); + // aggiungo Joint + m_JointList.Clear(); + switch (SelShape) + { + case Shapes.RECTANGLE: + case Shapes.RIGHTCHAMFER: + case Shapes.LEFTCHAMFER: + case Shapes.DOUBLECHAMFER: + case Shapes.ARC: + case Shapes.DOUBLEARC: + { + JointList.Add(new Joint(this, 1, oldJointType[0].SelJointType)); + JointList.Add(new Joint(this, 2, oldJointType[1].SelJointType)); + JointList.Add(new Joint(this, 3, oldJointType[2].SelJointType)); + JointList.Add(new Joint(this, 4, oldJointType[3].SelJointType)); + break; + } + + case Shapes.ARC_FULL: + { + JointList.Add(new Joint(this, 1, oldJointType[0].SelJointType)); + JointList.Add(new Joint(this, 2, oldJointType[1].SelJointType)); + JointList.Add(new Joint(this, 3, Joints.ANGLED)); + JointList.Add(new Joint(this, 4, Joints.ANGLED)); + break; + } + + case Shapes.TRIANGLE: + { + JointList.Add(new Joint(this, 1, oldJointType[0].SelJointType)); + JointList.Add(new Joint(this, 2, oldJointType[1].SelJointType)); + JointList.Add(new Joint(this, 3, Joints.ANGLED)); + break; + } + + case Shapes.CUSTOM: + { + JointList.Clear(); + break; + } + } + m_Shape = SelShape; + } + m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + } + } + + public Shapes Shape + { + get + { + return m_Shape; + } + } + + public List ShapeList + { + get + { + return m_ShapeList; + } + } + + #endregion Public Properties + + #region Public Methods + + public override Frame Copy(Area ParentArea) + { + return null; + } + + #endregion Public Methods + + #region Internal Methods + + internal static Area CreateFrame(Window Window) + { + Frame NewFrame = new Frame(null, Window); + NewFrame.SetAreaType(AreaTypes.FRAME); + NewFrame.SetSelShape(Shapes.RECTANGLE); + NewFrame.SetBottomRail(false); + NewFrame.SetBottomRailQty(0); + return NewFrame; + } + + internal override JsonArea Serialize() + { + 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) + JsonFrame.JointList.Add(Joint.Serialize()); + foreach (var Area in AreaList) + JsonFrame.AreaList.Add(Area.Serialize()); + return JsonFrame; + } + + internal void SetBottomRail(bool bBottomRail) + { + m_bBottomRail = bBottomRail; + } + + internal void SetBottomRailQty(int nBottomRailQty) + { + m_nBottomRailQty = nBottomRailQty; + } + + internal void SetSelShape(Shapes Value) + { + DimensionList.Clear(); + // aggiungo Dimension + switch (Value) + { + case Shapes.RECTANGLE: + case Shapes.ARC_FULL: + { + DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true)); + DimensionList.Add(new FrameDimension(this, 2, "Height", 1800, true)); + break; + } + + case Shapes.RIGHTCHAMFER: + { + DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true)); + DimensionList.Add(new FrameDimension(this, 2, "Left Height", 1800, true)); + DimensionList.Add(new FrameDimension(this, 3, "Right Height", 1500, true)); + break; + } + + case Shapes.LEFTCHAMFER: + { + DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true)); + DimensionList.Add(new FrameDimension(this, 2, "Left Height", 1500, true)); + DimensionList.Add(new FrameDimension(this, 3, "Right Height", 1800, true)); + break; + } + + case Shapes.DOUBLECHAMFER: + case Shapes.ARC: + { + DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true)); + DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true)); + DimensionList.Add(new FrameDimension(this, 3, "Full Height", 1800, true)); + break; + } + + case Shapes.DOUBLEARC: + { + DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true)); + DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true)); + DimensionList.Add(new FrameDimension(this, 3, "Full Height", 2400, true)); + break; + } + + case Shapes.TRIANGLE: + { + DimensionList.Add(new FrameDimension(this, 1, "Width", 2000, true)); + DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true)); + DimensionList.Add(new FrameDimension(this, 3, "Height projection", 0, true)); + break; + } + + case Shapes.CUSTOM: + { + DimensionList.Clear(); + break; + } + } + // aggiungo Joint + //int nJointQty = 4; + switch (Value) + { + case Shapes.RECTANGLE: + case Shapes.RIGHTCHAMFER: + case Shapes.LEFTCHAMFER: + case Shapes.DOUBLECHAMFER: + 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)); + 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, 3, Joints.ANGLED)); + JointList.Add(new Joint(this, 4, Joints.ANGLED)); + break; + } + + 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, 3, Joints.ANGLED)); + break; + } + + case Shapes.CUSTOM: + { + JointList.Clear(); + break; + } + } + m_Shape = Value; + } + + #endregion Internal Methods + + #region Private Fields + + private bool m_bBottomRail; + + private List m_DimensionList = new List(); + + private List m_JointList = new List(); + + private int m_nBottomRailQty = 0; + + private Shapes m_Shape; + + private List m_ShapeList = new List + { + new IdNameStruct((int)Shapes.RECTANGLE, "Rectangle"), + new IdNameStruct((int)Shapes.RIGHTCHAMFER, "Right Chamfer"), + new IdNameStruct((int)Shapes.LEFTCHAMFER, "Left Chamfer"), + new IdNameStruct((int)Shapes.DOUBLECHAMFER, "Double Chamfer"), + new IdNameStruct((int)Shapes.ARC, "Arc"), + new IdNameStruct((int)Shapes.ARC_FULL, "Arc Full"), + new IdNameStruct((int)Shapes.DOUBLEARC, "Double Arc"), + new IdNameStruct((int)Shapes.TRIANGLE, "Triangle") + }; + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/WebWindowComplex/Models/FrameDimension.cs b/WebWindowComplex/Models/FrameDimension.cs new file mode 100644 index 0000000..66fa6a8 --- /dev/null +++ b/WebWindowComplex/Models/FrameDimension.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WebWindowComplex.Json; + +namespace WebWindowComplex.Models +{ + public class FrameDimension + { + #region Public Constructors + + public FrameDimension(Frame ParentFrame, int nIndex, string sName, double dValue, bool bIsLen) + { + m_ParentFrame = ParentFrame; + m_nIndex = nIndex; + m_sName = sName; + m_dValue = dValue; + m_bIsLen = bIsLen; + } + + #endregion Public Constructors + + #region Public Properties + + public double dValue + { + get + { + return m_dValue; + } + set + { + m_dValue = value; + if (value > MaxDim) + { + m_dValue = MaxDim; + } + else if (value < MinDim) + { + m_dValue = MinDim; + } + m_ParentFrame.ParentWindow.OnUpdatePreview(m_ParentFrame.ParentWindow.sSerialized()); + } + } + + public int nIndex + { + get + { + return m_nIndex; + } + } + + public Frame ParentFrame + { + get + { + return m_ParentFrame; + } + } + + public string sName + { + get + { + return m_sName; + } + } + + #endregion Public Properties + + #region Internal Methods + + internal JsonFrameDimension Serialize() + { + JsonFrameDimension JsonFrameDimension = new JsonFrameDimension(m_nIndex, m_sName, m_dValue); + return JsonFrameDimension; + } + + #endregion Internal Methods + + #region Protected Fields + + protected Frame m_ParentFrame; + + #endregion Protected Fields + + #region Private Fields + + private bool m_bIsLen = false; + + private double m_dValue; + + private int m_nIndex; + + private string m_sName; + + // valore massimo della dimensione del frame + private int MaxDim = 4000; + // valore minimo della dimensione del frame + private int MinDim = 600; + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/WebWindowComplex/Models/IdNameStruct.cs b/WebWindowComplex/Models/IdNameStruct.cs new file mode 100644 index 0000000..06cf1af --- /dev/null +++ b/WebWindowComplex/Models/IdNameStruct.cs @@ -0,0 +1,126 @@ +namespace WebWindowComplex.Models +{ + public struct IdNameStruct + { + #region Public Constructors + + public IdNameStruct(int Id, string Name) + { + this = default(IdNameStruct); + m_Id = Id; + m_Name = Name; + } + + #endregion Public Constructors + + #region Public Properties + + public int Id + { + get + { + return m_Id; + } + set + { + m_Id = value; + } + } + + public string Name + { + get + { + return m_Name; + } + set + { + m_Name = value; + } + } + + #endregion Public Properties + + #region Public Methods + + public static int IdFromInd(int Ind, List List) + { + return List[Ind].Id; + } + + public static int IdFromInd(int Ind, List List) + { + if (List[Ind] is IdNameStruct) + { + return ((IdNameStruct)List[Ind]).Id; + } + + return 0; + } + + public static int IdFromName(string Name, List List) + { + checked + { + int num = List.Count - 1; + for (int i = 0; i <= num; i++) + { + if (string.Compare(((IdNameStruct)List[i]).Name, Name, false) == 0) + { + return ((IdNameStruct)List[i]).Id; + } + } + return 0; + } + } + + public static int IndFromId(int Id, List List) + { + checked + { + int num = List.Count - 1; + for (int i = 0; i <= num; i++) + { + if (List[i].Id == Id) + { + return i; + } + } + + return 0; + } + } + + public static int IndFromId(int Id, List List) + { + checked + { + int num = List.Count - 1; + for (int i = 0; i <= num; i++) + { + if (List[i] is IdNameStruct && ((IdNameStruct)List[i]).Id == Id) + { + return i; + } + } + + return 0; + } + } + + public override string ToString() + { + return Name; + } + + #endregion Public Methods + + #region Private Fields + + private int m_Id; + + private string m_Name; + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/WebWindowComplex/Models/Joint.cs b/WebWindowComplex/Models/Joint.cs new file mode 100644 index 0000000..cf67dd9 --- /dev/null +++ b/WebWindowComplex/Models/Joint.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WebWindowComplex.Json; +using static WebWindowComplex.Json.WindowConst; + +namespace WebWindowComplex.Models +{ + public class Joint + { + #region Public Constructors + + public Joint(Area ParentArea, int nIndex, Joints SelJointType) + { + m_ParentArea = ParentArea; + m_nIndex = nIndex; + m_SelJointType = SelJointType; + } + + #endregion Public Constructors + + #region Public Properties + + public List JointTypeList + { + get + { + return m_JointTypeList; + } + } + + public int nIndex + { + get + { + return m_nIndex; + } + } + + public Area ParentArea + { + get + { + return m_ParentArea; + } + } + + public Joints SelJointType + { + get + { + return m_SelJointType; + } + set + { + m_SelJointType = value; + } + } + + public int SelJointTypeIndex + { + get + { + return IdNameStruct.IndFromId((int)m_SelJointType, m_JointTypeList); + } + set + { + m_SelJointType = (Joints)IdNameStruct.IdFromInd(value, m_JointTypeList); + m_ParentArea.ParentWindow.OnUpdatePreview(m_ParentArea.ParentWindow.sSerialized()); + } + } + + #endregion Public Properties + + #region Public Methods + + public Joint Copy() + { + Joint newJoint = new Joint(ParentArea, nIndex, SelJointType); + return newJoint; + } + + #endregion Public Methods + + #region Internal Methods + + internal JsonJoint Serialize() + { + JsonJoint JsonJoint = new JsonJoint(m_nIndex, m_SelJointType); + return JsonJoint; + } + + internal void SetSelJointType(Joints value) + { + m_SelJointType = value; + //NotifyPropertyChanged(nameof(SelJointTypeIndex)); + } + + #endregion Internal Methods + + #region Protected Fields + + protected Area m_ParentArea; + + #endregion Protected Fields + + #region Private Fields + + private List m_JointTypeList = new List + { + new IdNameStruct((int)Joints.ANGLED, "Angled"), + new IdNameStruct((int)Joints.FULL_H, "Full H"), + new IdNameStruct((int)Joints.FULL_V, "Full V") + }; + + private int m_nIndex; + private Joints m_SelJointType; + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/WebWindowComplex/Models/OnPreviewEventArgs.cs b/WebWindowComplex/Models/OnPreviewEventArgs.cs new file mode 100644 index 0000000..d6585e0 --- /dev/null +++ b/WebWindowComplex/Models/OnPreviewEventArgs.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebWindowComplex.Models +{ + public class OnPreviewEventArgs : EventArgs + { + #region Public Fields + + public string sJwd; + + #endregion Public Fields + + #region Public Constructors + + public OnPreviewEventArgs(string sJwd) + { + this.sJwd = sJwd; + } + + #endregion Public Constructors + } +} \ No newline at end of file diff --git a/WebWindowComplex/Models/ParametriOpzioni.cs b/WebWindowComplex/Models/ParametriOpzioni.cs new file mode 100644 index 0000000..5ad6324 --- /dev/null +++ b/WebWindowComplex/Models/ParametriOpzioni.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static WebWindowComplex.Json.WindowConst; + +namespace WebWindowComplex.Models +{ + public partial class ParametriOpzioni + { + #region Public Constructors + + public ParametriOpzioni(ParametriOpzioniParametri HdwOptionParam) + { + m_sName = HdwOptionParam.NomeParametro; + m_sDescription = HdwOptionParam.DescrizioneParametro; + m_OptVisibility = Visibility.VISIBLE; // If(HdwOptionParam.Visible.ToLower = "true", Visibility.Visible, Visibility.Collapsed) + } + + #endregion Public Constructors + + #region Public Enums + + public enum HDWOPTIONTYPES : int + { + TEXT = 1, + LENGHT = 2, + COMBO = 3 + } + + #endregion Public Enums + + #region Public Properties + + public Visibility OptVisibility + { + get + { + return m_OptVisibility; + } + } + + public string sDescription + { + get + { + return m_sDescription; + } + } + + public string sName + { + get + { + return m_sName; + } + } + + public HDWOPTIONTYPES Type + { + get + { + return m_Type; + } + } + + #endregion Public Properties + + #region Protected Fields + + protected HDWOPTIONTYPES m_Type; + + #endregion Protected Fields + + #region Private Fields + + private Visibility m_OptVisibility; + private string m_sDescription; + private string m_sName; + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/WebWindowComplex/Models/Sash.cs b/WebWindowComplex/Models/Sash.cs new file mode 100644 index 0000000..67c8924 --- /dev/null +++ b/WebWindowComplex/Models/Sash.cs @@ -0,0 +1,803 @@ +using Egw.Window.Data; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WebWindowComplex.Json; +using static WebWindowComplex.Json.WindowConst; + +namespace WebWindowComplex.Models +{ + public class Sash : Area + { + #region Public Fields + + // Lista hardware completa passata dal chiamante del componente + public static List m_HardwareCompleteList = new List(); + + // Lista hardware completa passata dal chiamante del componente + public static List s_FamilyHardwareList = new List(); + + #endregion Public Fields + + #region Public Constructors + + public Sash(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow) + { + } + + #endregion Public Constructors + + #region Public Properties + + public bool bIsMeasureGlass + { + get + { + return m_bIsMeasureGlass; + } + set + { + m_bIsMeasureGlass = value; + } + } + + public bool bIsPercentage + { + get + { + return m_bIsPercentage; + } + } + + public bool bIsSashVertical + { + get + { + return m_bIsSashVertical; + } + set + { + m_bIsSashVertical = value; + } + } + + public List HardwareList + { + get + { + return m_HardwareList; + } + } + + public List HwdOptionList + { + get + { + return m_HwdOptionList; + } + } + + public List JointList + { + get + { + return m_JointList; + } + set + { + m_JointList = value; + } + } + + public int nSashQty + { + get + { + return m_SashList.Count > 0 ? m_SashList.Count : 1; + } + set + { + if (value >= 0 && value <= 4) + { + if (value > m_SashList.Count) + { + // recupero larghezza ultimo + double dLastDimension = 100; + double dNewDimension = 100; + if (m_SashList.Count > 0) + { + dLastDimension = m_SashList[m_SashList.Count - 1].dDimension; + dNewDimension = dLastDimension / (value + 1 - nSashQty); + m_SashList[m_SashList.Count - 1].SetDimension(dNewDimension); + } + else + dNewDimension = dLastDimension / (value + 1 - nSashQty); + // aggiungo area Sash di default + for (var SplitIndex = m_SashList.Count; SplitIndex <= value - 1; SplitIndex++) + { + SashList.Add(new SashDimension(dNewDimension, true, this, SplitIndex + 1)); + } + } + else if (value < m_SashList.Count) + { + if (value > 0) + { + double dLastDimension = 0; + for (var SplitIndex = m_SashList.Count - 1; SplitIndex >= value; SplitIndex += -1) + { + dLastDimension += m_SashList[SplitIndex].dDimension; + SashList.RemoveAt(SplitIndex); + } + dLastDimension += m_SashList[SashList.Count - 1].dDimension; + SashList[SashList.Count - 1].SetDimension(dLastDimension); + if (value == 1) + SashList.First().SetHasHandle(true); + } + else + { + SashList.RemoveAt(0); + } + } + if (m_SashList.Count == 0) + { + Area child = AreaList.First(); + // Se nella singola anta ho uno split + if (!(child is Fill)) + { + child = child.AreaList.First().AreaList.First(); + } + child.SetParentArea(this.ParentArea); + this.ParentArea.AreaList.Remove(this); + this.ParentArea.AreaList.Add(child); + } + // Se ho singola anta + else if (m_SashList.Count == 1) + { + // Metto come padre dell'area nello splitted l'anta stessa + List ContentArea = new List(); + ContentArea.Add(AreaList.First().AreaList.First()); + ContentArea.First().SetParentArea(this); + AreaList.Clear(); + AreaList.Add(ContentArea.First()); + } + else + { + // Se aggiungo ante + if (SashList.Count > AreaList.Count) + { + List ContentArea = new List(); + // Salvo in ContentArea il sottoalbero delle singole aree che mantengo + if (AreaList.Count >= 1 & SashList.Count > AreaList.Count) + { + foreach (Area area in AreaList) + { + if (area is Splitted) + ContentArea.Add(area.AreaList.First()); + else + ContentArea.Add(area); + } + AreaList.Clear(); + } + for (int SplitIndex = AreaList.Count; SplitIndex <= SashList.Count - 1; SplitIndex++) + { + AreaList.Add(Splitted.CreateSplitted(this)); + } + // Riaggiungo i sottoalberi che avevo salvato + for (int i = 0; i < AreaList.Count - 1; i++) + { + if (AreaList.Count == 2) + { + ContentArea[i].SetParentArea(AreaList[i]); + } + AreaList[i].AreaList.Add(ContentArea[i]); + } + // Aggiungo all'ultimo Splitted l'area di vetro + 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); + } + // Se tolgo anta + else + { + for (int SplitIndex = SashList.Count; SplitIndex <= AreaList.Count() - 1; SplitIndex++) + { + AreaList.Remove(AreaList[AreaList.Count - 1]); + break; + } + } + } + } + RefreshHardwareList(); + RefreshHardwareOptionList(); + SetFirstHardware(); + m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + } + } + + public OrientationSash OrientationSashType + { + get + { + return (OrientationSash)m_SelOrientationSashType; + } + } + + public List OrientationSashTypeList + { + get + { + return m_OrientationSashTypeList; + } + } + + public bool SashBottomRail + { + get + { + return m_bSashBottomRail; + } + set + { + m_bSashBottomRail = value; + } + } + + public int SashBottomRailQty + { + get + { + return m_nSashBottomRailQty; + } + set + { + // Controllo che il valore inserito sia positivo + if (value >= 0) + { + m_nSashBottomRailQty = value; + if (m_nSashBottomRailQty > 0) + { + m_bSashBottomRail = true; + } + else + { + m_bSashBottomRail = false; + } + m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + } + } + } + + public List SashList + { + get + { + return m_SashList; + } + set + { + m_SashList = value; + } + } + + public SashTypes SashType + { + get + { + return m_SashType; + } + set + { + m_SashType = value; + } + } + + public string SelFamilyHardware + { + get + { + return m_SelFamilyHardware; + } + set + { + m_SelFamilyHardware = value; + RefreshHardwareList(); + RefreshHardwareOptionList(); + SetFirstHardware(); + m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + } + } + + public Hardware SelHardware + { + get + { + return m_SelHardware; + } + set + { + m_SelHardware = value; + // if (m_SelHardware != null && m_SelHardware.sId != "000000") + // { + // string sHwdOptPath = ""; + // var gf = EgtLuaCreateGlobTable("WDG"); + // var tft = EgtLuaSetGlobIntVar("WDG.AREAID", m_nAreaId); + // var tfy = EgtLuaSetGlobStringVar("WDG.HDWFAVOURITE", value.sId); + // SashDimension HandleSash = m_SashList.FirstOrDefault(x => x.bHasHandle); + // string sHandle = "Dx"; + // switch (GetOpeningSide(HandleSash.OpeningType)) + // { + // case object _ when OpeningSides.LEFT: + // { + // sHandle = "Sx"; + // break; + // } + + // case object _ when OpeningSides.RIGHT: + // { + // sHandle = "Dx"; + // break; + // } + // } + // var tfd = EgtLuaSetGlobStringVar("WDG.HDWHANDLE", sHandle); + // var tlt = EgtLuaCallFunction("WinCreate_GetHardwareOptionPath"); + // var tltf = EgtLuaGetGlobStringVar("WDG.HWDOPTPATH", sHwdOptPath); + // if (!string.IsNullOrWhiteSpace(sHwdOptPath)) + // { + // XmlSerializer serializer = new XmlSerializer(typeof(ParametriOpzioni)); + // ParametriOpzioni HwdOptions = null/* TODO Change to default(_) if this is not a reference type */; + // string sHdwOptPath = Path.ChangeExtension(sHwdOptPath, ".opt"); + // bool bHdwOptFound = false; + // for (var WaitIndex = 0; WaitIndex <= 100; WaitIndex++) + // { + // if (File.Exists(sHdwOptPath)) + // { + // bHdwOptFound = true; + // break; + // } + // System.Threading.Thread.Sleep(100); + // } + // if (bHdwOptFound) + // { + // string sHwdOptText = ""; + // try + // { + // sHwdOptText = File.ReadAllText(sHdwOptPath); + // } + // catch (Exception ex) + // { + // EgtOutLog("Hardware file opt not found or read!"); + // } + // if (!string.IsNullOrWhiteSpace(sHwdOptText)) + // { + // using (TextReader reader = new StringReader(sHwdOptText)) + // { + // HwdOptions = serializer.Deserialize(reader); + // } + // if (!IsNothing(HwdOptions)) + // { + // m_HwdOptionList.Clear(); + // foreach (var HdwOption in HwdOptions.Items) + // m_HwdOptionList.Add(new AGBOption(HdwOption)); + // NotifyPropertyChanged(nameof(HwdOptionList)); + // } + // } + // } + // var ud = EgtLuaResetGlobVar("WDG"); + // } + // } + } + } + + public string SelHardwareFromId + { + get + { + return m_SelHardware.Id; + } + set + { + m_SelHardware = m_HardwareList.FirstOrDefault(x => !string.IsNullOrEmpty(value) && x.Id.Equals(value)) ?? new Hardware("", "", "", Enums.OpeningTypes.Null, "", 0, 0); + ParentWindow.OnUpdatePreview(ParentWindow.sSerialized()); + } + } + + public OrientationSash SelOrientationSashType + { + get + { + return m_SelOrientationSashType; + } + set + { + m_SelOrientationSashType = value; + } + } + + public int SelOrientationSashTypeIndex + { + get + { + return IdNameStruct.IndFromId((int)m_SelOrientationSashType, m_OrientationSashTypeList); + } + set + { + m_SelOrientationSashType = (OrientationSash)IdNameStruct.IdFromInd(value, m_OrientationSashTypeList); + if (value == 0) + { + m_bIsSashVertical = true; + } + else + { + m_bIsSashVertical = false; + } + m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + } + } + + #endregion Public Properties + + #region Public Methods + + 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); + newSash.SetIsSashVertical(bIsSashVertical); + newSash.SetOrientationSashType(OrientationSashType); + newSash.SetSashBottomRailQty(SashBottomRailQty); + newSash.SetSelFamilyHardwareFromIndex(SelHardware.Id); + newSash.RefreshHardwareList(); + newSash.RefreshHardwareOptionList(); + newSash.SetSelHardware(SelHardware); + for (int i = 0; i < SashList.Count; i++) + { + //Cancello SashDimension di default e aggiungo la copia + newSash.SashList.RemoveAt(i); + SashDimension newSashDim = SashList[i].Copy(); + newSash.SashList.Insert(i, newSashDim); + } + foreach (var item in JointList) + { + Joint newJoint = item.Copy(); + newSash.JointList.Add(newJoint); + } + foreach (var item in AreaList) + { + Area newArea = item.Copy(newSash); + newSash.AreaList.Add(newArea); + } + return newSash; + } + + public void RefreshHardwareList() + { + if (m_HardwareCompleteList != null && m_HardwareCompleteList.Count > 0) + { + m_HardwareList.Clear(); + string sSashShape = FindSashShape(); + Enums.OpeningTypes sOpeningType = ConvertOpeningType(); + var iComp = StringComparison.InvariantCultureIgnoreCase; + var rawList = m_HardwareCompleteList + .Where(x => x.Id == "000000" || + (!string.IsNullOrEmpty(m_SelFamilyHardware) && x.FamilyName.Equals(m_SelFamilyHardware, iComp) && x.SashQty == nSashQty && x.Shape.Equals(sSashShape, iComp) && x.OpeningType == sOpeningType) + ) + .ToList(); + if (rawList != null && rawList.Count > 0) + { + m_HardwareList = new List(rawList); + } + else + { + m_HardwareList = new List(); + } + } + } + + 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()); + } + + #endregion Public Methods + + #region Internal Methods + + 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); + newSash.SetIsSashVertical(true); + for (var JointIndex = 0; JointIndex <= 3; JointIndex++) + newSash.JointList.Add(new Joint(newSash, JointIndex + 1, Joints.FULL_H)); + newSash.SetSashBottomRail(false); + newSash.SetSashBottomRailQty(0); + newSash.SelFamilyHardware = Sash.s_FamilyHardwareList.First(); + newSash.RefreshHardwareList(); + newSash.RefreshHardwareOptionList(); + newSash.SetFirstHardware(); + return newSash; + } + + internal OpeningSides GetOpeningSide(Openings OpeningType) + { + switch (OpeningType) + { + case Openings.TURNONLY_LEFT: + case Openings.TILTTURN_LEFT: + case Openings.TILTONLY_TOP: + case Openings.COMPLANARSLIDE_LEFT: + case Openings.LIFTSLIDE_LEFT: + { + return OpeningSides.LEFT; + } + + case Openings.TURNONLY_RIGHT: + case Openings.TILTTURN_RIGHT: + case Openings.TILTONLY_BOTTOM: + case Openings.COMPLANARSLIDE_RIGHT: + case Openings.LIFTSLIDE_RIGHT: + { + return OpeningSides.RIGHT; + } + + default: + { + return OpeningSides.NULL; + } + } + } + + internal Enums.OpeningTypes GetOpeningType(Openings OpeningType) + { + switch (OpeningType) + { + case Openings.TURNONLY_LEFT: + case Openings.TURNONLY_RIGHT: + { + return Enums.OpeningTypes.TurnOnly; + } + + case Openings.TILTTURN_LEFT: + case Openings.TILTTURN_RIGHT: + { + return Enums.OpeningTypes.TiltTurn; + } + + case Openings.TILTONLY_TOP: + case Openings.TILTONLY_BOTTOM: + { + return Enums.OpeningTypes.TiltOnly; + } + + case Openings.PIVOT: + { + return Enums.OpeningTypes.Pivot; + } + + case Openings.FIXED: + { + return Enums.OpeningTypes.Fixed; + } + + case Openings.COMPLANARSLIDE_LEFT: + case Openings.COMPLANARSLIDE_RIGHT: + { + return Enums.OpeningTypes.ComplanarSlide; + } + + case Openings.LIFTSLIDE_LEFT: + case Openings.LIFTSLIDE_RIGHT: + { + return Enums.OpeningTypes.LiftSlide; + } + + default: + { + return Enums.OpeningTypes.Null; + } + } + } + + internal void RefreshHardwareOptionList() + { + m_HwdOptionList.Clear(); + } + + internal override JsonArea Serialize() + { + 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) + JsonSash.JointList.Add(Joint.Serialize()); + foreach (var Area in AreaList) + JsonSash.AreaList.Add(Area.Serialize()); + return JsonSash; + } + + internal void SetFirstHardware() + { + if (m_HardwareList.Count > 0) + { + m_SelHardware = m_HardwareList.First(); + } + } + + internal void SetIsMeasureGlass(bool IsMeasureGlass) + { + m_bIsMeasureGlass = IsMeasureGlass; + } + + internal void SetIsSashVertical(bool IsSashVertical) + { + m_bIsSashVertical = IsSashVertical; + if (IsSashVertical) + { + m_SelOrientationSashType = OrientationSash.VERTICAL; + } + else + { + m_SelOrientationSashType = OrientationSash.HORIZONTAL; + } + } + + internal void SetOrientationSashType(OrientationSash value) + { + m_SelOrientationSashType = value; + } + + internal void SetSashBottomRail(bool bBottomRail) + { + m_bSashBottomRail = bBottomRail; + } + + internal void SetSashBottomRailQty(int nBottomRailQty) + { + m_nSashBottomRailQty = nBottomRailQty; + } + + internal void SetSashQty(int Qty) + { + if (Qty >= 0 && Qty <= 4) + { + if (Qty > m_SashList.Count) + { + // recupero larghezza ultimo + double dLastDimension = 100; + double dNewDimension = 100; + if (m_SashList.Count > 0) + { + dLastDimension = m_SashList[m_SashList.Count - 1].dDimension; + dNewDimension = dLastDimension / (Qty + 1 - nSashQty); + m_SashList[m_SashList.Count - 1].dDimension = dNewDimension; + } + else + 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, SplitIndex + 1)); + } + else if (Qty < m_SashList.Count) + { + for (var SplitIndex = m_SashList.Count - 1; SplitIndex >= Qty; SplitIndex += -1) + SashList.RemoveAt(SplitIndex); + } + } + } + + internal void SetSashType(SashTypes SashType) + { + m_SashType = SashType; + } + + internal string SetSelFamilyHardwareFromIndex(string codHardware) + { + if (string.IsNullOrEmpty(m_SelFamilyHardware)) + { + var item = m_HardwareCompleteList + .Where(x => x.Id == codHardware) + .Select(x => x.FamilyName) + .ToList(); + SelFamilyHardware = item.First(); + } + return SelFamilyHardware; + } + + internal void SetSelHardware(Hardware value) + { + SelHardware = value; + } + + internal void SetSelHardwareFromId(string sId) + { + if (m_HardwareList.Count == 0) + SelHardware = m_HardwareCompleteList.FirstOrDefault(x => x.Id.Equals(sId)) ?? new Hardware("", "", "", Enums.OpeningTypes.Null, "", 0, 0); + else + SelHardware = m_HardwareList.FirstOrDefault(x => x.Id.Equals(sId)) ?? new Hardware("", "", "", Enums.OpeningTypes.Null, "", 0, 0); + if (SelHardware.Id == "") + SelHardware = m_HardwareList.First(); + //SelFamilyHardware = m_SelHardware.FamilyName; + } + + #endregion Internal Methods + + #region Private Fields + + private bool m_bIsMeasureGlass; + + private bool m_bIsPercentage = true; + + private bool m_bIsSashVertical; + + private bool m_bSashBottomRail; + + private List m_HardwareList = new List(); + + private List m_HwdOptionList = new List(); + + private List m_JointList = new List(); + + private int m_nSashBottomRailQty; + + private List m_OrientationSashTypeList = new List + { + new IdNameStruct((int)OrientationSash.VERTICAL, "Vertical"), + new IdNameStruct((int)OrientationSash.HORIZONTAL, "Horizontal"), + }; + + private List m_SashList = new List(); + private SashTypes m_SashType; + private string m_SelFamilyHardware; + private Hardware m_SelHardware; + private OrientationSash m_SelOrientationSashType; + + #endregion Private Fields + + #region Private Methods + + private Enums.OpeningTypes ConvertOpeningType() + { + var answ = Enums.OpeningTypes.Null; + if (m_SashList.Count > 1) + { + for (int i = 0; i < m_SashList.Count; i++) + { + if (m_SashList[i].bHasHandle) + { + answ = GetOpeningType(m_SashList[i].OpeningType); + } + } + } + else + { + answ = GetOpeningType(m_SashList.First().OpeningType); + } + return answ; + } + + private string FindSashShape() + { + return "Rectangular"; + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/WebWindowComplex/Models/SashDimension.cs b/WebWindowComplex/Models/SashDimension.cs new file mode 100644 index 0000000..cde5c8c --- /dev/null +++ b/WebWindowComplex/Models/SashDimension.cs @@ -0,0 +1,326 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WebWindowComplex.Json; +using static WebWindowComplex.Json.WindowConst; + +namespace WebWindowComplex.Models +{ + public class SashDimension + { + #region Public Constructors + + 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; + // assegno tipo di anta + if (Parent.SashList.Count == 0) + SetOpeningType(Openings.TILTTURN_LEFT); + else if (Parent.SashList.Count == 1) + { + switch (Parent.SashList[0].OpeningType) + { + case Openings.TURNONLY_LEFT: + { + SetOpeningType(Openings.TURNONLY_RIGHT); + break; + } + + case Openings.TURNONLY_RIGHT: + { + SetOpeningType(Openings.TURNONLY_LEFT); + break; + } + + case Openings.TILTTURN_LEFT: + { + SetOpeningType(Openings.TURNONLY_RIGHT); + break; + } + + case Openings.TILTTURN_RIGHT: + { + SetOpeningType(Openings.TURNONLY_LEFT); + break; + } + + case Openings.TILTONLY_TOP: + { + SetOpeningType(Openings.TILTONLY_BOTTOM); + break; + } + + case Openings.TILTONLY_BOTTOM: + { + SetOpeningType(Openings.TILTONLY_TOP); + break; + } + + case Openings.COMPLANARSLIDE_LEFT: + { + SetOpeningType(Openings.COMPLANARSLIDE_RIGHT); + break; + } + + case Openings.COMPLANARSLIDE_RIGHT: + { + SetOpeningType(Openings.COMPLANARSLIDE_LEFT); + break; + } + + case Openings.LIFTSLIDE_LEFT: + { + SetOpeningType(Openings.LIFTSLIDE_RIGHT); + break; + } + + case Openings.LIFTSLIDE_RIGHT: + { + SetOpeningType(Openings.LIFTSLIDE_LEFT); + break; + } + } + } + else + SetOpeningType(Parent.SashList[Parent.SashList.Count - 1].OpeningType); + } + + #endregion Public Constructors + + #region Public Properties + + public bool bHasHandle + { + get + { + return m_bHasHandle; + } + set + { + m_bHasHandle = value; + m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); + } + } + + public bool bIsRelative + { + get + { + return m_bIsRelative; + } + } + + public double dDimension + { + get + { + return m_dDimension; + } + set + { + // Controllo che il valore inserito sia compreso tra 0 e 100 + if (value > 0 && value < 100) + { + // se sono in percentuale + if (m_bIsRelative) + { + // verifico se ci sono assoluti + List RelativeDimList = m_Parent.SashList.Where(x => x.bIsRelative).ToList(); + if (RelativeDimList.Count > 0) + { + if (m_Parent.bIsPercentage) + { + int nIndex = RelativeDimList.IndexOf(this); + // se diminuisce dimensione + if (value < m_dDimension) + { + if (nIndex < RelativeDimList.Count - 1) + RelativeDimList[nIndex + 1].SetDimension(RelativeDimList[nIndex + 1].dDimension + (m_dDimension - value)); + else if (RelativeDimList.Count > 1) + RelativeDimList[nIndex - 1].SetDimension(RelativeDimList[nIndex - 1].dDimension + (m_dDimension - value)); + else + { + m_dDimension = 100; + return; + } + } + // se aumenta dimensione + else + { + double dRes = value; + // se non ultima anta + if (nIndex < RelativeDimList.Count - 1) + { + for (var nInd = 0; nInd <= nIndex - 1; nInd++) + dRes += RelativeDimList[nInd].dDimension; + dRes = (100 - dRes) / (RelativeDimList.Count - nIndex - 1); + for (var Ind = nIndex + 1; Ind <= RelativeDimList.Count - 1; Ind++) + RelativeDimList[Ind].SetDimension(dRes); + } + // se ultima anta + else if (RelativeDimList.Count > 1) + { + if (RelativeDimList.Count > 2) + { + for (var Ind = 0; Ind <= nIndex - 2; Ind++) + dRes += RelativeDimList[Ind].dDimension; + } + + //for (var Ind = nIndex + 1; Ind <= RelativeDimList.Count - 1; Ind++) + // dRes += RelativeDimList[Ind].dDimension; + dRes = (100 - dRes); + RelativeDimList[nIndex - 1].SetDimension(dRes); + //for (var nInd = 0; nInd <= nIndex - 1; nInd++) + // RelativeDimList[nInd].SetDimension(dRes); + } + else + { + m_dDimension = 100; + return; + } + } + } + } + } + m_dDimension = value; + m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); + } + } + } + + public int nSashId + { + get + { + return m_nSashId; + } + } + + public Openings OpeningType + { + get + { + return (Openings)m_SelOpeningType; + } + } + + public List OpeningTypeList + { + get + { + return m_OpeningTypeList; + } + } + + public Openings SelOpeningType + { + get + { + return m_SelOpeningType; + } + set + { + m_SelOpeningType = value; + m_Parent.RefreshHardwareList(); + m_Parent.RefreshHardwareOptionList(); + m_Parent.SetFirstHardware(); + } + } + + public int SelOpeningTypeIndex + { + get + { + return IdNameStruct.IndFromId((int)m_SelOpeningType, m_OpeningTypeList); + } + set + { + m_SelOpeningType = (Openings)IdNameStruct.IdFromInd(value, m_OpeningTypeList); + m_Parent.RefreshHardwareList(); + m_Parent.RefreshHardwareOptionList(); + m_Parent.SetFirstHardware(); + m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); + } + } + + #endregion Public Properties + + #region Public Methods + + public SashDimension Copy() + { + SashDimension newSashDim = new SashDimension(dDimension, bIsRelative, m_Parent, m_nSashId); + newSashDim.SetOpeningType(SelOpeningType); + newSashDim.SetHasHandle(bHasHandle); + return newSashDim; + } + + #endregion Public Methods + + #region Internal Methods + + internal JsonSashDimension Serialize() + { + JsonSashDimension JsonSashDimension = new JsonSashDimension(OpeningType, m_bHasHandle, m_dDimension, m_nSashId); + return JsonSashDimension; + } + + internal void SetDimension(double dValue) + { + m_dDimension = dValue; + } + + internal void SetHasHandle(bool value) + { + m_bHasHandle = value; + } + + internal void SetOpeningType(Openings value) + { + m_SelOpeningType = value; + } + + #endregion Internal Methods + + #region Private Fields + + private bool m_bHasHandle; + + private bool m_bIsRelative = false; + + private double m_dDimension; + + private int m_nSashId; + + private List m_OpeningTypeList = new List + { + new IdNameStruct((int)Openings.TURNONLY_LEFT, ">"), + new IdNameStruct((int)Openings.TURNONLY_RIGHT, "<"), + new IdNameStruct((int)Openings.TILTTURN_LEFT, ">*"), + new IdNameStruct((int)Openings.TILTTURN_RIGHT, "<*"), + new IdNameStruct((int)Openings.TILTONLY_TOP, "˄"), + new IdNameStruct((int)Openings.TILTONLY_BOTTOM, "˅"), + new IdNameStruct((int)Openings.PIVOT, "◊"), + new IdNameStruct((int)Openings.FIXED, "X"), + new IdNameStruct((int)Openings.COMPLANARSLIDE_LEFT, "-→"), + new IdNameStruct((int)Openings.COMPLANARSLIDE_RIGHT, "←-"), + new IdNameStruct((int)Openings.LIFTSLIDE_LEFT, "┌→"), + new IdNameStruct((int)Openings.LIFTSLIDE_RIGHT, "←┐") + }; + + // reference + private Sash m_Parent; + + private Openings m_SelOpeningType; + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/WebWindowComplex/Models/Split.cs b/WebWindowComplex/Models/Split.cs new file mode 100644 index 0000000..8481927 --- /dev/null +++ b/WebWindowComplex/Models/Split.cs @@ -0,0 +1,475 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WebWindowComplex.Json; +using static WebWindowComplex.Json.WindowConst; + +namespace WebWindowComplex.Models +{ + public class Split : Area + { + #region Public Constructors + + public Split(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow) + { + } + + #endregion Public Constructors + + #region Public Properties + + public bool bIsPercentage + { + get + { + return m_bIsPercentage; + } + } + + public bool bSplitStartVert + { + get + { + return m_bSplitStartVert; + } + set + { + m_bSplitStartVert = value; + m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + } + } + + 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()); + } + } + + public int nSplitQtyVert + { + get + { + return m_SplitVertList.Count > 0 ? m_SplitVertList.Count - 1 : 0; + } + set + { + if (value == 0) + { + for (var SplitIndex = m_SplitVertList.Count - 1; SplitIndex >= value; SplitIndex += -1) + m_SplitVertList.RemoveAt(SplitIndex); + if (nSplitQtyHoriz == 0) + { + ParentArea.AreaList.Remove(this); + Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS); + newFill.SetAreaType(AreaTypes.FILL); + ParentArea.AreaList.Add(newFill); + } + else + SetSplitShape(SplitShapes.HORIZONTAL); + } + else + { + // Ricalcolo dimensioni aggiungendo split + if (value > m_SplitVertList.Count - 1) + { + // 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)); + } + else if (value == 0) + { + 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); + } + } + m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + } + } + + public int SelSplitShapeIndex + { + get + { + return IdNameStruct.IndFromId((int)m_SelSplitShape, m_SplitShapeList); + } + 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()); + } + } + + public List SplitHorizList + { + get + { + return m_SplitHorizList; + } + set + { + m_SplitHorizList = value; + } + } + + public List SplitPositionList + { + get + { + return m_SplitPositionList; + } + set + { + m_SplitPositionList = value; + } + } + + public List SplitShapeList + { + get + { + return m_SplitShapeList; + } + } + + public List SplitVertList + { + get + { + return m_SplitVertList; + } + set + { + m_SplitVertList = value; + } + } + + #endregion Public Properties + + #region Public Methods + + public override Split Copy(Area newParentArea) + { + Split newSplit = new Split(newParentArea, ParentWindow); + AddCounterGroup(); + newSplit.SetIdGroup(nCounterGroup); + newSplit.SetSplitStartVert(bSplitStartVert); + newSplit.SetSplitQtyVert(nSplitQtyVert); + for (int i = 0; i < SplitVertList.Count; i++) + newSplit.SplitVertList.ElementAt(i).SetDimension(SplitVertList.ElementAt(i).dDimension); + newSplit.SetSplitQtyHoriz(nSplitQtyHoriz); + for (int i = 0; i < SplitHorizList.Count; i++) + newSplit.SplitHorizList.ElementAt(i).SetDimension(SplitHorizList.ElementAt(i).dDimension); + newSplit.SetSplitShape(SelSplitShape, true); + newSplit.SetAreaType(AreaType); + foreach (var item in AreaList) + { + Area a = item.Copy(newSplit); + newSplit.AreaList.Add(a); + } + 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()); + } + + #endregion Public Methods + + #region Internal Properties + + internal SplitShapes SelSplitShape + { + get + { + return m_SelSplitShape; + } + } + + #endregion Internal Properties + + #region Internal Methods + + 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; + } + + internal override JsonArea 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; + } + + 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); + } + } + + internal void SetSplitQtyVert(int QtyVert, bool NotifyProperty = false) + { + if (QtyVert > m_SplitVertList.Count) + { + // recupero larghezza ultimo + double dLastDimension = 100; + double dNewDimension = 100; + if (m_SplitVertList.Count > 0) + { + dLastDimension = m_SplitVertList[m_SplitVertList.Count - 1].dDimension; + dNewDimension = dLastDimension / (QtyVert + 1 - nSplitQtyVert); + m_SplitVertList[m_SplitVertList.Count - 1].dDimension = dNewDimension; + } + else + dNewDimension = dLastDimension / (QtyVert + 1 - nSplitQtyVert); + // aggiungo area Split di default + for (var SplitIndex = m_SplitVertList.Count; SplitIndex <= QtyVert; SplitIndex++) + m_SplitVertList.Add(new SplitDimension(dNewDimension, true, this, true)); + } + else if (QtyVert < m_SplitVertList.Count) + { + for (var SplitIndex = m_SplitVertList.Count - 1; SplitIndex >= QtyVert; SplitIndex += -1) + m_SplitVertList.RemoveAt(SplitIndex); + } + } + + internal void SetSplitShape(SplitShapes Value, bool NotifyProperty = false) + { + m_SelSplitShape = Value; + } + + internal void SetSplitStartVert(bool SplitStartVert) + { + bSplitStartVert = SplitStartVert; + } + + #endregion Internal Methods + + #region Private Fields + + private bool m_bIsPercentage = true; + private bool m_bSplitStartVert = true; + private SplitShapes m_SelSplitShape; + + private List m_SplitHorizList = new List(); + + private List m_SplitPositionList = new List(); + + private List m_SplitShapeList = new List + { + new IdNameStruct((int)SplitShapes.VERTICAL, "Vertical"), + new IdNameStruct((int)SplitShapes.HORIZONTAL, "Horizontal"), + new IdNameStruct((int)SplitShapes.GRID, "Grid"), + new IdNameStruct((int)SplitShapes.CUSTOM, "Custom") + }; + + private List m_SplitVertList = new List(); + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/WebWindowComplex/Models/SplitDimension.cs b/WebWindowComplex/Models/SplitDimension.cs new file mode 100644 index 0000000..8849369 --- /dev/null +++ b/WebWindowComplex/Models/SplitDimension.cs @@ -0,0 +1,189 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WebWindowComplex.Json; + +namespace WebWindowComplex.Models +{ + public class SplitDimension + { + #region Public Constructors + + public SplitDimension(double dDimension, bool bIsRelative, Split Parent, bool IsVertList) + { + m_dDimension = dDimension; + m_bIsRelative = bIsRelative; + m_Parent = Parent; + m_bIsVertListDim = IsVertList; + } + + #endregion Public Constructors + + #region Public Properties + + public bool bIsRelative + { + get + { + return m_bIsRelative; + } + } + + public bool bIsVertListDim + { + get + { + return m_bIsVertListDim; + } + } + + public double dDimension + { + get + { + return m_dDimension; + } + set + { + // Controllo che il valore inserito sia compreso tra 0 e 100 + if (value > 0 && value < 100) + { + // 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(); + if (RelativeDimList.Count > 0) + { + if (m_Parent.bIsPercentage) + { + int nIndex = RelativeDimList.IndexOf(this); + if (value < m_dDimension) + { + if (nIndex < RelativeDimList.Count - 1) + RelativeDimList[nIndex + 1].SetDimension(RelativeDimList[nIndex + 1].dDimension + (m_dDimension - value)); + else if (RelativeDimList.Count > 1) + RelativeDimList[nIndex - 1].SetDimension(RelativeDimList[nIndex - 1].dDimension + (m_dDimension - value)); + else + { + m_dDimension = 100; + return; + } + } + else + { + double dRes = value; + if (nIndex < RelativeDimList.Count - 1) + { + for (var nInd = 0; nInd <= nIndex - 1; nInd++) + dRes += RelativeDimList[nInd].dDimension; + dRes = (100 - dRes) / (RelativeDimList.Count - nIndex - 1); + if (dRes != 0) + { + for (var Ind = nIndex + 1; Ind <= RelativeDimList.Count - 1; Ind++) + RelativeDimList[Ind].SetDimension(dRes); + } + else + return; + } + else if (RelativeDimList.Count > 1) + { + if (RelativeDimList.Count > 2) + { + for (var Ind = 0; Ind <= nIndex - 2; Ind++) + dRes += RelativeDimList[Ind].dDimension; + } + dRes = (100 - dRes); + if (dRes != 0) + RelativeDimList[nIndex - 1].SetDimension(dRes); + else + return; + } + else + { + m_dDimension = 100; + return; + } + } + } + else + { + } + } + } + m_dDimension = value; + m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); + } + } + } + + public Split Parent + { + get + { + return m_Parent; + } + set + { + m_Parent = value; + } + } + + #endregion Public Properties + + #region Public Methods + + public SplitDimension Copy() + { + SplitDimension newSplitDim = new SplitDimension(dDimension, bIsRelative, m_Parent, bIsVertListDim); + return newSplitDim; + } + + #endregion Public Methods + + #region Internal Methods + + internal JsonSplitDimension Serialize() + { + JsonSplitDimension JsonSplitDimension = new JsonSplitDimension(m_bIsRelative, m_dDimension); + return JsonSplitDimension; + } + + internal void SetDimension(double dValue) + { + m_dDimension = dValue; + } + + internal void SetIsRelative(bool value) + { + m_bIsRelative = value; + } + + internal void SetIsVertListDim(bool value) + { + m_bIsVertListDim = value; + } + + #endregion Internal Methods + + #region Private Fields + + private bool m_bIsRelative = false; + + private bool m_bIsVertListDim = false; + + private double m_dDimension; + + // reference + private Split m_Parent; + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/WebWindowComplex/Models/Splitted.cs b/WebWindowComplex/Models/Splitted.cs new file mode 100644 index 0000000..17ba514 --- /dev/null +++ b/WebWindowComplex/Models/Splitted.cs @@ -0,0 +1,57 @@ +using WebWindowComplex.Json; +using static WebWindowComplex.Json.WindowConst; + +namespace WebWindowComplex.Models +{ + public class Splitted : Area + { + #region Public Constructors + + public Splitted(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow) + { + } + + #endregion Public Constructors + + #region Public Methods + + public override Splitted Copy(Area newParentArea) + { + Splitted newSplitted = new Splitted(newParentArea, ParentWindow); + AddCounterGroup(); + newSplitted.SetIdGroup(nCounterGroup); + newSplitted.SetAreaType(AreaType); + foreach (var item in AreaList) + { + Area a = item.Copy(newSplitted); + newSplitted.AreaList.Add(a); + } + return newSplitted; + } + + #endregion Public Methods + + #region Internal Methods + + internal static Splitted CreateSplitted(Area ParentArea) + { + Splitted Splitted = new Splitted(ParentArea, ParentArea.ParentWindow); + AddCounterGroup(); + Splitted.SetIdGroup(nCounterGroup); + Splitted.SetAreaType(AreaTypes.SPLITTED); + return Splitted; + } + + internal override JsonArea Serialize() + { + if (nCounterGroup < IdGroup) + Area.nCounterGroup = IdGroup; + JsonSplitted JsonSplitted = new JsonSplitted(IdGroup); + foreach (var Area in AreaList) + JsonSplitted.AreaList.Add(Area.Serialize()); + return JsonSplitted; + } + + #endregion Internal Methods + } +} \ No newline at end of file diff --git a/WebWindowComplex/Models/Window.cs b/WebWindowComplex/Models/Window.cs new file mode 100644 index 0000000..4b37f20 --- /dev/null +++ b/WebWindowComplex/Models/Window.cs @@ -0,0 +1,131 @@ +using Egw.Window.Data; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System.Collections; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Drawing; +using System.Runtime.Intrinsics.Arm; +using System.Security.Cryptography; +using System.Xml.Linq; +using System.Xml.Serialization; +using WebWindowComplex.Json; +using static WebWindowComplex.Json.WindowConst; +using static WebWindowComplex.ParametriOpzioni; + +namespace WebWindowComplex.Models +{ + public class Window + { + #region Public Events + + public event EventHandler OnPreview = delegate { }; + + #endregion Public Events + + #region Public Properties + + public List AreaList + { + get + { + return m_AreaList; + } + set + { + m_AreaList = value; + } + } + + public string sColorMaterial + { + get + { + return m_sColorMaterial; + } + set + { + m_sColorMaterial = value; + OnUpdatePreview(sSerialized()); + } + } + + public string sGlass + { + get + { + return m_sGlass; + } + set + { + m_sGlass = value; + OnUpdatePreview(sSerialized()); + } + } + + public string sMaterial + { + get + { + return m_sMaterial; + } + set + { + m_sMaterial = value; + OnUpdatePreview(sSerialized()); + } + } + + public string sProfilePath + { + get + { + return m_sProfilePath; + } + set + { + m_sProfilePath = value; + OnUpdatePreview(sSerialized()); + } + } + + #endregion Public Properties + + #region Internal Methods + + internal void OnUpdatePreview(string sJwd) + { + OnPreviewEventArgs e = new OnPreviewEventArgs(sJwd); + EventHandler handler = OnPreview; + if (handler != null) + { + handler(this, e); + } + } + + internal JsonWindow Serialize() + { + JsonWindow JsonWindow = new JsonWindow(sProfilePath, sMaterial, sColorMaterial, sGlass); + foreach (var Area in AreaList) + JsonWindow.AreaList.Add(Area.Serialize()); + return JsonWindow; + } + + internal string sSerialized() + { + return JsonConvert.SerializeObject(Serialize(), Formatting.Indented); + } + + #endregion Internal Methods + + #region Private Fields + + private List m_AreaList = new List(); + private string m_sColorMaterial; + private string m_sGlass; + private string m_sMaterial; + private string m_sProfilePath; + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/WebWindowComplex/SerialMan.cs b/WebWindowComplex/SerialMan.cs new file mode 100644 index 0000000..2daaf14 --- /dev/null +++ b/WebWindowComplex/SerialMan.cs @@ -0,0 +1,81 @@ +using Egw.Window.Data; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WebWindowComplex.Json; +using WebWindowComplex.Models; +using static WebWindowComplex.Json.WindowConst; + +namespace WebWindowComplex +{ + public class SerialMan + { + /// + /// Riceve un JWD in ingresso e effettua una sostituzione dei parametri rieschiesti (SE non nulli) + /// + /// + /// + /// + /// + /// Valore serializzato con le modifiche richieste + public static string MassUpdate(string currSer, string? newFamilyHardware, Hardware? newHardware, string? newColorMaterial, string? newMaterial, string? newGlass, string? newProfile) + { + string outVal = currSer; + // serializzazione JWD --> window + JsonWindow WindowFromJson = JsonConvert.DeserializeObject(currSer, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); + Window currWindow = WindowFromJson.Deserialize(); + // verifica 1:1 delle richieste + if (!string.IsNullOrEmpty(newFamilyHardware)) + { + SearchSash(currWindow.AreaList.First(), newFamilyHardware, null); + } + if (newHardware != null) + { + SearchSash(currWindow.AreaList.First(), null, newHardware); + } + if (!string.IsNullOrEmpty(newColorMaterial)) + { + currWindow.sColorMaterial = newColorMaterial; + } + if (!string.IsNullOrEmpty(newMaterial)) + { + currWindow.sMaterial = newMaterial; + } + if (!string.IsNullOrEmpty(newGlass)) + { + currWindow.sGlass = newGlass; + } + if (!string.IsNullOrEmpty(newProfile)) + { + currWindow.sProfilePath = newProfile; + } + var CurrJwd = JsonConvert.SerializeObject(currWindow.Serialize(), Formatting.Indented); + return CurrJwd; + + + } + + internal static void SearchSash(Area currentArea, string? newFamilyHw, Hardware? newHardware) + { + if (currentArea.AreaType.Equals(AreaTypes.SASH)) + { + Sash s = (Sash)currentArea; + if (!string.IsNullOrEmpty(newFamilyHw)) + { + s.SelFamilyHardware = newFamilyHw; + } + if (newHardware != null) + { + s.SelHardware = newHardware; + } + } + foreach (Area child in currentArea.AreaList) + { + SearchSash(child, newFamilyHw, newHardware); + } + } + } +} diff --git a/WebWindowComplex/TableComp.razor b/WebWindowComplex/TableComp.razor index 021ecc7..1095e49 100644 --- a/WebWindowComplex/TableComp.razor +++ b/WebWindowComplex/TableComp.razor @@ -1,4 +1,5 @@ -
+@using static WebWindowComplex.LayoutConst +
@if (isLoading) { @@ -25,7 +26,6 @@
Errore configurazione:
-
    @foreach (var item in listErrLink) { @@ -40,7 +40,7 @@
    -
    +
    -
    +
    @if (currStep != CompileStep.Template) { }
    -
    +
    -
    +
    -
    - @if (string.IsNullOrEmpty(LiveData.CurrJwd)) + @if (string.IsNullOrEmpty(LiveData.CurrJwd)) + { + @if (currStep == CompileStep.Template && ListPayload.TemplateDTO != null) { - @if (currStep == CompileStep.Template && ListPayload.TemplateDTO != null) - { - - - - - - +
    #ImageDescription
    + + + + + + + + + @foreach (var item in ListPayload.TemplateDTO) + { + string colorClass = ""; + @if (SelTemplateDTO != null && item.Index == SelTemplateDTO.Index) + colorClass = "table-success"; + else + colorClass = ""; + + + + - - - @foreach (var item in ListPayload.TemplateDTO) - { - string colorClass = ""; - @if (SelTemplateDTO != null && item.Index == SelTemplateDTO.Index) - colorClass = "table-success"; - else - colorClass = ""; - - - - - - } - -
    #ImageDescription
    @item.Index@item.Description
    @item.Index@item.Description
    - } + } + + } - @if (currStep == CompileStep.Tree) + } + @if (currStep == CompileStep.Tree) + { + + } + else if (currStep == CompileStep.Frame) + { + @if (m_CurrWindow != null) { -
    - - - @for (int i = 0; i < ItemTableList.Count; i++) - { - - @for (int j = 0; j < m_maxCol; j++) - { - CompileStep cs = CompileStep.Frame; - int ind = -1; - @if (j + 1 == ItemTableList[i].Col) - { - @if (ItemTableList[i].Type is Json.WindowConst.AreaTypes.FRAME) - { - cs = CompileStep.Frame; - } - else if (ItemTableList[i].Type is Json.WindowConst.AreaTypes.SPLIT) - { - cs = CompileStep.Split; - ind = ItemTableList[i].IndexItem; - } - else if (ItemTableList[i].Type is Json.WindowConst.AreaTypes.SASH) - { - cs = CompileStep.Sash; - ind = ItemTableList[i].IndexItem; - } - else if (ItemTableList[i].Type is Json.WindowConst.AreaTypes.FILL) - { - cs = CompileStep.Fill; - ind = ItemTableList[i].IndexItem; - } - - } - else - { - - } - } - - } - -
    - - @FillTable(i, j)
    -
    - + m_PreviousWindow = m_CurrWindow; } - else if (currStep == CompileStep.Frame) + + } + else if (currStep == CompileStep.Split) + { + @if (currSplit >= SplitList.Count || currSplit == -1) { - @if (m_CurrWindow != null) - { - m_PreviousWindow = m_CurrWindow; - } -
    -
    -
    -
    -
    -
    -
    -
    -
    -

    Frame

    -
    -
    -
    -
    -
    - - -
    -
    -
    -
    -
    -
    -
    Dimension
    - @foreach (FrameDimension dimension in FrameWindow.DimensionList) - { -
    - @dimension.sName - - mm -
    - } -
    -
    -
    Threshold
    -
    - - -
    -
    -
    -
    -
    -
    -
    -
    -
    Joints
    -
    -
    -
    - -
    -
    -
    -
    - -
    -
    -
    -
    - -
    -
    -
    -
    - @foreach (Joint joint in FrameWindow.JointList) - { -
    - - -
    - } -
    -
    -
    - @if (m_SashList.Count == 0) - { -
    -
    Bottom rail
    -
    -
    -
    - Quantity - -
    -
    - } -
    - -
    -
    -
    - @if (!(FrameWindow.AreaList[0] is Split) || (SashList.Count == 0 && SplitList.Count == 0)) - { - - - } -
    -
    -
    -
    -
    + currStep = CompileStep.Tree; } - else if (currStep == CompileStep.Split) + else { - @if (currSplit >= SplitList.Count || currSplit == -1) - { - currStep = CompileStep.Tree; - } - else - { - Split item = SplitList[currSplit]; -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    @(descParentSplit(item))
    -
    -
    -
    -
    -
    -
    -
    -
    Split
    -
    -
    - @if ((item.nSplitQtyVert == 1 && item.nSplitQtyHoriz == 0) || (item.nSplitQtyVert == 0 && item.nSplitQtyHoriz == 1)) - { -
    - -
    - } -
    -
    -
    - -
    -
    -
    -
    -
    -
    - - -
    -
    -
    -
    - @if (item.nSplitQtyVert > 0) - { -
    -
    - QtyVert - -
    -
    - } - @if (item.nSplitQtyHoriz > 0) - { -
    -
    - QtyHoriz - -
    -
    - } -
    -
    - @if (item.SplitVertList.Count > 0 && item.SplitHorizList.Count > 0) - { -
    - @foreach (var dim in item.SplitVertList) - { -
    - Width - - % -
    - } -
    -
    - @foreach (var dim in item.SplitHorizList) - { -
    - Height - - % -
    - - } -
    - } - else if (item.SplitHorizList.Count > 0) - { - @foreach (var dim in item.SplitHorizList) - { -
    -
    - Height - - % -
    -
    - } - } - else if (item.SplitVertList.Count > 0) - { - @foreach (var dim in item.SplitVertList) - { -
    -
    - Width - - % -
    -
    - } - } -
    - @if (item.SelSplitShape == Json.WindowConst.SplitShapes.GRID) - { -
    -
    -
    -
    - -
    -
    - -
    -
    -
    -
    - } -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - } + } - else if (currStep == CompileStep.Sash) + } + else if (currStep == CompileStep.Sash) + { + @if (currSash >= SashList.Count || currSash == -1) { - @if (currSash >= SashList.Count || currSash == -1) - { - currStep = CompileStep.Tree; - } - else - { - Sash item = SashList[currSash]; -
    -
    -
    -
    -
    -
    -
    -
    -
    - @if (SashList.Count > 1) - { -

    Window @(currSash + 1)

    - } - else - { -

    Window

    - } -
    -
    -
    - -
    -
    -
    -
    -
    -
    - Qty sash - -
    -
    -
    -
    -
    -
    - - -
    -
    -
    -
    - Qty bottom rail - -
    -
    -
    -
    -
    -
    -
    -
    -
    Joints
    -
    -
    -
    - -
    -
    -
    -
    - -
    -
    -
    -
    - -
    -
    -
    - @foreach (Joint joint in item.JointList) - { -
    -
    - - -
    -
    - } - -
    -
    -
    -
    -
    Hardware
    -
    -
    -
    -
    -
    - - -
    -
    - - -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - @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]; - Area anta; - @if (item.AreaList[i * 2 + j] is Splitted) - { - anta = item.AreaList[i * 2 + j]; - } - else - { - anta = item; - } -
    - @if (item.SashList.Count == 1) - { -
    Sash
    - } - else - { -
    Sash @(i * 2 + j + 1)
    - } -
    - - -
    -
    - Dimension - - % -
    -
    -
    - -
    -
    - -
    -
    - @if (!(anta.AreaList[0] is Split)) - { -
    -
    -
    - -
    -
    -
    -
    - -
    -
    -
    - } -
    - @for (int k = 0; k <= item.SashList.Count - 1; k++) - { - @if (k != i * 2 + j) - { - int IndexCopy = k; - int IndexModify = i * 2 + j; -
    -
    - -
    -
    - } - } -
    -
    - - } - } -
    -
    -
    -
    -
    -
    -
    -
    - } + currStep = CompileStep.Tree; } - else if (currStep == CompileStep.Fill) + else { - @if (currFill >= FillList.Count || currFill == -1) - { - currStep = CompileStep.Tree; - } - else - { - Fill item = FillList[currFill]; -
    -
    -
    -
    -
    -
    -
    -
    -
    -

    Fill @(currFill + 1)

    -
    -
    -
    - -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    -
    Selected all fill
    -
    -
    -
    - -
    -
    -
    -
    - -
    -
    -
    -
    -
    - @foreach (var currSplitted in SplittedList) - @* @for (int i = 0; i < SplittedList.Count; i++) *@ - { - @* Splitted currSplitted = SplittedList[i]; *@ - @if (currSplitted.AreaList[0].Equals(item)) - { -
    -
    -
    -
    - @if (SplittedList.Count > 1) - { -

    Area split @(SplittedList.IndexOf(currSplitted) + 1)

    - } - else - { -

    Area split

    - } -
    -
    -
    - -
    -
    - @foreach (var Index in SashList) - @* @for (int j = 0; j < SashList.Count; j++) *@ - { - @* int Index = j; *@ -
    -
    - -
    -
    - } -
    -
    -
    - } - } -
    -
    -
    -
    -
    - } + } - else if (currStep == CompileStep.General) + } + else if (currStep == CompileStep.Fill) + { + @if (currFill >= FillList.Count || currFill == -1) { - + currStep = CompileStep.Tree; } -
    + else + { + + } + } + else if (currStep == CompileStep.General) + { + + }
    @@ -801,7 +177,6 @@
    Mancata corrispondenza valori:
    -
      @foreach (var item in listWarnings) { @@ -820,5 +195,4 @@ -} - +} \ No newline at end of file diff --git a/WebWindowComplex/TableComp.razor.cs b/WebWindowComplex/TableComp.razor.cs index 4505d2e..f4c3382 100644 --- a/WebWindowComplex/TableComp.razor.cs +++ b/WebWindowComplex/TableComp.razor.cs @@ -1,14 +1,12 @@ using Egw.Window.Data; 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 WebWindowComplex.Compo; using WebWindowComplex.DTO; using WebWindowComplex.Json; +using WebWindowComplex.Models; +using static WebWindowComplex.LayoutConst; using static WebWindowComplex.Json.WindowConst; namespace WebWindowComplex @@ -91,29 +89,6 @@ namespace WebWindowComplex #endregion Protected Fields - #region Protected Enums - - protected enum CompileStep - { - Template = 0, - Tree = 1, - Frame, - Split, - Sash, - Fill, - General - } - - protected enum PositionJoints - { - BL = 0, // Bottom Left - BR = 1, // Bottom Right - TR, // Top Right - TL // Top Left - } - - #endregion Protected Enums - #region Protected Properties protected List FillList @@ -155,6 +130,7 @@ namespace WebWindowComplex protected string SelColorMaterial { get; set; } = ""; protected string SelFamilyHardware { get; set; } = ""; protected string SelGlass { get; set; } = ""; + protected string SelProfile { get; set; } = ""; protected string SelMaterial { get; set; } = ""!; @@ -179,8 +155,10 @@ namespace WebWindowComplex /// /// anta su cui si seleziona la maniglia /// - protected void changeHandle(SashDimension sashDim, Sash currSash) + protected void changeHandle(DataChangeHandle Args) { + SashDimension sashDim = Args.currSashDimension; + Sash currSash = Args.currItem; // Cerco la Sash che si sta considerando nella lista Sash foreach (Sash s in SashList) { @@ -223,8 +201,10 @@ namespace WebWindowComplex /// /// split su cui si sceglie /// - protected void changeStartVert(ChangeEventArgs e, Split currSplit) + protected async Task changeStartVert(DataChangeStartVert Args) { + ChangeEventArgs e = Args.eventArg; + Split currSplit = Args.currItem; // Cerco la Sash che si sta considerando nella lista Sash foreach (Split s in SplitList) { @@ -233,6 +213,7 @@ namespace WebWindowComplex s.SetSplitStartVert((bool)e.Value); } } + await DoPreviewSvg(); } /// @@ -275,9 +256,9 @@ namespace WebWindowComplex nWIndow = SashList.Count == 1 ? "" : $"{i + 1}"; // Se il nodo ha figli, salvo il numero nell'oggetto if (node.AreaList.Count >= 1) - ItemTableList.Add(new ItemTable(AreaTypes.SASH, "WIN" + nWIndow, maxRow, col, i, node.AreaList.Count)); + ItemTableList.Add(new ItemTable(AreaTypes.SASH, "SG" + nWIndow, maxRow, col, i, node.AreaList.Count)); else - ItemTableList.Add(new ItemTable(AreaTypes.SASH, "WIN" + nWIndow, maxRow, col, i, 0)); + ItemTableList.Add(new ItemTable(AreaTypes.SASH, "SG" + nWIndow, maxRow, col, i, 0)); } } maxCol++; @@ -286,9 +267,9 @@ namespace WebWindowComplex { // Se il nodo ha figli, salvo il numero nell'oggetto if (node.AreaList.Count >= 1) - ItemTableList.Add(new ItemTable(AreaTypes.SASH, "WIN", row, col, 0, node.AreaList.Count)); + ItemTableList.Add(new ItemTable(AreaTypes.SASH, "SG", row, col, 0, node.AreaList.Count)); else - ItemTableList.Add(new ItemTable(AreaTypes.SASH, "WIN", row, col, 0, 0)); + ItemTableList.Add(new ItemTable(AreaTypes.SASH, "SG", row, col, 0, 0)); maxCol++; } row++; @@ -298,8 +279,8 @@ namespace WebWindowComplex } case AreaTypes.FILL: { - if ((node.ParentArea.AreaList.Count > 1 && node.ParentArea.AreaList[0].Equals(node)) || - (node.ParentArea.ParentArea != null && node.ParentArea.ParentArea.AreaList.Count > 1 && node.ParentArea.ParentArea.AreaList[0].AreaList[0].Equals(node))) + if ((node.ParentArea.AreaList.Count > 1 && node.ParentArea.AreaList.First().Equals(node)) || + (node.ParentArea.ParentArea != null && node.ParentArea.ParentArea.AreaList.Count > 1 && node.ParentArea.ParentArea.AreaList.First().AreaList.First().Equals(node))) maxCol++; string nFill; for (int i = 0; i < FillList.Count; i++) @@ -321,7 +302,7 @@ namespace WebWindowComplex // Se il nodo ha fratelli o cugini if (node.ParentArea.AreaList.Count > 1 || (node.ParentArea.ParentArea != null && node.ParentArea.ParentArea.AreaList.Count > 1)) { - if (node.ParentArea.AreaList[0].Equals(node) || node.ParentArea.ParentArea.AreaList[0].Equals(node)) + if (node.ParentArea.AreaList.First().Equals(node) || node.ParentArea.ParentArea.AreaList.First().Equals(node)) maxCol++; for (int i = 0; i < SplitList.Count; i++) { @@ -413,7 +394,7 @@ namespace WebWindowComplex } case AreaTypes.SPLITTED: { - if (node.ParentArea is Split && !IntoSash && node.AreaList[0] is Fill) + if (node.ParentArea is Split && !IntoSash && node.AreaList.First() is Fill) { m_SplittedList.Add((Splitted)node); } @@ -428,37 +409,13 @@ namespace WebWindowComplex } /// - /// Metodo per determinare la descrizione del parent dello split corrente + /// Calcola CSS warning /// - /// split corrente + /// /// - protected string descParentSplit(Split currSplit) + protected string cssValid(string fKey) { - 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 ""; + return listWarnings.ContainsKey(fKey) ? "border border-danger" : ""; } /// @@ -501,31 +458,8 @@ namespace WebWindowComplex /// 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(LiveData.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; - editLock = false; - bError = false; - await DoPreviewSvg(); + { + // Da fare } /// @@ -616,7 +550,6 @@ namespace WebWindowComplex { listErrLink.Add("Window", $"Deserializing Error:{Environment.NewLine}{ex}"); } - updateSvg = true; } checkWarnings(); @@ -662,66 +595,6 @@ namespace WebWindowComplex } } - /// - /// Verifica errori prelimionari per mostrare dove sia il problema - /// - private void checkErrorPre() - { - // verifico 1:1 le liste e indico cosa manca - if (ListPayload.Hardware == null || ListPayload.Hardware.Count == 0) - { - listErrPre.Add("Hardware", "Missing Hardware List!"); - } - else - { - if (ListPayload.FamilyHardware == null || ListPayload.FamilyHardware.Count == 0) - { - listErrPre.Add("FamilyHardware", "Missing Famly HW List!"); - } - } - if (ListPayload.Glass == null || ListPayload.Glass.Count == 0) - { - listErrPre.Add("Glass", "Missing Glass List!"); - } - if (ListPayload.Material == null || ListPayload.Material.Count == 0) - { - listErrPre.Add("Material", "Missing Material List!"); - } - if (ListPayload.ColorMaterial == null || ListPayload.ColorMaterial.Count == 0) - { - listErrPre.Add("ColorMaterial", "Missing ColorMaterial List!"); - } - } - - /// - /// Verifica warning minori (es coerenza colori...) - /// - private void checkWarnings() - { - // verifico 1:1 le liste e i valori siano coerenti... - if (ListPayload.ColorMaterial != null && ListPayload.ColorMaterial.Count > 0) - { - // verifico colore attuale sia consistente... - if (m_CurrWindow != null) - { - if (!ListPayload.ColorMaterial.Contains(m_CurrWindow.sColorMaterial)) - { - listWarnings.Add("ColorMaterial", $"Missing Color: {m_CurrWindow.sColorMaterial}"); - } - } - } - } - - /// - /// Calcola CSS warning - /// - /// - /// - protected string cssValid(string fKey) - { - return listWarnings.ContainsKey(fKey) ? "border border-danger" : ""; - } - protected void setCurrWindow(JsonWindow WindowFromJson) { if (m_CurrWindow != null) @@ -735,9 +608,9 @@ namespace WebWindowComplex if (m_PreviousWindow != null) { for (int i = 0; i < 2; i++) - m_CurrWindow.AreaList[0].DimensionList[i] = m_PreviousWindow.AreaList[0].DimensionList[i]; + m_CurrWindow.AreaList.First().DimensionList[i] = m_PreviousWindow.AreaList.First().DimensionList[i]; for (int i = 0; i < 4; i++) - m_CurrWindow.AreaList[0].JointList[i] = m_PreviousWindow.AreaList[0].JointList[i]; + m_CurrWindow.AreaList.First().JointList[i] = m_PreviousWindow.AreaList.First().JointList[i]; } if (m_CurrWindow != null) { @@ -760,8 +633,8 @@ namespace WebWindowComplex 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); + CreateWindowsList((m_CurrWindow!).AreaList.First(), false); + CreateElementTable(m_CurrWindow.AreaList.First(), 1, 1, 1, 1); } /// @@ -777,6 +650,7 @@ namespace WebWindowComplex SelColorMaterial = CurrSelection.ColorMaterial ?? ""; SelMaterial = CurrSelection.Material ?? ""; SelGlass = CurrSelection.Glass ?? ""; + SelProfile = CurrSelection.Profile ?? ""; } } @@ -910,11 +784,12 @@ namespace WebWindowComplex /// /// 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) + private async Task ChangeAllJoints(DataChangeJoints Args) { + WindowConst.Joints type = Args.currJointType; + Area area = Args.currArea; if (area is Frame) { foreach (Joint joint in FrameWindow.JointList) @@ -945,20 +820,87 @@ namespace WebWindowComplex await DoPreviewSvg(); } + /// + /// Verifica errori prelimionari per mostrare dove sia il problema + /// + private void checkErrorPre() + { + // verifico 1:1 le liste e indico cosa manca + if (ListPayload.Hardware == null || ListPayload.Hardware.Count == 0) + { + listErrPre.Add("Hardware", "Missing Hardware List!"); + } + else + { + if (ListPayload.FamilyHardware == null || ListPayload.FamilyHardware.Count == 0) + { + listErrPre.Add("FamilyHardware", "Missing Family HW List!"); + } + } + if (ListPayload.Glass == null || ListPayload.Glass.Count == 0) + { + listErrPre.Add("Glass", "Missing Glass List!"); + } + if (ListPayload.Material == null || ListPayload.Material.Count == 0) + { + listErrPre.Add("Material", "Missing Material List!"); + } + if (ListPayload.ColorMaterial == null || ListPayload.ColorMaterial.Count == 0) + { + listErrPre.Add("ColorMaterial", "Missing ColorMaterial List!"); + } + if (ListPayload.Profile == null || ListPayload.Profile.Count == 0) + { + listErrPre.Add("Profile", "Missing Profile List!"); + } + } + + /// + /// Verifica warning minori (es coerenza colori...) + /// + private void checkWarnings() + { + // verifico 1:1 le liste e i valori siano coerenti... + if (ListPayload.ColorMaterial != null && ListPayload.ColorMaterial.Count > 0) + { + // verifico colore attuale sia consistente... + if (m_CurrWindow != null) + { + if (!ListPayload.ColorMaterial.Contains(m_CurrWindow.sColorMaterial)) + { + listWarnings.Add("ColorMaterial", $"Missing Color: {m_CurrWindow.sColorMaterial}"); + } + if (!ListPayload.Glass.Contains(m_CurrWindow.sGlass)) + { + listWarnings.Add("Glass", $"Missing Glass: {m_CurrWindow.sGlass}"); + } + if (!ListPayload.Material.Contains(m_CurrWindow.sMaterial)) + { + listWarnings.Add("Material", $"Missing Material: {m_CurrWindow.sMaterial}"); + } + if (!ListPayload.Profile.Contains(m_CurrWindow.sProfilePath)) + { + listWarnings.Add("Profile", $"Missing Profile: {m_CurrWindow.sProfilePath}"); + } + } + } + } + /// /// 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) + /// + private async Task CopyContentSash(DataCopyContentSash Args) { + Sash sashItem = Args.currItem; + int IndexCopy = Args.indexCopy; + int IndexModify = Args.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); + Area a = sashItem.AreaList[IndexCopy].AreaList.First().Copy(sashSplitted); // Aggiungo copia all'anta selezionata sashItem.AreaList[IndexModify].AreaList.Add(a); await DoPreviewSvg(); @@ -967,11 +909,12 @@ namespace WebWindowComplex /// /// Metodo per copiare una Sash intera /// - /// Area Splitted corrente - /// Indice della Sash che si vuole copiare + /// /// - private async Task CopySash(Splitted currSplitted, int numSash) + private async Task CopySash(DataAreaSplit Args) { + Splitted currSplitted = Args.splitted; + int numSash = Args.index; //Rimuovo contenuto di Splitted e rimuovo area da conteggio gruppi currSplitted.AreaList.RemoveAll(i => i != null); //Area.DelCounterGroup(); @@ -983,91 +926,6 @@ namespace WebWindowComplex await DoPreviewSvg(); } - /// - /// Metodo per riempire tabella con contenuto vuoto o con i simboli per rappresentare la struttura - /// - /// riga della cella - /// colonna della cella - /// - private string FillTable(int row, int col) - { - List itemSameCol = new List(); - for (int k = 0; k < row; k++) - { - if (ItemTableList[k].Col == col + 1) - { - itemSameCol.Add(ItemTableList[k]); - } - continue; - } - int numItemNextCol = 0; - for (int k = 0; k < row; k++) - { - if (ItemTableList[k].Row <= row && ItemTableList[k].Col == col + 2) - { - numItemNextCol++; - } - continue; - } - if (itemSameCol.Count > 1) - { - for (int i = 0; i <= itemSameCol.Count - 2; i++) - { - if (itemSameCol[i].NumChild > 0) - numItemNextCol = numItemNextCol - itemSameCol[i].NumChild; - } - } - if (itemSameCol.Count > 0) - { - // Sono alla riga successiva di un elemento e nella stessa colonna - if (itemSameCol.Last().Row == row) - { - // se ha un solo figlio - if (itemSameCol.Last().NumChild == 1) - { - return "└"; - } - else if (itemSameCol.Last().NumChild == 0) - { - return " "; - } - else - { - return "├"; - } - } - // Non sono alla riga successiva - else - { - // se ha un solo figlio - if (itemSameCol.Last().NumChild == 1) - { - return " "; - } - else if (col + 2 <= m_maxCol && ItemTableList[row].Col == col + 2) - { - if (numItemNextCol < itemSameCol.Last().NumChild && numItemNextCol != (itemSameCol.Last().NumChild - 1)) - { - return "├"; - } - return "└"; - } - else if (numItemNextCol < itemSameCol.Last().NumChild) - { - return "│"; - } - else - { - return " "; - } - } - } - else - { - return " "; - } - } - /// /// Calcola larghezza colonna header nav /// @@ -1095,10 +953,10 @@ namespace WebWindowComplex } /// - /// Metodo per cambiare step e aggiornare preview svg + /// Metodo per cambiare step /// /// step successivo - private void NextStepAndPreview(CompileStep newStep, int Index = -1) + private void NextStep(CompileStep newStep, int Index = 1) { editLock = true; currStep = newStep; @@ -1126,10 +984,17 @@ namespace WebWindowComplex break; } } + } -#if false - await DoPreviewSvg(); -#endif + /// + /// Metodo per cambiare step + /// + /// + private void NextStepArgs(DataNextStep Args) + { + CompileStep newStep = Args.currCompileStep; + int Index = Args.index; + NextStep(newStep, Index); } /// @@ -1148,6 +1013,63 @@ namespace WebWindowComplex currStep = CompileStep.Tree; } + /// + /// Ritorno step Tree + /// + /// + private void ReturnTree(bool args) + { + AdvStep(CompileStep.Tree); + } + + /// + /// Selezione del colore + /// + /// + private void SelectColor(string newVal) + { + if (m_CurrWindow != null) + { + m_CurrWindow.sColorMaterial = newVal; + } + } + + /// + /// Selezione del vetro + /// + /// + private void SelectGlass(string newVal) + { + if (m_CurrWindow != null) + { + m_CurrWindow.sGlass = newVal; + } + } + + /// + /// Selezione del materiale + /// + /// + private void SelectMat(string newVal) + { + if (m_CurrWindow != null) + { + m_CurrWindow.sMaterial = newVal; + } + } + + /// + /// Selezione del profilo + /// + /// + private void SelectProfile(string newVal) + { + if (m_CurrWindow != null) + { + m_CurrWindow.sProfilePath = newVal; + } + } + /// /// Metodo per scambiare due aree di uno split /// @@ -1190,27 +1112,54 @@ namespace WebWindowComplex return (testStep == currStep) ? "nav-link active fw-bold" : "nav-link text-secondary"; } + /// + /// Aggiornamento Frame + /// + /// + /// + private async Task UpdateFrame(Frame newFrame) + { + FrameWindow = newFrame; + await DoPreviewSvg(); + } + + /// + /// Aggiornamento Sash e Frame + /// + /// nuova sash + /// + private async Task UpdateSash(Sash newSash) + { + SearchSash(m_Frame, newSash.IdGroup, newSash); + await DoPreviewSvg(); + } + + /// + /// Cerca e aggiorna la sash + /// + /// area corrente che si sta valutando + /// id della sash che si sta cercando + /// nuova sash + /// + public Area SearchSash(Area currentArea, int idSearch, Sash newSash) + { + if (currentArea.IdGroup == idSearch && currentArea.AreaType.Equals(AreaTypes.SASH)) + { + currentArea = newSash; + return currentArea; + } + foreach (Area child in currentArea.AreaList) + { + Area found = SearchSash(child, idSearch, newSash); + if (found != null) + { + return found; + } + } + return null; + } + + #endregion Private Methods - private void SelectColor(string newVal) - { - if (m_CurrWindow != null) - { - m_CurrWindow.sColorMaterial = newVal; - } - } - private void SelectMat(string newVal) - { - if (m_CurrWindow != null) - { - m_CurrWindow.sMaterial = newVal; - } - } - private void SelectGlass(string newVal) - { - if (m_CurrWindow != null) - { - m_CurrWindow.sGlass = newVal; - } - } } } \ No newline at end of file diff --git a/WebWindowComplex/WebWindowComplex.csproj b/WebWindowComplex/WebWindowComplex.csproj index f12895d..9ccca42 100644 --- a/WebWindowComplex/WebWindowComplex.csproj +++ b/WebWindowComplex/WebWindowComplex.csproj @@ -29,161 +29,3 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/WebWindowComplex/Window.cs b/WebWindowComplex/Window.cs deleted file mode 100644 index 2ddbd63..0000000 --- a/WebWindowComplex/Window.cs +++ /dev/null @@ -1,2831 +0,0 @@ -using Egw.Window.Data; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Collections; -using System.Collections.ObjectModel; -using System.ComponentModel; -using System.Drawing; -using System.Runtime.Intrinsics.Arm; -using System.Security.Cryptography; -using System.Xml.Linq; -using System.Xml.Serialization; -using WebWindowComplex.Json; -using static WebWindowComplex.Json.WindowConst; -using static WebWindowComplex.ParametriOpzioni; - -namespace WebWindowComplex -{ - - public class Window - { - public event EventHandler OnPreview = delegate { }; - - private string m_sProfilePath; - public string sProfilePath - { - get - { - return m_sProfilePath; - } - set - { - m_sProfilePath = value; - } - } - - private string m_sMaterial; - public string sMaterial - { - get - { - return m_sMaterial; - } - set - { - m_sMaterial = value; - OnUpdatePreview(sSerialized()); - } - } - - private string m_sColorMaterial; - public string sColorMaterial - { - get - { - return m_sColorMaterial; - } - set - { - m_sColorMaterial = value; - OnUpdatePreview(sSerialized()); - } - } - - private string m_sGlass; - public string sGlass - { - get - { - return m_sGlass; - } - set - { - m_sGlass = value; - OnUpdatePreview(sSerialized()); - } - } - - private List m_AreaList = new List(); - public List AreaList - { - get - { - return m_AreaList; - } - set - { - m_AreaList = value; - } - } - - internal JsonWindow Serialize() - { - JsonWindow JsonWindow = new JsonWindow(sProfilePath, sMaterial, sColorMaterial, sGlass); - foreach (var Area in AreaList) - JsonWindow.AreaList.Add(Area.Serialize()); - return JsonWindow; - } - - internal string sSerialized() - { - return JsonConvert.SerializeObject(Serialize(), Formatting.Indented); - } - - internal void OnUpdatePreview(string sJwd) - { - OnPreviewEventArgs e = new OnPreviewEventArgs(sJwd); - EventHandler handler = OnPreview; - if (handler != null) - { - handler(this, e); - } - } - } - - public class OnPreviewEventArgs : EventArgs - { - public string sJwd; - - public OnPreviewEventArgs(string sJwd) - { - this.sJwd = sJwd; - } - } - - 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 - { - get - { - return m_ParentWindow; - } - } - - protected int m_nAreaId = -1; - public int nAreaId - { - get - { - return m_nAreaId; - } - set - { - m_nAreaId = value; - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); - } - } - - private List m_AreaList = new List(); - public List AreaList - { - get - { - return m_AreaList; - } - set - { - m_AreaList = value; - } - } - - private AreaTypes m_AreaType; - public AreaTypes AreaType - { - get - { - return m_AreaType; - } - set - { - m_AreaType = value; - } - } - internal void SetAreaType(AreaTypes AreaType) - { - m_AreaType = AreaType; - } - - private Area m_ParentArea; - public Area ParentArea - { - get - { - return m_ParentArea; - } - } - internal void SetParentArea(Area ParentArea) - { - m_ParentArea = ParentArea; - } - - public Area(Area ParentArea, Window ParentWindow) - { - m_ParentWindow = ParentWindow; - m_ParentArea = ParentArea; - } - - internal abstract JsonArea Serialize(); - - public void AddSplit(Area ParentArea) - { - List ContentArea = new List(); - // Salvo gli oggetti già presenti e li cancello da AreaList - ContentArea.Add(AreaList[0]); - AreaList.Remove(AreaList[0]); - // Aggiungo Area split di default - Split SplitArea = Split.CreateSplit(this, SplitShapes.HORIZONTAL); - // imposto i parametri di default - SplitArea.SetSplitQtyHoriz(1); - SplitArea.SetSplitStartVert(false); - // Aggiungo area - AreaList.Add(SplitArea); - // Creo le due aree Splitted - List newSplittedList = new List(); - for (int i = 0; i < 2; i++) - newSplittedList.Add(Splitted.CreateSplitted(SplitArea)); - // Inserisco nelle aree Splitted il Fill salvato e un Fill uguale (e setto ParentArea del fill) - ContentArea[0].SetParentArea(newSplittedList[0]); - newSplittedList[0].AreaList.Add(ContentArea[0]); - if (ContentArea[0] is Fill) - { - Fill fill1 = (Fill)ContentArea[0]; - Fill fill2 = Fill.CreateFill(newSplittedList[1], fill1.FillType); - newSplittedList[1].AreaList.Add(fill2); - } - else - { - Fill fill2 = Fill.CreateFill(newSplittedList[1], FillTypes.GLASS); - newSplittedList[1].AreaList.Add(fill2); - } - // All'area Split aggiunto le due aree Splitted - for (int i = 0; i < 2; i++) - AreaList[0].AreaList.Add(newSplittedList[i]); - ParentWindow.OnUpdatePreview(ParentWindow.sSerialized()); - } - - public bool AddFirstSash() - { - bool answ = false; - // Salvo il parent - Area ParentArea = AreaList[0].ParentArea; - // Creo area sash di default - Sash SashArea = Sash.CreateSash(ParentArea); - // ricerco tra ttuti gli hw disponibili... - string sShape = FindSashShape(); - var listHwValid = Sash - .m_HardwareCompleteList - .Where(x => x.Shape == sShape && x.SashQty == 1) - .FirstOrDefault(); - if (listHwValid != null) - { - // seleziono la famiglia del primo hw trovato... - SashArea.SelFamilyHardware = listHwValid.FamilyName; - SashArea.RefreshHardwareList(); - if (SashArea.HardwareList.Count == 0) - { - SashArea.Remove(); - answ = true; - } - else - { - SashArea.SetSelHardwareFromId(SashArea.HardwareList.First().Id); - // Salvo gli oggetti già presenti e li cancello da AreaList - List ContentArea = new List(); - ContentArea.Add(AreaList[0]); - AreaList.Remove(AreaList[0]); - // Aggiungo area - AreaList.Add(SashArea); - if (SashArea.nSashQty == 1) - { - // Inserisco il riempimento precedente - AreaList[0].AreaList.Add(ContentArea[0]); - AreaList[0].AreaList[0].SetParentArea(AreaList[0]); - } - else - { - // All'area Sash aggiunto uno Splitted per ogni anta - for (int i = 1; i < SashArea.nSashQty; i++) - { - AreaList[0].AreaList.Add(Splitted.CreateSplitted(SashArea)); - } - Fill fill2 = (Fill)ContentArea[0]; - for (int i = 1; i < SashArea.nSashQty; i++) - { - AreaList[0].AreaList[1].AreaList.Add(Fill.CreateFill(AreaList[0].AreaList[1], fill2.FillType)); - } - } - ParentWindow.OnUpdatePreview(ParentWindow.sSerialized()); - } - } - return answ; - } - - - /// - /// MockUp chiamata a c++ x scelta forma sash per Hw - /// - /// - private string FindSashShape() - { - return "Rectangular"; - } - public void SwapAree() - { - Area tempArea; - if (this is Sash || this is Split) - { - tempArea = AreaList[0]; - AreaList[0] = AreaList[1]; - AreaList[1] = tempArea; - } - } - - public abstract Area Copy(Area ParentArea); - } - - public class Frame : Area - { - - private List m_ShapeList = new List - { - new IdNameStruct((int)Shapes.RECTANGLE, "Rectangle"), - new IdNameStruct((int)Shapes.RIGHTCHAMFER, "Right Chamfer"), - new IdNameStruct((int)Shapes.LEFTCHAMFER, "Left Chamfer"), - new IdNameStruct((int)Shapes.DOUBLECHAMFER, "Double Chamfer"), - new IdNameStruct((int)Shapes.ARC, "Arc"), - new IdNameStruct((int)Shapes.ARC_FULL, "Arc Full"), - new IdNameStruct((int)Shapes.DOUBLEARC, "Double Arc"), - new IdNameStruct((int)Shapes.TRIANGLE, "Triangle") - }; - public List ShapeList - { - get - { - return m_ShapeList; - } - } - - private Shapes m_Shape; - public Shapes Shape - { - get - { - return m_Shape; - } - } - public int SelShapeIndex - { - get - { - return IdNameStruct.IndFromId((int)m_Shape, m_ShapeList); - } - set - { - Shapes SelShape = (Shapes)IdNameStruct.IdFromInd(value, m_ShapeList); - if (m_Shape != SelShape) - { - // verifico parametri Dimension - DimensionList.Clear(); - // aggiungo Dimensioni - switch (SelShape) - { - case Shapes.RECTANGLE: - case Shapes.ARC_FULL: - { - DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true)); - DimensionList.Add(new FrameDimension(this, 2, "Height", 1800, true)); - break; - } - - case Shapes.RIGHTCHAMFER: - { - DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true)); - DimensionList.Add(new FrameDimension(this, 2, "Left Height", 1800, true)); - DimensionList.Add(new FrameDimension(this, 3, "Right Height", 1500, true)); - break; - } - - case Shapes.LEFTCHAMFER: - { - DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true)); - DimensionList.Add(new FrameDimension(this, 2, "Left Height", 1500, true)); - DimensionList.Add(new FrameDimension(this, 3, "Right Height", 1800, true)); - break; - } - - case Shapes.DOUBLECHAMFER: - case Shapes.ARC: - { - DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true)); - DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true)); - DimensionList.Add(new FrameDimension(this, 3, "Full Height", 1800, true)); - break; - } - - case Shapes.DOUBLEARC: - { - DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true)); - DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true)); - DimensionList.Add(new FrameDimension(this, 3, "Full Height", 2400, true)); - break; - } - - case Shapes.TRIANGLE: - { - DimensionList.Add(new FrameDimension(this, 1, "Width", 2000, true)); - DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true)); - DimensionList.Add(new FrameDimension(this, 3, "Height projection", 0, true)); - break; - } - - case Shapes.CUSTOM: - { - DimensionList.Clear(); - break; - } - } - // salvo tipo Joint - Joints oldJointType = JointList[0].SelJointType; - // aggiungo Joint - m_JointList.Clear(); - switch (SelShape) - { - case Shapes.RECTANGLE: - case Shapes.RIGHTCHAMFER: - case Shapes.LEFTCHAMFER: - case Shapes.DOUBLECHAMFER: - case Shapes.ARC: - case Shapes.DOUBLEARC: - { - 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)); - break; - } - - case Shapes.ARC_FULL: - { - 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; - } - - case Shapes.TRIANGLE: - { - JointList.Add(new Joint(this, 1, oldJointType)); - JointList.Add(new Joint(this, 2, oldJointType)); - JointList.Add(new Joint(this, 3, Joints.ANGLED)); - break; - } - - case Shapes.CUSTOM: - { - JointList.Clear(); - break; - } - } - m_Shape = SelShape; - } - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); - } - } - internal void SetSelShape(Shapes Value) - { - DimensionList.Clear(); - // aggiungo Dimension - switch (Value) - { - case Shapes.RECTANGLE: - case Shapes.ARC_FULL: - { - DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true)); - DimensionList.Add(new FrameDimension(this, 2, "Height", 1800, true)); - break; - } - - case Shapes.RIGHTCHAMFER: - { - DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true)); - DimensionList.Add(new FrameDimension(this, 2, "Left Height", 1800, true)); - DimensionList.Add(new FrameDimension(this, 3, "Right Height", 1500, true)); - break; - } - - case Shapes.LEFTCHAMFER: - { - DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true)); - DimensionList.Add(new FrameDimension(this, 2, "Left Height", 1500, true)); - DimensionList.Add(new FrameDimension(this, 3, "Right Height", 1800, true)); - break; - } - - case Shapes.DOUBLECHAMFER: - case Shapes.ARC: - { - DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true)); - DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true)); - DimensionList.Add(new FrameDimension(this, 3, "Full Height", 1800, true)); - break; - } - - case Shapes.DOUBLEARC: - { - DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true)); - DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true)); - DimensionList.Add(new FrameDimension(this, 3, "Full Height", 2400, true)); - break; - } - - case Shapes.TRIANGLE: - { - DimensionList.Add(new FrameDimension(this, 1, "Width", 2000, true)); - DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true)); - DimensionList.Add(new FrameDimension(this, 3, "Height projection", 0, true)); - break; - } - - case Shapes.CUSTOM: - { - DimensionList.Clear(); - break; - } - } - // aggiungo Joint - //int nJointQty = 4; - switch (Value) - { - case Shapes.RECTANGLE: - case Shapes.RIGHTCHAMFER: - case Shapes.LEFTCHAMFER: - case Shapes.DOUBLECHAMFER: - 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)); - 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, 3, Joints.ANGLED)); - JointList.Add(new Joint(this, 4, Joints.ANGLED)); - break; - } - - 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, 3, Joints.ANGLED)); - break; - } - - case Shapes.CUSTOM: - { - JointList.Clear(); - break; - } - } - m_Shape = Value; - } - - private List m_DimensionList = new List(); - public List DimensionList - { - get - { - return m_DimensionList; - } - } - - private List m_JointList = new List(); - public List JointList - { - get - { - return m_JointList; - } - set - { - m_JointList = value; - } - } - - private bool m_bBottomRail; - public bool BottomRail - { - get - { - return m_bBottomRail; - } - set - { - m_bBottomRail = value; - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); - } - } - internal void SetBottomRail(bool bBottomRail) - { - m_bBottomRail = bBottomRail; - } - - private int m_nBottomRailQty = 0; - public int BottomRailQty - { - get - { - return m_nBottomRailQty; - } - set - { - if (m_nBottomRailQty >= 0) - { - m_nBottomRailQty = value; - if (m_nBottomRailQty > 0) - { - m_bBottomRail = true; - } - else - { - m_bBottomRail = false; - } - } - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); - } - } - internal void SetBottomRailQty(int nBottomRailQty) - { - m_nBottomRailQty = nBottomRailQty; - } - - public Frame(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow) - { - } - - internal static Area CreateFrame(Window Window) - { - Frame NewFrame = new Frame(null, Window); - NewFrame.SetAreaType(AreaTypes.FRAME); - NewFrame.SetSelShape(Shapes.RECTANGLE); - NewFrame.SetBottomRail(false); - NewFrame.SetBottomRailQty(0); - return NewFrame; - } - - public override Frame Copy(Area ParentArea) - { - return null; - } - - internal override JsonArea Serialize() - { - 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) - JsonFrame.JointList.Add(Joint.Serialize()); - foreach (var Area in AreaList) - JsonFrame.AreaList.Add(Area.Serialize()); - return JsonFrame; - } - } - - public class Sash : Area - { - // Lista hardware completa passata dal chiamante del componente - public static List m_HardwareCompleteList = new List(); - // Lista hardware completa passata dal chiamante del componente - public static List s_FamilyHardwareList = new List(); - - public int nSashQty - { - get - { - return m_SashList.Count > 0 ? m_SashList.Count : 1; - } - set - { - if (value >= 0 && value <= 4) - { - if (value > m_SashList.Count) - { - // recupero larghezza ultimo - double dLastDimension = 100; - double dNewDimension = 100; - if (m_SashList.Count > 0) - { - dLastDimension = m_SashList[m_SashList.Count - 1].dDimension; - dNewDimension = dLastDimension / (value + 1 - nSashQty); - m_SashList[m_SashList.Count - 1].SetDimension(dNewDimension); - } - else - dNewDimension = dLastDimension / (value + 1 - nSashQty); - // aggiungo area Sash di default - for (var SplitIndex = m_SashList.Count; SplitIndex <= value - 1; SplitIndex++) - { - SashList.Add(new SashDimension(dNewDimension, true, this, SplitIndex + 1)); - } - } - else if (value < m_SashList.Count) - { - if (value > 0) - { - double dLastDimension = 0; - for (var SplitIndex = m_SashList.Count - 1; SplitIndex >= value; SplitIndex += -1) - { - dLastDimension += m_SashList[SplitIndex].dDimension; - SashList.RemoveAt(SplitIndex); - } - dLastDimension += m_SashList[SashList.Count - 1].dDimension; - SashList[SashList.Count - 1].SetDimension(dLastDimension); - if (value == 1) - SashList[0].SetHasHandle(true); - } - else - { - SashList.RemoveAt(0); - } - } - if (m_SashList.Count == 0) - { - Area child = AreaList[0]; - // Se nella singola anta ho uno split - if (!(child is Fill)) - { - child = child.AreaList[0].AreaList[0]; - } - child.SetParentArea(this.ParentArea); - this.ParentArea.AreaList.Remove(this); - this.ParentArea.AreaList.Add(child); - } - // Se ho singola anta - else if (m_SashList.Count == 1) - { - // Metto come padre dell'area nello splitted l'anta stessa - List ContentArea = new List(); - ContentArea.Add(AreaList[0].AreaList[0]); - ContentArea[0].SetParentArea(this); - AreaList.Clear(); - AreaList.Add(ContentArea[0]); - } - else - { - // Se aggiungo ante - if (SashList.Count > AreaList.Count) - { - List ContentArea = new List(); - // Salvo in ContentArea il sottoalbero delle singole aree che mantengo - if (AreaList.Count >= 1 & SashList.Count > AreaList.Count) - { - foreach (Area area in AreaList) - { - if (area is Splitted) - ContentArea.Add(area.AreaList[0]); - else - ContentArea.Add(area); - } - AreaList.Clear(); - } - for (int SplitIndex = AreaList.Count; SplitIndex <= SashList.Count - 1; SplitIndex++) - { - AreaList.Add(Splitted.CreateSplitted(this)); - } - // Riaggiungo i sottoalberi che avevo salvato - for (int i = 0; i < AreaList.Count - 1; i++) - { - if (AreaList.Count == 2) - { - ContentArea[i].SetParentArea(AreaList[i]); - } - AreaList[i].AreaList.Add(ContentArea[i]); - - } - // Aggiungo all'ultimo Splitted l'area di vetro - 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); - } - // Se tolgo anta - else - { - for (int SplitIndex = SashList.Count; SplitIndex <= AreaList.Count() - 1; SplitIndex++) - { - AreaList.Remove(AreaList[AreaList.Count - 1]); - break; - } - } - } - } - RefreshHardwareList(); - RefreshHardwareOptionList(); - SetFirstHardware(); - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); - } - } - internal void SetSashQty(int Qty) - { - if (Qty >= 0 && Qty <= 4) - { - if (Qty > m_SashList.Count) - { - // recupero larghezza ultimo - double dLastDimension = 100; - double dNewDimension = 100; - if (m_SashList.Count > 0) - { - dLastDimension = m_SashList[m_SashList.Count - 1].dDimension; - dNewDimension = dLastDimension / (Qty + 1 - nSashQty); - m_SashList[m_SashList.Count - 1].dDimension = dNewDimension; - } - else - 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, SplitIndex + 1)); - } - else if (Qty < m_SashList.Count) - { - for (var SplitIndex = m_SashList.Count - 1; SplitIndex >= Qty; SplitIndex += -1) - SashList.RemoveAt(SplitIndex); - } - } - } - - private List m_OrientationSashTypeList = new List - { - new IdNameStruct((int)OrientationSash.VERTICAL, "Vertical"), - new IdNameStruct((int)OrientationSash.HORIZONTAL, "Horizontal"), - }; - public List OrientationSashTypeList - { - get - { - return m_OrientationSashTypeList; - } - } - - private OrientationSash m_SelOrientationSashType; - public OrientationSash SelOrientationSashType - { - get - { - return m_SelOrientationSashType; - } - set - { - m_SelOrientationSashType = value; - } - } - - public OrientationSash OrientationSashType - { - get - { - return (OrientationSash)m_SelOrientationSashType; - } - } - internal void SetOrientationSashType(OrientationSash value) - { - m_SelOrientationSashType = value; - } - public int SelOrientationSashTypeIndex - { - get - { - return IdNameStruct.IndFromId((int)m_SelOrientationSashType, m_OrientationSashTypeList); - } - set - { - m_SelOrientationSashType = (OrientationSash)IdNameStruct.IdFromInd(value, m_OrientationSashTypeList); - if (value == 0) - { - m_bIsSashVertical = true; - } - else - { - m_bIsSashVertical = false; - } - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); - } - } - - private bool m_bIsSashVertical; - public bool bIsSashVertical - { - get - { - return m_bIsSashVertical; - } - set - { - m_bIsSashVertical = value; - } - } - internal void SetIsSashVertical(bool IsSashVertical) - { - m_bIsSashVertical = IsSashVertical; - if (IsSashVertical) - { - m_SelOrientationSashType = OrientationSash.VERTICAL; - } - else - { - m_SelOrientationSashType = OrientationSash.HORIZONTAL; - } - } - - private bool m_bIsMeasureGlass; - public bool bIsMeasureGlass - { - get - { - return m_bIsMeasureGlass; - } - set - { - m_bIsMeasureGlass = value; - } - } - internal void SetIsMeasureGlass(bool IsMeasureGlass) - { - m_bIsMeasureGlass = IsMeasureGlass; - } - - private List m_SashList = new List(); - public List SashList - { - get - { - return m_SashList; - } - set - { - m_SashList = value; - } - } - - private SashTypes m_SashType; - public SashTypes SashType - { - get - { - return m_SashType; - } - set - { - m_SashType = value; - } - } - internal void SetSashType(SashTypes SashType) - { - m_SashType = SashType; - } - - private List m_JointList = new List(); - public List JointList - { - get - { - return m_JointList; - } - set - { - m_JointList = value; - } - } - - private bool m_bSashBottomRail; - public bool SashBottomRail - { - get - { - return m_bSashBottomRail; - } - set - { - m_bSashBottomRail = value; - } - } - internal void SetSashBottomRail(bool bBottomRail) - { - m_bSashBottomRail = bBottomRail; - } - - private int m_nSashBottomRailQty; - public int SashBottomRailQty - { - get - { - return m_nSashBottomRailQty; - } - set - { - // Controllo che il valore inserito sia positivo - if (value >= 0) - { - m_nSashBottomRailQty = value; - if (m_nSashBottomRailQty > 0) - { - m_bSashBottomRail = true; - } - else - { - m_bSashBottomRail = false; - } - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); - } - } - } - internal void SetSashBottomRailQty(int nBottomRailQty) - { - m_nSashBottomRailQty = nBottomRailQty; - } - - private bool m_bIsPercentage = true; - public bool bIsPercentage - { - get - { - return m_bIsPercentage; - } - } - - private string m_SelFamilyHardware; - public string SelFamilyHardware - { - get - { - return m_SelFamilyHardware; - } - set - { - m_SelFamilyHardware = value; - RefreshHardwareList(); - RefreshHardwareOptionList(); - SetFirstHardware(); - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); - } - } - - internal string SetSelFamilyHardwareFromIndex(string codHardware) - { - if (string.IsNullOrEmpty(m_SelFamilyHardware)) - { - SelFamilyHardware = (m_HardwareCompleteList - .Where(x => x.Id == codHardware) - .First()).FamilyName; - } - return SelFamilyHardware; - } - - private List m_HardwareList = new List(); - public List HardwareList - { - get - { - return m_HardwareList; - } - } - - private Hardware m_SelHardware; - public Hardware SelHardware - { - get - { - return m_SelHardware; - } - set - { - m_SelHardware = value; - // if (m_SelHardware != null && m_SelHardware.sId != "000000") - // { - // string sHwdOptPath = ""; - // var gf = EgtLuaCreateGlobTable("WDG"); - // var tft = EgtLuaSetGlobIntVar("WDG.AREAID", m_nAreaId); - // var tfy = EgtLuaSetGlobStringVar("WDG.HDWFAVOURITE", value.sId); - // SashDimension HandleSash = m_SashList.FirstOrDefault(x => x.bHasHandle); - // string sHandle = "Dx"; - // switch (GetOpeningSide(HandleSash.OpeningType)) - // { - // case object _ when OpeningSides.LEFT: - // { - // sHandle = "Sx"; - // break; - // } - - // case object _ when OpeningSides.RIGHT: - // { - // sHandle = "Dx"; - // break; - // } - // } - // var tfd = EgtLuaSetGlobStringVar("WDG.HDWHANDLE", sHandle); - // var tlt = EgtLuaCallFunction("WinCreate_GetHardwareOptionPath"); - // var tltf = EgtLuaGetGlobStringVar("WDG.HWDOPTPATH", sHwdOptPath); - // if (!string.IsNullOrWhiteSpace(sHwdOptPath)) - // { - // XmlSerializer serializer = new XmlSerializer(typeof(ParametriOpzioni)); - // ParametriOpzioni HwdOptions = null/* TODO Change to default(_) if this is not a reference type */; - // string sHdwOptPath = Path.ChangeExtension(sHwdOptPath, ".opt"); - // bool bHdwOptFound = false; - // for (var WaitIndex = 0; WaitIndex <= 100; WaitIndex++) - // { - // if (File.Exists(sHdwOptPath)) - // { - // bHdwOptFound = true; - // break; - // } - // System.Threading.Thread.Sleep(100); - // } - // if (bHdwOptFound) - // { - // string sHwdOptText = ""; - // try - // { - // sHwdOptText = File.ReadAllText(sHdwOptPath); - // } - // catch (Exception ex) - // { - // EgtOutLog("Hardware file opt not found or read!"); - // } - // if (!string.IsNullOrWhiteSpace(sHwdOptText)) - // { - // using (TextReader reader = new StringReader(sHwdOptText)) - // { - // HwdOptions = serializer.Deserialize(reader); - // } - // if (!IsNothing(HwdOptions)) - // { - // m_HwdOptionList.Clear(); - // foreach (var HdwOption in HwdOptions.Items) - // m_HwdOptionList.Add(new AGBOption(HdwOption)); - // NotifyPropertyChanged(nameof(HwdOptionList)); - // } - // } - // } - // var ud = EgtLuaResetGlobVar("WDG"); - // } - // } - } - } - - internal void SetSelHardware(Hardware value) - { - m_SelHardware = value; - } - - internal void SetSelHardwareFromId(string sId) - { - if (m_HardwareList.Count == 0) - m_SelHardware = m_HardwareCompleteList.FirstOrDefault(x => x.Id.Equals(sId)) ?? new Hardware("", "", "", Enums.OpeningTypes.Null, "", 0, 0); - else - m_SelHardware = m_HardwareList.FirstOrDefault(x => x.Id.Equals(sId)) ?? new Hardware("", "", "", Enums.OpeningTypes.Null, "", 0, 0); - if (m_SelHardware == null) - m_SelHardware = m_HardwareList[0]; - //SelFamilyHardware = m_SelHardware.FamilyName; - } - - public string SelHardwareFromId - { - get - { - return m_SelHardware.Id; - } - set - { - m_SelHardware = m_HardwareList.FirstOrDefault(x => !string.IsNullOrEmpty(value) && x.Id.Equals(value)) ?? new Hardware("", "", "", Enums.OpeningTypes.Null, "", 0, 0); - ParentWindow.OnUpdatePreview(ParentWindow.sSerialized()); - } - } - - internal void SetFirstHardware() - { - if (m_HardwareList.Count > 0) - { - m_SelHardware = m_HardwareList[0]; - } - } - - private List m_HwdOptionList = new List(); - public List HwdOptionList - { - get - { - return m_HwdOptionList; - } - } - - public Sash(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow) - { - } - - 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); - newSash.SetIsSashVertical(true); - for (var JointIndex = 0; JointIndex <= 3; JointIndex++) - newSash.JointList.Add(new Joint(newSash, JointIndex + 1, Joints.FULL_H)); - newSash.SetSashBottomRail(false); - newSash.SetSashBottomRailQty(0); - newSash.SelFamilyHardware = Sash.s_FamilyHardwareList.First(); - newSash.RefreshHardwareList(); - newSash.RefreshHardwareOptionList(); - newSash.SetFirstHardware(); - return newSash; - } - private string FindSashShape() - { - return "Rectangular"; - } - - internal Enums.OpeningTypes GetOpeningType(Openings OpeningType) - { - switch (OpeningType) - { - case Openings.TURNONLY_LEFT: - case Openings.TURNONLY_RIGHT: - { - return Enums.OpeningTypes.TurnOnly; - } - - case Openings.TILTTURN_LEFT: - case Openings.TILTTURN_RIGHT: - { - return Enums.OpeningTypes.TiltTurn; - } - - case Openings.TILTONLY_TOP: - case Openings.TILTONLY_BOTTOM: - { - return Enums.OpeningTypes.TiltOnly; - } - - case Openings.PIVOT: - { - return Enums.OpeningTypes.Pivot; - } - - case Openings.FIXED: - { - return Enums.OpeningTypes.Fixed; - } - - case Openings.COMPLANARSLIDE_LEFT: - case Openings.COMPLANARSLIDE_RIGHT: - { - return Enums.OpeningTypes.ComplanarSlide; - } - - case Openings.LIFTSLIDE_LEFT: - case Openings.LIFTSLIDE_RIGHT: - { - return Enums.OpeningTypes.LiftSlide; - } - - default: - { - return Enums.OpeningTypes.Null; - } - } - } - private Enums.OpeningTypes ConvertOpeningType() - { - var answ = Enums.OpeningTypes.Null; - if (m_SashList.Count > 1) - { - for (int i = 0; i < m_SashList.Count; i++) - { - if (m_SashList[i].bHasHandle) - { - answ = GetOpeningType(m_SashList[i].OpeningType); - } - - } - } - else - { - answ = GetOpeningType(m_SashList[0].OpeningType); - } - return answ; - } - - public void RefreshHardwareList() - { - if (m_HardwareCompleteList != null && m_HardwareCompleteList.Count > 0) - { - m_HardwareList.Clear(); - string sSashShape = FindSashShape(); - Enums.OpeningTypes sOpeningType = ConvertOpeningType(); - var iComp = StringComparison.InvariantCultureIgnoreCase; - var rawList = m_HardwareCompleteList - .Where(x => x.Id == "000000" || - (!string.IsNullOrEmpty(m_SelFamilyHardware) && x.FamilyName.Equals(m_SelFamilyHardware, iComp) && x.SashQty == nSashQty && x.Shape.Equals(sSashShape, iComp) && x.OpeningType == sOpeningType) - ) - .ToList(); - if (rawList != null && rawList.Count > 0) - { - m_HardwareList = new List(rawList); - } - else - { - m_HardwareList = new List(); - } - } - } - - internal void RefreshHardwareOptionList() - { - m_HwdOptionList.Clear(); - } - - internal OpeningSides GetOpeningSide(Openings OpeningType) - { - switch (OpeningType) - { - case Openings.TURNONLY_LEFT: - case Openings.TILTTURN_LEFT: - case Openings.TILTONLY_TOP: - case Openings.COMPLANARSLIDE_LEFT: - case Openings.LIFTSLIDE_LEFT: - { - return OpeningSides.LEFT; - } - - case Openings.TURNONLY_RIGHT: - case Openings.TILTTURN_RIGHT: - case Openings.TILTONLY_BOTTOM: - case Openings.COMPLANARSLIDE_RIGHT: - case Openings.LIFTSLIDE_RIGHT: - { - return OpeningSides.RIGHT; - } - - default: - { - return OpeningSides.NULL; - } - } - } - - 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); - newSash.SetIsSashVertical(bIsSashVertical); - newSash.SetOrientationSashType(OrientationSashType); - newSash.SetSashBottomRailQty(SashBottomRailQty); - newSash.SetSelFamilyHardwareFromIndex(SelHardware.Id); - newSash.RefreshHardwareList(); - newSash.RefreshHardwareOptionList(); - newSash.SetSelHardware(SelHardware); - for (int i = 0; i < SashList.Count; i++) - { - //Cancello SashDimension di default e aggiungo la copia - newSash.SashList.RemoveAt(i); - SashDimension newSashDim = SashList[i].Copy(); - newSash.SashList.Insert(i, newSashDim); - } - foreach (var item in JointList) - { - Joint newJoint = item.Copy(); - newSash.JointList.Add(newJoint); - } - foreach (var item in AreaList) - { - Area newArea = item.Copy(newSash); - newSash.AreaList.Add(newArea); - } - 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() - { - 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) - JsonSash.JointList.Add(Joint.Serialize()); - foreach (var Area in AreaList) - JsonSash.AreaList.Add(Area.Serialize()); - return JsonSash; - } - } - - public class Split : Area - { - private bool m_bSplitStartVert = true; - public bool bSplitStartVert - { - get - { - return m_bSplitStartVert; - } - set - { - 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) - { - for (var SplitIndex = m_SplitVertList.Count - 1; SplitIndex >= value; SplitIndex += -1) - m_SplitVertList.RemoveAt(SplitIndex); - if (nSplitQtyHoriz == 0) - { - ParentArea.AreaList.Remove(this); - Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS); - newFill.SetAreaType(AreaTypes.FILL); - ParentArea.AreaList.Add(newFill); - } - else - SetSplitShape(SplitShapes.HORIZONTAL); - } - else - { - // Ricalcolo dimensioni aggiungendo split - if (value > m_SplitVertList.Count - 1) - { - // 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)); - } - else if (value == 0) - { - 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); - } - } - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); - } - } - internal void SetSplitQtyVert(int QtyVert, bool NotifyProperty = false) - { - if (QtyVert > m_SplitVertList.Count) - { - // recupero larghezza ultimo - double dLastDimension = 100; - double dNewDimension = 100; - if (m_SplitVertList.Count > 0) - { - dLastDimension = m_SplitVertList[m_SplitVertList.Count - 1].dDimension; - dNewDimension = dLastDimension / (QtyVert + 1 - nSplitQtyVert); - m_SplitVertList[m_SplitVertList.Count - 1].dDimension = dNewDimension; - } - else - dNewDimension = dLastDimension / (QtyVert + 1 - nSplitQtyVert); - // aggiungo area Split di default - for (var SplitIndex = m_SplitVertList.Count; SplitIndex <= QtyVert; SplitIndex++) - m_SplitVertList.Add(new SplitDimension(dNewDimension, true, this, true)); - } - else if (QtyVert < m_SplitVertList.Count) - { - 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); - } - } - - private List m_SplitShapeList = new List - { - new IdNameStruct((int)SplitShapes.VERTICAL, "Vertical"), - new IdNameStruct((int)SplitShapes.HORIZONTAL, "Horizontal"), - new IdNameStruct((int)SplitShapes.GRID, "Grid"), - new IdNameStruct((int)SplitShapes.CUSTOM, "Custom") - }; - public List SplitShapeList - { - get - { - return m_SplitShapeList; - } - } - - private SplitShapes m_SelSplitShape; - public int SelSplitShapeIndex - { - get - { - return IdNameStruct.IndFromId((int)m_SelSplitShape, m_SplitShapeList); - } - 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()); - } - } - internal void SetSplitShape(SplitShapes Value, bool NotifyProperty = false) - { - m_SelSplitShape = Value; - } - internal SplitShapes SelSplitShape - { - get - { - return m_SelSplitShape; - } - } - - private bool m_bIsPercentage = true; - public bool bIsPercentage - { - get - { - return m_bIsPercentage; - } - } - - private List m_SplitPositionList = new List(); - public List SplitPositionList - { - get - { - return m_SplitPositionList; - } - set - { - m_SplitPositionList = value; - } - } - - private List m_SplitVertList = new List(); - public List SplitVertList - { - get - { - return m_SplitVertList; - } - set - { - m_SplitVertList = value; - } - } - - private List m_SplitHorizList = new List(); - public List SplitHorizList - { - get - { - return m_SplitHorizList; - } - set - { - m_SplitHorizList = value; - } - } - - public Split(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow) - { - } - - 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; - } - - public override Split Copy(Area newParentArea) - { - Split newSplit = new Split(newParentArea, ParentWindow); - 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) - { - Area a = item.Copy(newSplit); - newSplit.AreaList.Add(a); - } - 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() - { - 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; - } - } - - public class Splitted : Area - { - public Splitted(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow) - { - } - - internal static Splitted CreateSplitted(Area ParentArea) - { - Splitted Splitted = new Splitted(ParentArea, ParentArea.ParentWindow); - AddCounterGroup(); - Splitted.SetIdGroup(nCounterGroup); - Splitted.SetAreaType(AreaTypes.SPLITTED); - return Splitted; - } - - public override Splitted Copy(Area newParentArea) - { - Splitted newSplitted = new Splitted(newParentArea, ParentWindow); - AddCounterGroup(); - newSplitted.SetIdGroup(nCounterGroup); - newSplitted.SetAreaType(AreaType); - foreach (var item in AreaList) - { - Area a = item.Copy(newSplitted); - newSplitted.AreaList.Add(a); - } - return newSplitted; - } - - internal override JsonArea Serialize() - { - if (nCounterGroup < IdGroup) - Area.nCounterGroup = IdGroup; - JsonSplitted JsonSplitted = new JsonSplitted(IdGroup); - foreach (var Area in AreaList) - JsonSplitted.AreaList.Add(Area.Serialize()); - return JsonSplitted; - } - } - - public class Fill : Area - { - private List m_FillTypeList = new List - { - new IdNameStruct((int)FillTypes.GLASS, "SvgPreview"), - new IdNameStruct((int)FillTypes.WOOD, "Wood") - }; - public List FillTypeList - { - get - { - return m_FillTypeList; - } - } - - private FillTypes m_SelFillType; - public FillTypes SelFillType - { - get - { - return m_SelFillType; - } - set - { - m_SelFillType = value; - } - } - - public FillTypes FillType - { - get - { - return (FillTypes)m_SelFillType; - } - } - internal void SetFillType(FillTypes value) - { - m_SelFillType = value; - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); - } - public int SelFillTypeIndex - { - get - { - return IdNameStruct.IndFromId((int)m_SelFillType, m_FillTypeList); - } - set - { - m_SelFillType = (FillTypes)IdNameStruct.IdFromInd(value, m_FillTypeList); - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); - } - } - - public Fill(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow) - { - } - - 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; - } - - 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; - } - - internal override JsonArea Serialize() - { - if (nCounterGroup < IdGroup) - Area.nCounterGroup = IdGroup; - JsonFill JsonFill = new JsonFill(FillType, IdGroup); - foreach (var Area in AreaList) - JsonFill.AreaList.Add(Area.Serialize()); - return JsonFill; - } - } - - public class Joint - { - protected Area m_ParentArea; - public Area ParentArea - { - get - { - return m_ParentArea; - } - } - - private int m_nIndex; - public int nIndex - { - get - { - return m_nIndex; - } - } - - private List m_JointTypeList = new List - { - new IdNameStruct((int)Joints.ANGLED, "Angled"), - new IdNameStruct((int)Joints.FULL_H, "Full H"), - new IdNameStruct((int)Joints.FULL_V, "Full V") - }; - public List JointTypeList - { - get - { - return m_JointTypeList; - } - } - - private Joints m_SelJointType; - public int SelJointTypeIndex - { - get - { - return IdNameStruct.IndFromId((int)m_SelJointType, m_JointTypeList); - } - set - { - m_SelJointType = (Joints)IdNameStruct.IdFromInd(value, m_JointTypeList); - m_ParentArea.ParentWindow.OnUpdatePreview(m_ParentArea.ParentWindow.sSerialized()); - } - } - public Joints SelJointType - { - get - { - return m_SelJointType; - } - set - { - m_SelJointType = value; - } - } - internal void SetSelJointType(Joints value) - { - m_SelJointType = value; - //NotifyPropertyChanged(nameof(SelJointTypeIndex)); - } - - public Joint Copy() - { - Joint newJoint = new Joint(ParentArea, nIndex, SelJointType); - return newJoint; - } - - public Joint(Area ParentArea, int nIndex, Joints SelJointType) - { - m_ParentArea = ParentArea; - m_nIndex = nIndex; - m_SelJointType = SelJointType; - } - - internal JsonJoint Serialize() - { - JsonJoint JsonJoint = new JsonJoint(m_nIndex, m_SelJointType); - return JsonJoint; - } - } - - public partial class ParametriOpzioni - { - public enum HDWOPTIONTYPES : int - { - TEXT = 1, - LENGHT = 2, - COMBO = 3 - } - - protected HDWOPTIONTYPES m_Type; - public HDWOPTIONTYPES Type - { - get - { - return m_Type; - } - } - - private string m_sName; - public string sName - { - get - { - return m_sName; - } - } - - private string m_sDescription; - public string sDescription - { - get - { - return m_sDescription; - } - } - - private Visibility m_OptVisibility; - public Visibility OptVisibility - { - get - { - return m_OptVisibility; - } - } - - public ParametriOpzioni(ParametriOpzioniParametri HdwOptionParam) - { - m_sName = HdwOptionParam.NomeParametro; - m_sDescription = HdwOptionParam.DescrizioneParametro; - m_OptVisibility = Visibility.VISIBLE; // If(HdwOptionParam.Visible.ToLower = "true", Visibility.Visible, Visibility.Collapsed) - } - } - - public class AGBOptionCombo : ParametriOpzioni - { - private List m_ValueList = new List(); - public List ValueList - { - get - { - return m_ValueList; - } - } - - private AGBOptionParameter m_sValue; - public AGBOptionParameter sValue - { - get - { - return m_sValue; - } - set - { - m_sValue = value; - } - } - - public AGBOptionCombo(ParametriOpzioniParametri HdwOptionParam) : base(HdwOptionParam) - { - m_Type = HDWOPTIONTYPES.COMBO; - foreach (var Value in HdwOptionParam.Opzioni) - m_ValueList.Add(new AGBOptionParameter(Value.Valore, Value.DescrizioneOpzione)); - m_sValue = m_ValueList.FirstOrDefault(x => x.sValue == HdwOptionParam.ValoreCorrente) ?? new AGBOptionParameter("", ""); - } - } - - public class AGBOptionParameter - { - private string m_sValue; - public string sValue - { - get - { - return m_sValue; - } - } - - private string m_sDescription; - public string sDescription - { - get - { - return m_sDescription; - } - } - - public AGBOptionParameter(string sValue, string sDescription) - { - m_sValue = sValue; - m_sDescription = sDescription; - } - } - - public class AGBOptionText : ParametriOpzioni - { - private string m_sValue; - public string sValue - { - get - { - return m_sValue; - } - set - { - m_sValue = value; - } - } - - public AGBOptionText(ParametriOpzioniParametri HdwOptionParam) : base(HdwOptionParam) - { - m_Type = HDWOPTIONTYPES.TEXT; - m_sValue = HdwOptionParam.ValoreCorrente; - } - } - - public class FrameDimension - { - // valore massimo e minimo della dimensione del frame - int MaxDim = 4000; - int MinDim = 600; - - protected Frame m_ParentFrame; - public Frame ParentFrame - { - get - { - return m_ParentFrame; - } - } - - private bool m_bIsLen = false; - - private int m_nIndex; - public int nIndex - { - get - { - return m_nIndex; - } - } - - private string m_sName; - public string sName - { - get - { - return m_sName; - } - } - - private double m_dValue; - public double dValue - { - get - { - return m_dValue; - } - set - { - m_dValue = value; - if (value > MaxDim) - { - m_dValue = MaxDim; - } - else if (value < MinDim) - { - m_dValue = MinDim; - } - m_ParentFrame.ParentWindow.OnUpdatePreview(m_ParentFrame.ParentWindow.sSerialized()); - } - } - - public FrameDimension(Frame ParentFrame, int nIndex, string sName, double dValue, bool bIsLen) - { - m_ParentFrame = ParentFrame; - m_nIndex = nIndex; - m_sName = sName; - m_dValue = dValue; - m_bIsLen = bIsLen; - } - - internal JsonFrameDimension Serialize() - { - JsonFrameDimension JsonFrameDimension = new JsonFrameDimension(m_nIndex, m_sName, m_dValue); - return JsonFrameDimension; - } - } - - public class SashDimension - { - // reference - private Sash m_Parent; - - private int m_nSashId; - public int nSashId - { - get - { - return m_nSashId; - } - } - - private bool m_bIsRelative = false; - public bool bIsRelative - { - get - { - return m_bIsRelative; - } - } - - private List m_OpeningTypeList = new List - { - new IdNameStruct((int)Openings.TURNONLY_LEFT, ">"), - new IdNameStruct((int)Openings.TURNONLY_RIGHT, "<"), - new IdNameStruct((int)Openings.TILTTURN_LEFT, ">*"), - new IdNameStruct((int)Openings.TILTTURN_RIGHT, "<*"), - new IdNameStruct((int)Openings.TILTONLY_TOP, "˄"), - new IdNameStruct((int)Openings.TILTONLY_BOTTOM, "˅"), - new IdNameStruct((int)Openings.PIVOT, "◊"), - new IdNameStruct((int)Openings.FIXED, "X"), - new IdNameStruct((int)Openings.COMPLANARSLIDE_LEFT, "-→"), - new IdNameStruct((int)Openings.COMPLANARSLIDE_RIGHT, "←-"), - new IdNameStruct((int)Openings.LIFTSLIDE_LEFT, "┌→"), - new IdNameStruct((int)Openings.LIFTSLIDE_RIGHT, "←┐") - }; - public List OpeningTypeList - { - get - { - return m_OpeningTypeList; - } - } - - private Openings m_SelOpeningType; - public Openings SelOpeningType - { - get - { - return m_SelOpeningType; - } - set - { - m_SelOpeningType = value; - m_Parent.RefreshHardwareList(); - m_Parent.RefreshHardwareOptionList(); - m_Parent.SetFirstHardware(); - } - } - public Openings OpeningType - { - get - { - return (Openings)m_SelOpeningType; - } - } - internal void SetOpeningType(Openings value) - { - m_SelOpeningType = value; - } - public int SelOpeningTypeIndex - { - get - { - return IdNameStruct.IndFromId((int)m_SelOpeningType, m_OpeningTypeList); - } - set - { - m_SelOpeningType = (Openings)IdNameStruct.IdFromInd(value, m_OpeningTypeList); - m_Parent.RefreshHardwareList(); - m_Parent.RefreshHardwareOptionList(); - m_Parent.SetFirstHardware(); - m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); - } - } - - private bool m_bHasHandle; - public bool bHasHandle - { - get - { - return m_bHasHandle; - } - set - { - m_bHasHandle = value; - m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); - } - } - internal void SetHasHandle(bool value) - { - m_bHasHandle = value; - } - - private double m_dDimension; - public double dDimension - { - get - { - return m_dDimension; - } - set - { - // Controllo che il valore inserito sia compreso tra 0 e 100 - if (value > 0 && value < 100) - { - // se sono in percentuale - if (m_bIsRelative) - { - // verifico se ci sono assoluti - List RelativeDimList = m_Parent.SashList.Where(x => x.bIsRelative).ToList(); - if (RelativeDimList.Count > 0) - { - if (m_Parent.bIsPercentage) - { - int nIndex = RelativeDimList.IndexOf(this); - // se diminuisce dimensione - if (value < m_dDimension) - { - if (nIndex < RelativeDimList.Count - 1) - RelativeDimList[nIndex + 1].SetDimension(RelativeDimList[nIndex + 1].dDimension + (m_dDimension - value)); - else if (RelativeDimList.Count > 1) - RelativeDimList[nIndex - 1].SetDimension(RelativeDimList[nIndex - 1].dDimension + (m_dDimension - value)); - else - { - m_dDimension = 100; - return; - } - } - // se aumenta dimensione - else - { - double dRes = value; - // se non ultima anta - if (nIndex < RelativeDimList.Count - 1) - { - for (var nInd = 0; nInd <= nIndex - 1; nInd++) - dRes += RelativeDimList[nInd].dDimension; - dRes = (100 - dRes) / (RelativeDimList.Count - nIndex - 1); - for (var Ind = nIndex + 1; Ind <= RelativeDimList.Count - 1; Ind++) - RelativeDimList[Ind].SetDimension(dRes); - } - // se ultima anta - else if (RelativeDimList.Count > 1) - { - if (RelativeDimList.Count > 2) - { - for (var Ind = 0; Ind <= nIndex - 2; Ind++) - dRes += RelativeDimList[Ind].dDimension; - } - - //for (var Ind = nIndex + 1; Ind <= RelativeDimList.Count - 1; Ind++) - // dRes += RelativeDimList[Ind].dDimension; - dRes = (100 - dRes); - RelativeDimList[nIndex - 1].SetDimension(dRes); - //for (var nInd = 0; nInd <= nIndex - 1; nInd++) - // RelativeDimList[nInd].SetDimension(dRes); - } - else - { - m_dDimension = 100; - return; - } - } - } - } - } - m_dDimension = value; - m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); - } - } - } - internal void SetDimension(double dValue) - { - m_dDimension = dValue; - } - - public SashDimension Copy() - { - 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, 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; - // assegno tipo di anta - if (Parent.SashList.Count == 0) - SetOpeningType(Openings.TILTTURN_LEFT); - else if (Parent.SashList.Count == 1) - { - switch (Parent.SashList[0].OpeningType) - { - case Openings.TURNONLY_LEFT: - { - SetOpeningType(Openings.TURNONLY_RIGHT); - break; - } - - case Openings.TURNONLY_RIGHT: - { - SetOpeningType(Openings.TURNONLY_LEFT); - break; - } - - case Openings.TILTTURN_LEFT: - { - SetOpeningType(Openings.TURNONLY_RIGHT); - break; - } - - case Openings.TILTTURN_RIGHT: - { - SetOpeningType(Openings.TURNONLY_LEFT); - break; - } - - case Openings.TILTONLY_TOP: - { - SetOpeningType(Openings.TILTONLY_BOTTOM); - break; - } - - case Openings.TILTONLY_BOTTOM: - { - SetOpeningType(Openings.TILTONLY_TOP); - break; - } - - case Openings.COMPLANARSLIDE_LEFT: - { - SetOpeningType(Openings.COMPLANARSLIDE_RIGHT); - break; - } - - case Openings.COMPLANARSLIDE_RIGHT: - { - SetOpeningType(Openings.COMPLANARSLIDE_LEFT); - break; - } - - case Openings.LIFTSLIDE_LEFT: - { - SetOpeningType(Openings.LIFTSLIDE_RIGHT); - break; - } - - case Openings.LIFTSLIDE_RIGHT: - { - SetOpeningType(Openings.LIFTSLIDE_LEFT); - break; - } - } - } - else - SetOpeningType(Parent.SashList[Parent.SashList.Count - 1].OpeningType); - } - - internal JsonSashDimension Serialize() - { - JsonSashDimension JsonSashDimension = new JsonSashDimension(OpeningType, m_bHasHandle, m_dDimension, m_nSashId); - return JsonSashDimension; - } - } - - public class SplitDimension - { - // reference - private Split m_Parent; - - private bool m_bIsRelative = false; - public bool bIsRelative - { - get - { - return m_bIsRelative; - } - } - internal void SetIsRelative(bool value) - { - 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 - { - get - { - return m_dDimension; - } - set - { - // Controllo che il valore inserito sia compreso tra 0 e 100 - if (value > 0 && value < 100) - { - // 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(); - if (RelativeDimList.Count > 0) - { - if (m_Parent.bIsPercentage) - { - int nIndex = RelativeDimList.IndexOf(this); - if (value < m_dDimension) - { - if (nIndex < RelativeDimList.Count - 1) - RelativeDimList[nIndex + 1].SetDimension(RelativeDimList[nIndex + 1].dDimension + (m_dDimension - value)); - else if (RelativeDimList.Count > 1) - RelativeDimList[nIndex - 1].SetDimension(RelativeDimList[nIndex - 1].dDimension + (m_dDimension - value)); - else - { - m_dDimension = 100; - return; - } - } - else - { - double dRes = value; - if (nIndex < RelativeDimList.Count - 1) - { - for (var nInd = 0; nInd <= nIndex - 1; nInd++) - dRes += RelativeDimList[nInd].dDimension; - dRes = (100 - dRes) / (RelativeDimList.Count - nIndex - 1); - if (dRes != 0) - { - for (var Ind = nIndex + 1; Ind <= RelativeDimList.Count - 1; Ind++) - RelativeDimList[Ind].SetDimension(dRes); - } - else - return; - } - else if (RelativeDimList.Count > 1) - { - if (RelativeDimList.Count > 2) - { - for (var Ind = 0; Ind <= nIndex - 2; Ind++) - dRes += RelativeDimList[Ind].dDimension; - } - dRes = (100 - dRes); - if (dRes != 0) - RelativeDimList[nIndex - 1].SetDimension(dRes); - else - return; - } - else - { - m_dDimension = 100; - return; - } - } - } - else - { - } - } - } - m_dDimension = value; - m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); - } - - } - } - internal void SetDimension(double dValue) - { - m_dDimension = dValue; - } - - public SplitDimension Copy() - { - SplitDimension newSplitDim = new SplitDimension(dDimension, bIsRelative, m_Parent, bIsVertListDim); - return newSplitDim; - } - 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() - { - JsonSplitDimension JsonSplitDimension = new JsonSplitDimension(m_bIsRelative, m_dDimension); - return JsonSplitDimension; - } - } - - public struct IdNameStruct - { - private int m_Id; - - private string m_Name; - - public int Id - { - get - { - return m_Id; - } - set - { - m_Id = value; - } - } - - public string Name - { - get - { - return m_Name; - } - set - { - m_Name = value; - } - } - - public IdNameStruct(int Id, string Name) - { - this = default(IdNameStruct); - m_Id = Id; - m_Name = Name; - } - - public override string ToString() - { - return Name; - } - - public static int IndFromId(int Id, List List) - { - checked - { - int num = List.Count - 1; - for (int i = 0; i <= num; i++) - { - if (List[i].Id == Id) - { - return i; - } - } - - return 0; - } - } - - public static int IdFromInd(int Ind, List List) - { - return List[Ind].Id; - } - - public static int IndFromId(int Id, List List) - { - checked - { - int num = List.Count - 1; - for (int i = 0; i <= num; i++) - { - if (List[i] is IdNameStruct && ((IdNameStruct)List[i]).Id == Id) - { - return i; - } - } - - return 0; - } - } - - public static int IdFromInd(int Ind, List List) - { - if (List[Ind] is IdNameStruct) - { - return ((IdNameStruct)List[Ind]).Id; - } - - return 0; - } - - public static int IdFromName(string Name, List List) - { - checked - { - int num = List.Count - 1; - for (int i = 0; i <= num; i++) - { - if (string.Compare(((IdNameStruct)List[i]).Name, Name, false) == 0) - { - return ((IdNameStruct)List[i]).Id; - } - } - return 0; - } - } - } - -} diff --git a/WebWindowComplex/_Imports.razor b/WebWindowComplex/_Imports.razor index 7728512..ea6d3fc 100644 --- a/WebWindowComplex/_Imports.razor +++ b/WebWindowComplex/_Imports.razor @@ -1 +1,4 @@ @using Microsoft.AspNetCore.Components.Web +@using WebWindowComplex +@using WebWindowComplex.Compo +@using WebWindowComplex.Models \ No newline at end of file diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index 60ecadd..8f07910 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -88,124 +88,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -