From 7eaeca2bce3ae8aac53a089553a636e2141388fa Mon Sep 17 00:00:00 2001 From: Annamaria Sassi Date: Wed, 16 Jul 2025 19:06:10 +0200 Subject: [PATCH] =?UTF-8?q?-=20modificata=20funzionalit=C3=A0=20bottone=20?= =?UTF-8?q?save=20-=20aggiunti=20nuovi=20esempi=20JWD=20-=20aggiunto=20SVG?= =?UTF-8?q?=20-=20modificati=20titoli=20tabs=20-=20modificata=20tabs=20Fra?= =?UTF-8?q?me=20-=20aggiunti=20metodi=20deserialize?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Test.UI/Components/Pages/Home.razor.cs | 4 +- .../Test.UI/Data/FinDueAnteBottomFisso.jwd | 132 ++++ Test.UI/Test.UI/Data/FinestraSplitVert.jwd | 79 +++ .../Test.UI/Data/FinestraSplitVertOriz.jwd | 141 +++++ Test.UI/Test.UI/Data/Setup.json | 16 + .../DTO/TemplateSelectorDTO.cs | 2 +- WebWindowConfigurator/Json/JsonUtility.cs | 149 +++-- WebWindowConfigurator/Template.cs | 14 +- WebWindowConfigurator/WebWindowMaker.razor | 165 +++-- WebWindowConfigurator/WebWindowMaker.razor.cs | 27 +- WebWindowConfigurator/Window.cs | 568 +++++++++++++++--- 11 files changed, 1051 insertions(+), 246 deletions(-) create mode 100644 Test.UI/Test.UI/Data/FinDueAnteBottomFisso.jwd create mode 100644 Test.UI/Test.UI/Data/FinestraSplitVert.jwd create mode 100644 Test.UI/Test.UI/Data/FinestraSplitVertOriz.jwd diff --git a/Test.UI/Test.UI/Components/Pages/Home.razor.cs b/Test.UI/Test.UI/Components/Pages/Home.razor.cs index a1623da..b7c4567 100644 --- a/Test.UI/Test.UI/Components/Pages/Home.razor.cs +++ b/Test.UI/Test.UI/Components/Pages/Home.razor.cs @@ -10,7 +10,7 @@ namespace Test.UI.Components.Pages { #region Public Properties - public Template SelTemplate { get; set; } = new Template(0, "---SELECT---", ""); + public Template SelTemplate { get; set; } = new Template(0, "---SELECT---", "",""); #endregion Public Properties @@ -73,7 +73,7 @@ namespace Test.UI.Components.Pages { rawVal = File.ReadAllText(selTemp.TemplFile); } - SelTemplate = new Template(selTemp.Index, selTemp.Description, rawVal); + SelTemplate = new Template(selTemp.Index, selTemp.Description, rawVal, selTemp.TemplSVG); } #endregion Private Methods diff --git a/Test.UI/Test.UI/Data/FinDueAnteBottomFisso.jwd b/Test.UI/Test.UI/Data/FinDueAnteBottomFisso.jwd new file mode 100644 index 0000000..36f9952 --- /dev/null +++ b/Test.UI/Test.UI/Data/FinDueAnteBottomFisso.jwd @@ -0,0 +1,132 @@ +{ + "ProfilePath": "Profilo78", + "AreaList": [ + { + "Shape": "RECTANGLE", + "DimensionList": [ + { + "nIndex": 1, + "sName": "Width", + "dValue": 1500.0 + }, + { + "nIndex": 2, + "sName": "Height", + "dValue": 2100.0 + } + ], + "JointList": [ + { + "nIndex": 1, + "JointType": "FULL_H" + }, + { + "nIndex": 2, + "JointType": "FULL_H" + }, + { + "nIndex": 3, + "JointType": "FULL_H" + }, + { + "nIndex": 4, + "JointType": "FULL_H" + } + ], + "BottomRail": false, + "BottomRailQty": 0, + "AreaList": [ + { + "SplitShape": "HORIZONTAL", + "SplitPositionList": [ + { + "bIsRelative": true, + "dDimension": 40.0 + }, + { + "bIsRelative": true, + "dDimension": 60.0 + } + ], + "AreaList": [ + { + "AreaList": [ + { + "FillType": "GLASS", + "AreaList": [], + "AreaType": "FILL" + } + ], + "AreaType": "SPLITTED" + }, + { + "AreaList": [ + { + "bIsSashVertical": true, + "SashList": [ + { + "OpeningType": "TURNONLY_LEFT", + "bHasHandle": false, + "dDimension": 50.0 + }, + { + "OpeningType": "TILTTURN_RIGHT", + "bHasHandle": true, + "dDimension": 50.0 + } + ], + "SashType": "NULL", + "JointList": [ + { + "nIndex": 1, + "JointType": "FULL_H" + }, + { + "nIndex": 2, + "JointType": "FULL_H" + }, + { + "nIndex": 3, + "JointType": "FULL_H" + }, + { + "nIndex": 4, + "JointType": "FULL_H" + } + ], + "Hardware": "000000", + "AreaList": [ + { + "AreaList": [ + { + "FillType": "GLASS", + "AreaList": [], + "AreaType": "FILL" + } + ], + "AreaType": "SPLITTED" + }, + { + "AreaList": [ + { + "FillType": "GLASS", + "AreaList": [], + "AreaType": "FILL" + } + ], + "AreaType": "SPLITTED" + } + ], + "AreaType": "SASH" + } + ], + "AreaType": "SPLITTED" + } + ], + "AreaType": "SPLIT" + } + ], + "AreaType": "FRAME" + } + ] +} \ No newline at end of file diff --git a/Test.UI/Test.UI/Data/FinestraSplitVert.jwd b/Test.UI/Test.UI/Data/FinestraSplitVert.jwd new file mode 100644 index 0000000..b8dc284 --- /dev/null +++ b/Test.UI/Test.UI/Data/FinestraSplitVert.jwd @@ -0,0 +1,79 @@ +{ + "ProfilePath": "Profilo78", + "AreaList": [ + { + "Shape": "RECTANGLE", + "DimensionList": [ + { + "nIndex": 1, + "sName": "Width", + "dValue": 1500.0 + }, + { + "nIndex": 2, + "sName": "Height", + "dValue": 1800.0 + } + ], + "JointList": [ + { + "nIndex": 1, + "JointType": "FULL_H" + }, + { + "nIndex": 2, + "JointType": "FULL_H" + }, + { + "nIndex": 3, + "JointType": "FULL_H" + }, + { + "nIndex": 4, + "JointType": "FULL_H" + } + ], + "BottomRail": false, + "BottomRailQty": 0, + "AreaList": [ + { + "SplitShape": "VERTICAL", + "SplitPositionList": [ + { + "bIsRelative": true, + "dDimension": 50.0 + }, + { + "bIsRelative": true, + "dDimension": 50.0 + } + ], + "AreaList": [ + { + "AreaList": [ + { + "FillType": "GLASS", + "AreaList": [], + "AreaType": "FILL" + } + ], + "AreaType": "SPLITTED" + }, + { + "AreaList": [ + { + "FillType": "GLASS", + "AreaList": [], + "AreaType": "FILL" + } + ], + "AreaType": "SPLITTED" + } + ], + "AreaType": "SPLIT" + } + ], + "AreaType": "FRAME" + } + ] +} \ No newline at end of file diff --git a/Test.UI/Test.UI/Data/FinestraSplitVertOriz.jwd b/Test.UI/Test.UI/Data/FinestraSplitVertOriz.jwd new file mode 100644 index 0000000..e8380b3 --- /dev/null +++ b/Test.UI/Test.UI/Data/FinestraSplitVertOriz.jwd @@ -0,0 +1,141 @@ +{ + "ProfilePath": "Profilo78", + "AreaList": [ + { + "Shape": "RECTANGLE", + "DimensionList": [ + { + "nIndex": 1, + "sName": "Width", + "dValue": 1500.0 + }, + { + "nIndex": 2, + "sName": "Height", + "dValue": 1800.0 + } + ], + "JointList": [ + { + "nIndex": 1, + "JointType": "FULL_H" + }, + { + "nIndex": 2, + "JointType": "FULL_H" + }, + { + "nIndex": 3, + "JointType": "FULL_H" + }, + { + "nIndex": 4, + "JointType": "FULL_H" + } + ], + "BottomRail": false, + "BottomRailQty": 0, + "AreaList": [ + { + "SplitShape": "VERTICAL", + "SplitPositionList": [ + { + "bIsRelative": true, + "dDimension": 50.0 + }, + { + "bIsRelative": true, + "dDimension": 50.0 + } + ], + "AreaList": [ + { + "AreaList": [ + { + "SplitShape": "HORIZONTAL", + "SplitPositionList": [ + { + "bIsRelative": true, + "dDimension": 40.0 + }, + { + "bIsRelative": true, + "dDimension": 60.0 + } + ], + "AreaList": [ + { + "AreaList": [ + { + "FillType": "GLASS", + "AreaList": [], + "AreaType": "FILL" + } + ], + "AreaType": "SPLITTED" + }, + { + "AreaList": [ + { + "FillType": "GLASS", + "AreaList": [], + "AreaType": "FILL" + } + ], + "AreaType": "SPLITTED" + } + ], + "AreaType": "SPLIT" + } + ], + "AreaType": "SPLITTED" + }, + { + "AreaList": [ + { + "SplitShape": "HORIZONTAL", + "SplitPositionList": [ + { + "bIsRelative": true, + "dDimension": 40.0 + }, + { + "bIsRelative": true, + "dDimension": 60.0 + } + ], + "AreaList": [ + { + "AreaList": [ + { + "FillType": "GLASS", + "AreaList": [], + "AreaType": "FILL" + } + ], + "AreaType": "SPLITTED" + }, + { + "AreaList": [ + { + "FillType": "GLASS", + "AreaList": [], + "AreaType": "FILL" + } + ], + "AreaType": "SPLITTED" + } + ], + "AreaType": "SPLIT" + } + ], + "AreaType": "SPLITTED" + } + ], + "AreaType": "SPLIT" + } + ], + "AreaType": "FRAME" + } + ] +} \ No newline at end of file diff --git a/Test.UI/Test.UI/Data/Setup.json b/Test.UI/Test.UI/Data/Setup.json index 3354e02..905d2ca 100644 --- a/Test.UI/Test.UI/Data/Setup.json +++ b/Test.UI/Test.UI/Data/Setup.json @@ -8,5 +8,21 @@ "Index": 2, "Description": "Anta doppia", "TemplFile": "Data/AntaDoppia.jwd" + }, + { + "Index": 3, + "Description": "Finestra con split verticale", + "TemplFile": "Data/FinestraSplitVert.jwd" + }, + { + "Index": 4, + "Description": "Finestra con split verticale e orizzontale", + "TemplFile": "Data/FinestraSplitVertOriz.jwd" + }, + { + "Index": 5, + "Description": "Finestra con split orizzontale (sopra due ante e sotto vetro fisso)", + "TemplFile": "Data/FinDueAnteBottomFisso.jwd" } + ] \ No newline at end of file diff --git a/WebWindowConfigurator/DTO/TemplateSelectorDTO.cs b/WebWindowConfigurator/DTO/TemplateSelectorDTO.cs index 8d34f80..840f7b4 100644 --- a/WebWindowConfigurator/DTO/TemplateSelectorDTO.cs +++ b/WebWindowConfigurator/DTO/TemplateSelectorDTO.cs @@ -8,9 +8,9 @@ namespace WebWindowConfigurator.DTO { public class TemplateSelectDTO { - public int Index { get; set; } = 0; public string Description { get; set; } = ""; public string TemplFile { get; set; } = ""; + public string TemplSVG { get; set; } = ""; } } diff --git a/WebWindowConfigurator/Json/JsonUtility.cs b/WebWindowConfigurator/Json/JsonUtility.cs index 3576651..f3c2456 100644 --- a/WebWindowConfigurator/Json/JsonUtility.cs +++ b/WebWindowConfigurator/Json/JsonUtility.cs @@ -276,34 +276,40 @@ namespace WebWindowConfigurator.Json { } - public JsonSash(bool bIsSashVertical, SashTypes SashType, string Hardware) : base(AreaTypes.SASH) + public JsonSash(bool bIsSashVertical, SashTypes SashType/*, string Hardware*/) : base(AreaTypes.SASH) { m_bIsSashVertical = bIsSashVertical; m_SashType = SashType; m_Hardware = Hardware; } - //internal override Area Deserialize(Area ParentArea) - //{ - // Sash Sash = new Sash(ParentArea); - // Sash.SetAreaType(AreaTypes.SASH); - // Sash.SetSashQty(m_SashList.Count); - // Sash.SetIsSashVertical(m_bIsSashVertical); - // Sash.AppliedDone(); - // for (var SashIndex = 0; SashIndex <= m_SashList.Count - 1; SashIndex++) - // { - // Sash.SashList(SashIndex).SetOpeningType(m_SashList[SashIndex].OpeningType); - // Sash.SashList(SashIndex).SetHasHandle(m_SashList[SashIndex].bHasHandle); - // Sash.SashList(SashIndex).SetDimension(m_SashList[SashIndex].dDimension); - // } - // foreach (var Joint in m_JointList) - // Sash.JointList.Add(Joint.Deserialize()); - // Sash.RefreshHardwareList(); - // Sash.SetSelHardwareFromId(Hardware); - // foreach (var Area in JsonArea.AreaList) - // Sash.AreaList.Add(Area.Deserialize(Sash)); - // return Sash; - //} + internal override Area Deserialize(Area ParentArea) + { + Sash Sash = new Sash(ParentArea); + Sash.SetAreaType(AreaTypes.SASH); + Sash.SetSashQty(m_SashList.Count); + Sash.SetIsSashVertical(m_bIsSashVertical); + //Sash.AppliedDone(); + for (var SashIndex = 0; SashIndex <= m_SashList.Count - 1; SashIndex++) + { + Sash.SashList[SashIndex].SetOpeningType(m_SashList[SashIndex].OpeningType); + Sash.SashList[SashIndex].SetHasHandle(m_SashList[SashIndex].bHasHandle); + Sash.SashList[SashIndex].SetDimension(m_SashList[SashIndex].dDimension); + } + foreach (var Joint in m_JointList) + Sash.JointList.Add(Joint.Deserialize()); + //Sash.RefreshHardwareList(); + //Sash.SetSelHardwareFromId(Hardware); + foreach (var Area in AreaList) + { + var AreaDeserealized = Area.Deserialize(Sash); + if (AreaDeserealized != null) + { + Sash.AreaList.Add(AreaDeserealized); + } + } + return Sash; + } } public class JsonSplit : JsonArea @@ -346,22 +352,28 @@ namespace WebWindowConfigurator.Json m_SplitShape = SplitShape; } - //internal override Area Deserialize(Area ParentArea) - //{ - // Split Split = new Split(ParentArea); - // Split.SetAreaType(AreaTypes.SPLIT); - // Split.SetSplitShape(m_SplitShape, true); - // Split.SetSplitQty(m_SplitPositionList.Count - 1, true); - // Split.AppliedDone(); - // for (var SplitIndex = 0; SplitIndex <= m_SplitPositionList.Count - 1; SplitIndex++) - // { - // Split.SplitPositionList(SplitIndex).SetIsRelative(m_SplitPositionList[SplitIndex].bIsRelative); - // Split.SplitPositionList(SplitIndex).SetDimension(m_SplitPositionList[SplitIndex].dDimension); - // } - // foreach (var Area in JsonArea.AreaList) - // Split.AreaList.Add(Area.Deserialize(Split)); - // return Split; - //} + internal override Area Deserialize(Area ParentArea) + { + Split Split = new Split(ParentArea); + Split.SetAreaType(AreaTypes.SPLIT); + Split.SetSplitShape(m_SplitShape, true); + Split.SetSplitQty(m_SplitPositionList.Count - 1, true); + //Split.AppliedDone(); + for (var SplitIndex = 0; SplitIndex <= m_SplitPositionList.Count - 1; SplitIndex++) + { + Split.SplitPositionList[SplitIndex].SetIsRelative(m_SplitPositionList[SplitIndex].bIsRelative); + Split.SplitPositionList[SplitIndex].SetDimension(m_SplitPositionList[SplitIndex].dDimension); + } + foreach (var Area in AreaList) + { + var AreaDeserealized = Area.Deserialize(Split); + if (AreaDeserealized != null) + { + Split.AreaList.Add(AreaDeserealized); + } + } + return Split; + } } public class JsonSplitted : JsonArea @@ -370,15 +382,22 @@ namespace WebWindowConfigurator.Json { } - //internal override Area Deserialize(Area ParentArea) - //{ - // Splitted Split = new Splitted(ParentArea); - // Split.SetAreaType(AreaTypes.SPLITTED); - // Split.AppliedDone(); - // foreach (var Area in JsonArea.AreaList) - // Split.AreaList.Add(Area.Deserialize(Split)); - // return Split; - //} + internal override Area Deserialize(Area ParentArea) + { + Splitted Split = new Splitted(ParentArea); + Split.SetAreaType(AreaTypes.SPLITTED); + //Split.AppliedDone(); + foreach (var Area in AreaList) + { + var AreaDeserealized = Area.Deserialize(Split); + if (AreaDeserealized != null) + { + Split.AreaList.Add(AreaDeserealized); + } + } + + return Split; + } } public class JsonFill : JsonArea @@ -407,16 +426,22 @@ namespace WebWindowConfigurator.Json m_FillType = FillType; } - //internal override Area Deserialize(Area ParentArea) - //{ - // Fill Fill = new Fill(ParentArea); - // Fill.SetAreaType(AreaTypes.FILL); - // Fill.SetFillType(m_FillType); - // Fill.AppliedDone(); - // foreach (var Area in JsonArea.AreaList) - // Fill.AreaList.Add(Area.Deserialize(Fill)); - // return Fill; - //} + internal override Area Deserialize(Area ParentArea) + { + Fill Fill = new Fill(ParentArea); + Fill.SetAreaType(AreaTypes.FILL); + Fill.SetFillType(m_FillType); + //Fill.AppliedDone(); + foreach (var Area in AreaList) + { + var AreaDeserealized = Area.Deserialize(Fill); + if (AreaDeserealized != null) + { + Fill.AreaList.Add(AreaDeserealized); + } + } + return Fill; + } } public class JsonJoint @@ -452,11 +477,11 @@ namespace WebWindowConfigurator.Json m_JointType = JointType; } - //internal Joint Deserialize() - //{ - // Joint Joint = new Joint(m_nIndex, m_JointType); - // return Joint; - //} + internal Joint Deserialize() + { + Joint Joint = new Joint(m_nIndex, m_JointType); + return Joint; + } } public class JsonCurve diff --git a/WebWindowConfigurator/Template.cs b/WebWindowConfigurator/Template.cs index 399ea7a..39dbd23 100644 --- a/WebWindowConfigurator/Template.cs +++ b/WebWindowConfigurator/Template.cs @@ -28,11 +28,21 @@ namespace WebWindowConfigurator } } - public Template(int nIndex, string sDescription, string JWDTemplate) + private string m_SVG; + public string SVG + { + get + { + return m_SVG; + } + } + + public Template(int nIndex, string sDescription, string JWD, string SVG) { m_nIndex = nIndex; this.sDescription = sDescription; - m_JWD = JWDTemplate; + m_JWD = JWD; + m_SVG = SVG; } } } diff --git a/WebWindowConfigurator/WebWindowMaker.razor b/WebWindowConfigurator/WebWindowMaker.razor index 5325328..c4fa21b 100644 --- a/WebWindowConfigurator/WebWindowMaker.razor +++ b/WebWindowConfigurator/WebWindowMaker.razor @@ -1,59 +1,69 @@ 
-
+
- @if (currStep == CompileStep.General) + @if (currStep == CompileStep.Template) { - + @@ -66,68 +76,86 @@ colorClass = ""; - - + + }
# ImageDescriptionDescription
@item.Index...@item.Description@item.TemplSVG@item.Description
@* *@ } - else if (currStep == CompileStep.Sash) + else if (currStep == CompileStep.Frame) { -
- @foreach (FrameDimension dimension in m_frame.DimensionList) - { -
- @dimension.nIndex - @dimension.sName - -
- } -
- - -
-
- @foreach (Joint joint in m_frame.JointList) - { -
- - +
+
+
+
+
+ + +
+
+
+
Dimensioni
+ @foreach (FrameDimension dimension in m_frame.DimensionList) + { +
+ @dimension.nIndex + @dimension.sName + +
+ } +
+
+
+
+
Giunzioni telaio
+ @foreach (Joint joint in m_frame.JointList) + { +
+ + +
+ } +
+
+
+
+
Bottom rail
+
+
+ +
+
+ +
+
+
+ Quantità + +
+
+
+ @* *@
- } -
-
-
-
-
- +
+ @m_SelSVG
-
- BottomRailQty - -
- @* *@
} else if (currStep == CompileStep.Split) @@ -137,6 +165,13 @@ @* *@
} + else if (currStep == CompileStep.Sash) + { +
+ aggiungi caratteristiche finestra + @* *@ +
+ } else if (currStep == CompileStep.Fill) {
diff --git a/WebWindowConfigurator/WebWindowMaker.razor.cs b/WebWindowConfigurator/WebWindowMaker.razor.cs index 96bcc48..88b6c55 100644 --- a/WebWindowConfigurator/WebWindowMaker.razor.cs +++ b/WebWindowConfigurator/WebWindowMaker.razor.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Components; using Newtonsoft.Json; +using System.Collections.ObjectModel; using System.Reflection.Metadata; using System.Runtime.Intrinsics.X86; using System.Text.Json.Serialization; @@ -28,38 +29,36 @@ namespace WebWindowConfigurator [Parameter] public Template IN_SelTemplate { - get => mSelTemplate; + get => m_SelTemplate; set { - if (value != null && !string.IsNullOrEmpty(value.JWD)) + if (value != null && (m_SelTemplate == null || (m_SelTemplate != null && value.nIndex != m_SelTemplate.nIndex)) && !string.IsNullOrEmpty(value.JWD)) { - mSelTemplate = value; - JsonWindow WindowFromJson = JsonConvert.DeserializeObject(mSelTemplate.JWD, new PolymorphicJsonConverter()); + m_SelTemplate = value; + JsonWindow WindowFromJson = JsonConvert.DeserializeObject(m_SelTemplate.JWD, new PolymorphicJsonConverter()); m_CurrWindow = WindowFromJson.Deserialize(); + m_SelSVG = m_SelTemplate.SVG; } } } - private Template mSelTemplate { get; set; } = null!; + private Template m_SelTemplate { get; set; } = null!; public TemplateSelectDTO? SelTemplateDTO { get; set; } = null; public Area m_SelArea { get; set; } = null!; - + public string m_SelSVG { get; set; } = ""; #endregion Public Properties - #region Public Methods - - #endregion Public Methods - #region Protected Enums protected enum CompileStep { - General = 0, - Sash = 1, + Template = 0, + Frame = 1, Split, + Sash, Fill } @@ -71,7 +70,7 @@ namespace WebWindowConfigurator { get => (Frame)m_CurrWindow.AreaList[0]; } - + #endregion Protected Properties #region Protected Methods @@ -105,7 +104,7 @@ namespace WebWindowConfigurator #region Private Fields - private CompileStep currStep = CompileStep.General; + private CompileStep currStep = CompileStep.Template; #endregion Private Fields diff --git a/WebWindowConfigurator/Window.cs b/WebWindowConfigurator/Window.cs index bbc9d9c..ac65959 100644 --- a/WebWindowConfigurator/Window.cs +++ b/WebWindowConfigurator/Window.cs @@ -1,64 +1,17 @@ using Newtonsoft.Json.Linq; +using System.Collections; using System.Collections.ObjectModel; using System.ComponentModel; using System.Drawing; using System.Runtime.Intrinsics.Arm; using System.Xml.Serialization; +using WebWindowConfigurator; using WebWindowConfigurator.Json; using static WebWindowConfigurator.Json.WindowConst; namespace WebWindowConfigurator { - public class FrameDimension - { - 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; - } - } - - public FrameDimension(int nIndex, string sName, double dValue, bool bIsLen) - { - 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 Window { private String m_sProfilePath; @@ -1107,71 +1060,332 @@ namespace WebWindowConfigurator } } + public class Split : Area + { + public int nSplitQty + { + get + { + return m_SplitPositionList.Count > 0 ? m_SplitPositionList.Count - 1 : 0; + } + set + { + if (value > m_SplitPositionList.Count - 1) + { + // recupero larghezza ultimo + double dLastDimension = 100; + double dNewDimension = 100; + if (m_SplitPositionList.Count > 0) + { + dLastDimension = m_SplitPositionList[m_SplitPositionList.Count - 1].dDimension; + dNewDimension = dLastDimension / (value + 1 - nSplitQty); + m_SplitPositionList[m_SplitPositionList.Count - 1].SetDimension(dNewDimension); + } + else + dNewDimension = dLastDimension / (value + 1 - nSplitQty); + // aggiungo area Split di default + for (var SplitIndex = m_SplitPositionList.Count; SplitIndex <= value; SplitIndex++) + SplitPositionList.Add(new SplitDimension(dNewDimension, true, this)); + } + else if (value < m_SplitPositionList.Count - 1) + { + double dLastDimension = 0; + for (var SplitIndex = m_SplitPositionList.Count - 1; SplitIndex >= value + 1; SplitIndex += -1) + { + dLastDimension += m_SplitPositionList[SplitIndex].dDimension; + SplitPositionList.RemoveAt(SplitIndex); + } + dLastDimension += m_SplitPositionList[SplitPositionList.Count - 1].dDimension; + SplitPositionList[SplitPositionList.Count - 1].SetDimension(dLastDimension); + } + } + } + + internal void SetSplitQty(int Qty, bool NotifyProperty = false) + { + if (Qty > m_SplitPositionList.Count) + { + // recupero larghezza ultimo + double dLastDimension = 100; + double dNewDimension = 100; + if (m_SplitPositionList.Count > 0) + { + dLastDimension = m_SplitPositionList[m_SplitPositionList.Count - 1].dDimension; + dNewDimension = dLastDimension / (Qty + 1 - nSplitQty); + m_SplitPositionList[m_SplitPositionList.Count - 1].dDimension = dNewDimension; + } + else + dNewDimension = dLastDimension / (Qty + 1 - nSplitQty); + // aggiungo area Split di default + for (var SplitIndex = m_SplitPositionList.Count; SplitIndex <= Qty; SplitIndex++) + SplitPositionList.Add(new SplitDimension(dNewDimension, true, this)); + } + else if (Qty < m_SplitPositionList.Count) + { + for (var SplitIndex = m_SplitPositionList.Count - 1; SplitIndex >= Qty; SplitIndex += -1) + SplitPositionList.RemoveAt(SplitIndex); + } + } + + private ObservableCollection m_SplitShapeList = new ObservableCollection + { + 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 ObservableCollection 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); + } + } + 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 ObservableCollection m_SplitPositionList = new ObservableCollection(); + public ObservableCollection SplitPositionList + { + get + { + return m_SplitPositionList; + } + set + { + m_SplitPositionList = value; + } + } + + private Curve m_Split; + public Curve sSplit + { + get + { + return m_Split; + } + set + { + m_Split = value; + } + } + + public Split(Area ParentArea) : base(ParentArea) + { + } + + internal static Split CreateSplit(Area Area, SplitShapes SplitShape) + { + Split Split = new Split(Area); + Split.SetAreaType(AreaTypes.SPLIT); + Split.SetSplitShape(SplitShape, true); + return Split; + } + + internal override JsonArea Serialize() + { + JsonSplit JsonSplit = new JsonSplit(m_SelSplitShape); + foreach (var SplitPosition in m_SplitPositionList) + JsonSplit.SplitPositionList.Add(SplitPosition.Serialize()); + foreach (var Area in AreaList) + JsonSplit.AreaList.Add(Area.Serialize()); + return JsonSplit; + } +} + + public class Splitted : Area + { + public Splitted(Area ParentArea) : base(ParentArea) + { + } + + internal static Splitted CreateSplitted(Area Area) + { + Splitted Splitted = new Splitted(Area); + Splitted.SetAreaType(AreaTypes.SPLITTED); + return Splitted; + } + + internal override JsonArea Serialize() + { + JsonSplitted JsonSplitted = new JsonSplitted(); + foreach (var Area in AreaList) + JsonSplitted.AreaList.Add(Area.Serialize()); + return JsonSplitted; + } + } + + public class Fill : Area + { + public FillTypes FillType + { + get + { + if (m_Fill_IsChecked[0]) + return FillTypes.GLASS; + else + return FillTypes.WOOD; + } + } + internal void SetFillType(FillTypes FillType) + { + switch (FillType) + { + case FillTypes.GLASS: + { + bGlass_IsChecked = true; + break; + } + + case FillTypes.WOOD: + { + bWood_IsChecked = true; + break; + } + } + } + + private bool[] m_Fill_IsChecked = new[] { false, false }; + public bool bGlass_IsChecked + { + get + { + return m_Fill_IsChecked[0]; + } + set + { + m_Fill_IsChecked[0] = value; + } + } + public bool bWood_IsChecked + { + get + { + return m_Fill_IsChecked[1]; + } + set + { + m_Fill_IsChecked[1] = value; + } + } + + public Fill(Area ParentArea) : base(ParentArea) + { + } + + internal static Fill CreateFill(Area Area, FillTypes FillType) + { + Fill Fill = new Fill(Area); + Fill.SetAreaType(AreaTypes.FILL); + Fill.SetFillType(FillType); + return Fill; + } + + internal override JsonArea Serialize() + { + JsonFill JsonFill = new JsonFill(FillType); + foreach (var Area in AreaList) + JsonFill.AreaList.Add(Area.Serialize()); + return JsonFill; + } + } + public class Joint - { - private int m_nIndex; - public int nIndex { - get + private int m_nIndex; + public int nIndex { - return m_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 + private List m_JointTypeList = new List { - get + 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 { - return m_JointTypeList; + get + { + return m_JointTypeList; + } } - } - private Joints m_SelJointType; - public int SelJointTypeIndex + 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); + } + } + public Joints SelJointType + { + get + { + return m_SelJointType; + } + set + { + m_SelJointType = value; + } + } + internal void SetSelJointType(Joints value) { - get - { - return IdNameStruct.IndFromId((int)m_SelJointType, m_JointTypeList); - } - set - { - m_SelJointType = (Joints)IdNameStruct.IdFromInd(value, m_JointTypeList); - } + m_SelJointType = value; + //NotifyPropertyChanged(nameof(SelJointTypeIndex)); } - public Joints SelJointType - { - get + public Joint(int nIndex, Joints SelJointType) { - return m_SelJointType; + m_nIndex = nIndex; + m_SelJointType = SelJointType; } - set - { - m_SelJointType = value; - } - } - internal void SetSelJointType(Joints value) - { - m_SelJointType = value; - //NotifyPropertyChanged(nameof(SelJointTypeIndex)); - } - public Joint(int nIndex, Joints SelJointType) - { - m_nIndex = nIndex; - m_SelJointType = SelJointType; - } - internal JsonJoint Serialize() - { - JsonJoint JsonJoint = new JsonJoint(m_nIndex, m_SelJointType); - return JsonJoint; + internal JsonJoint Serialize() + { + JsonJoint JsonJoint = new JsonJoint(m_nIndex, m_SelJointType); + return JsonJoint; + } } - } public class Curve { @@ -1393,6 +1607,56 @@ namespace WebWindowConfigurator } } + public class FrameDimension + { + 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; + } + } + + public FrameDimension(int nIndex, string sName, double dValue, bool bIsLen) + { + 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 @@ -1633,6 +1897,110 @@ namespace WebWindowConfigurator } } + 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 double m_dDimension; + public double dDimension + { + get + { + return m_dDimension; + } + set + { + // se sono in percentuale + if (m_bIsRelative) + { + // 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); + for (var Ind = nIndex + 1; Ind <= RelativeDimList.Count - 1; Ind++) + RelativeDimList[Ind].SetDimension(dRes); + } + else if (RelativeDimList.Count > 1) + { + for (var Ind = nIndex + 1; Ind <= RelativeDimList.Count - 1; Ind++) + dRes += RelativeDimList[Ind].dDimension; + dRes = (100 - dRes) / (nIndex - 1); + for (var nInd = 0; nInd <= nIndex - 1; nInd++) + RelativeDimList[nInd].SetDimension(dRes); + } + else + { + m_dDimension = 100; + return; + } + } + } + else + { + } + } + } + + m_dDimension = value; + } + } + internal void SetDimension(double dValue) + { + m_dDimension = dValue; + } + + public SplitDimension(double dDimension, bool bIsRelative, Split Parent) + { + m_dDimension = dDimension; + m_bIsRelative = bIsRelative; + m_Parent = Parent; + } + + internal JsonSplitDimension Serialize() + { + JsonSplitDimension JsonSplitDimension = new JsonSplitDimension(m_bIsRelative, m_dDimension); + return JsonSplitDimension; + } + } + + public struct IdNameStruct { private int m_Id;