From d63ec149b02757f51b4521e9ca0993b95a37437c Mon Sep 17 00:00:00 2001 From: Annamaria Sassi Date: Thu, 13 Nov 2025 19:05:36 +0100 Subject: [PATCH] Gestiti i diversi tipi di dimensioni per sash --- Test.UI/Data/AntaDoppia.jwd | 2 + Test.UI/Data/FinestraSplitVert.jwd | 2 + WebWindowComplex/Compo/CardSplit.razor | 44 +- WebWindowComplex/Json/JsonUtility.cs | 32 +- WebWindowComplex/Models/Sash.cs | 29 +- WebWindowComplex/Models/SashDimension.cs | 389 +++++++++++++----- WebWindowComplex/Models/Split.cs | 17 + WebWindowComplex/Models/SplitDimension.cs | 65 ++- WebWindowComplex/TableComp.razor.cs | 88 ++++ WebWindowComplex/WebWindowComplex.csproj | 82 +++- .../WebWindowConfigurator.csproj | 88 +++- 11 files changed, 730 insertions(+), 108 deletions(-) diff --git a/Test.UI/Data/AntaDoppia.jwd b/Test.UI/Data/AntaDoppia.jwd index eeb3733..486ff5f 100644 --- a/Test.UI/Data/AntaDoppia.jwd +++ b/Test.UI/Data/AntaDoppia.jwd @@ -47,12 +47,14 @@ "SashId": 1, "OpeningType": "TILTTURN_LEFT", "HasHandle": true, + "MeasureType": "PERCENTAGE", "Dimension": 50.0 }, { "SashId": 2, "OpeningType": "TURNONLY_RIGHT", "HasHandle": false, + "MeasureType": "PERCENTAGE", "Dimension": 50.0 } ], diff --git a/Test.UI/Data/FinestraSplitVert.jwd b/Test.UI/Data/FinestraSplitVert.jwd index d3feecc..8078d3c 100644 --- a/Test.UI/Data/FinestraSplitVert.jwd +++ b/Test.UI/Data/FinestraSplitVert.jwd @@ -46,10 +46,12 @@ "SplitVertList": [ { "IsRelative": true, + "MeasureType": "PERCENTAGE", "Dimension": 50.0 }, { "IsRelative": true, + "MeasureType": "PERCENTAGE", "Dimension": 50.0 } ], diff --git a/WebWindowComplex/Compo/CardSplit.razor b/WebWindowComplex/Compo/CardSplit.razor index 81551b6..568ba2f 100644 --- a/WebWindowComplex/Compo/CardSplit.razor +++ b/WebWindowComplex/Compo/CardSplit.razor @@ -69,9 +69,18 @@
@if (CurrItem.SplitVertList.Count > 0 && CurrItem.SplitHorizList.Count > 0) { -
+
@foreach (var dim in CurrItem.SplitVertList) { +
+ + +
Width @@ -79,9 +88,18 @@
}
-
+
@foreach (var dim in CurrItem.SplitHorizList) { +
+ + +
Height @@ -94,7 +112,16 @@ { @foreach (var dim in CurrItem.SplitHorizList) { -
+
+
+ + +
Height @@ -107,7 +134,16 @@ { @foreach (var dim in CurrItem.SplitVertList) { -
+
+
+ + +
Width diff --git a/WebWindowComplex/Json/JsonUtility.cs b/WebWindowComplex/Json/JsonUtility.cs index d9310dc..fef03b9 100644 --- a/WebWindowComplex/Json/JsonUtility.cs +++ b/WebWindowComplex/Json/JsonUtility.cs @@ -409,6 +409,7 @@ namespace WebWindowComplex.Json newSash.SashList[SashIndex].SetOpeningType(m_SashList[SashIndex].OpeningType); newSash.SashList[SashIndex].SetHasHandle(m_SashList[SashIndex].HasHandle); newSash.SashList[SashIndex].SetDimension(m_SashList[SashIndex].Dimension); + newSash.SashList[SashIndex].SetMeasureType(m_SashList[SashIndex].MeasureType); } foreach (var Joint in m_JointList) newSash.JointList.Add(Joint.Deserialize((Area)ParentArea)); @@ -511,19 +512,18 @@ namespace WebWindowComplex.Json Split.SetSplitQtyVert(0); else { - //Split.SplitVertList.Clear(); Split.SetSplitQtyVert(m_SplitVertList.Count - 1); for (var SplitIndex = 0; SplitIndex <= m_SplitVertList.Count - 1; SplitIndex++) { Split.SplitVertList[SplitIndex].SetIsRelative(m_SplitVertList[SplitIndex].IsRelative); Split.SplitVertList[SplitIndex].SetDimension(m_SplitVertList[SplitIndex].Dimension); + Split.SplitVertList[SplitIndex].SetMeasureType(m_SplitVertList[SplitIndex].MeasureType); } } if (m_SplitHorizList.Count == 0) Split.SetSplitQtyHoriz(0); else { - //Split.SplitHorizList.Clear(); Split.SetSplitQtyHoriz(m_SplitHorizList.Count - 1); for (var SplitIndex = 0; SplitIndex <= m_SplitHorizList.Count - 1; SplitIndex++) { @@ -769,6 +769,17 @@ namespace WebWindowComplex.Json } } + private MeasureTypes m_MeasureType; + [JsonProperty] + [JsonConverter(typeof(StringEnumConverter))] + public MeasureTypes MeasureType + { + get + { + return m_MeasureType; + } + } + private bool m_bHasHandle; [JsonProperty] public bool HasHandle @@ -797,9 +808,10 @@ namespace WebWindowComplex.Json } } - public JsonSashDimension(Openings OpeningType, bool HasHandle, double Dimension, int SashId) + public JsonSashDimension(Openings OpeningType, MeasureTypes MeasureType, bool HasHandle, double Dimension, int SashId) { m_OpeningType = OpeningType; + m_MeasureType = MeasureType; m_bHasHandle = HasHandle; m_dDimension = Dimension; m_nSashId = SashId; @@ -832,10 +844,22 @@ namespace WebWindowComplex.Json } } - public JsonSplitDimension(bool IsRelative, double Dimension) + private MeasureTypes m_MeasureType; + [JsonProperty] + [JsonConverter(typeof(StringEnumConverter))] + public MeasureTypes MeasureType + { + get + { + return m_MeasureType; + } + } + + public JsonSplitDimension(bool IsRelative, double Dimension, MeasureTypes MeasureType) { m_bIsRelative = IsRelative; m_dDimension = Dimension; + m_MeasureType = MeasureType; } } diff --git a/WebWindowComplex/Models/Sash.cs b/WebWindowComplex/Models/Sash.cs index 1ba799b..c7f82af 100644 --- a/WebWindowComplex/Models/Sash.cs +++ b/WebWindowComplex/Models/Sash.cs @@ -34,6 +34,21 @@ namespace WebWindowComplex.Models #region Public Properties + /// + /// Larghezza gruppo ante + /// + public double Width + { + get + { + return m_Width; + } + set + { + m_Width = value; + } + } + public bool bIsMeasureGlass { get @@ -128,7 +143,7 @@ namespace WebWindowComplex.Models // aggiungo area Sash di default for (var SplitIndex = m_SashList.Count; SplitIndex <= value - 1; SplitIndex++) { - SashList.Add(new SashDimension(dNewDimension, MeasureTypes.PERCENTAGE, this, SplitIndex + 1)); + SashList.Add(new SashDimension(dNewDimension, m_SashList[m_SashList.Count - 1].MeasureType, this, SplitIndex + 1)); } } else if (value < m_SashList.Count) @@ -136,12 +151,16 @@ namespace WebWindowComplex.Models if (value > 0) { double dLastDimension = 0; + SashDimension itemDelete = null; for (var SplitIndex = m_SashList.Count - 1; SplitIndex >= value; SplitIndex += -1) { - dLastDimension += m_SashList[SplitIndex].dDimension; + //dLastDimension += m_SashList[SplitIndex].dDimension; + itemDelete = m_SashList[SplitIndex]; SashList.RemoveAt(SplitIndex); } - dLastDimension += m_SashList[SashList.Count - 1].dDimension; + double deleteDim = itemDelete.ConvertDimension(itemDelete.SelMeasureType, m_SashList[SashList.Count - 1].SelMeasureType); + //dLastDimension += m_SashList[SashList.Count - 1].dDimension; + dLastDimension = deleteDim + m_SashList[SashList.Count - 1].dDimension; SashList[SashList.Count - 1].SetDimension(dLastDimension); if (value == 1) SashList.First().SetHasHandle(true); @@ -886,10 +905,12 @@ namespace WebWindowComplex.Models private List m_SashList = new List(); private SashTypes m_SashType; - private string m_SelFamilyHardware; + private string m_SelFamilyHardware = ""; private Hardware m_SelHardware; private OrientationSash m_SelOrientationSashType; + private double m_Width = 0; + #endregion Private Fields #region Private Methods diff --git a/WebWindowComplex/Models/SashDimension.cs b/WebWindowComplex/Models/SashDimension.cs index 1f3350b..bf27283 100644 --- a/WebWindowComplex/Models/SashDimension.cs +++ b/WebWindowComplex/Models/SashDimension.cs @@ -104,7 +104,7 @@ namespace WebWindowComplex.Models //m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); } } - + public double dDimension { get @@ -119,13 +119,14 @@ namespace WebWindowComplex.Models { case MeasureTypes.ABSOLUT: { - valMax = m_Parent.SashList.Sum(x => x.dDimension); - valueAccept = (value < valMax && value > 0) ? true: false; + valMax = m_Parent.Width; + valueAccept = (value < valMax && value > 0) ? true : false; break; } case MeasureTypes.PROPORTIONAL: { - valMax = m_Parent.SashList.Sum(x => x.dDimension); + valMax = 20; + valueAccept = true ; break; } case MeasureTypes.PERCENTAGE: @@ -135,69 +136,87 @@ namespace WebWindowComplex.Models break; } } - if (!MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + if (valueAccept) { - if (valueAccept) + double widthTot = m_Parent.Width; + List dimensions = m_Parent.SashList; + List absolutValList = new List(); + foreach(var item in m_Parent.SashList) { - - // verifico se ci sono altri in percentuale - List DimList = m_Parent.SashList.Where(x => x.MeasureType.Equals(MeasureType)).ToList(); - if (DimList.Count > 0) + absolutValList.Add(item.CalculateAbsolutValue(widthTot)); + } + int nIndex = dimensions.IndexOf(this); + int proportionalCount = dimensions.Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count; + // Le altre dimensioni non sono solo in proporzionale + if ( proportionalCount == 0 || proportionalCount < absolutValList.Count - 1) + { + double valueInAbsolute = 0; + switch (MeasureType) { - int nIndex = DimList.IndexOf(this); - // se diminuisce dimensione - if (value < m_dDimension) - { - if (nIndex < DimList.Count - 1) - DimList[nIndex + 1].SetDimension(DimList[nIndex + 1].dDimension + (m_dDimension - value)); - else if (DimList.Count > 1) - DimList[nIndex - 1].SetDimension(DimList[nIndex - 1].dDimension + (m_dDimension - value)); - else + case MeasureTypes.ABSOLUT: { - m_dDimension = valMax; - return; + valueInAbsolute = value; + break; } + case MeasureTypes.PROPORTIONAL: + { + var pesi = value + dimensions + .Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL) && !x.Equals(this)) + .Sum(x => x.m_dDimension); + valueInAbsolute = widthTot / pesi * value; + break; + } + case MeasureTypes.PERCENTAGE: + { + valueInAbsolute = (value / 100) * widthTot; + break; + } + } + if (value < dDimension) + { + // L'anta modificata non è l'ultima + if (nIndex < absolutValList.Count - 1) + { + absolutValList[nIndex + 1] = absolutValList[nIndex + 1] + (absolutValList[nIndex] - valueInAbsolute); + absolutValList[nIndex] = valueInAbsolute; } - // se aumenta dimensione - else + // L'anta modificata è l'ultima + else if (dimensions.Count > 1) { - double dRes = value; - // se non ultima anta - if (nIndex < DimList.Count - 1) - { - for (var nInd = 0; nInd <= nIndex - 1; nInd++) - dRes += DimList[nInd].dDimension; - dRes = (100 - dRes) / (DimList.Count - nIndex - 1); - for (var Ind = nIndex + 1; Ind <= DimList.Count - 1; Ind++) - DimList[Ind].SetDimension(dRes); - } - // se ultima anta - else if (DimList.Count > 1) - { - if (DimList.Count > 2) - { - for (var Ind = 0; Ind <= nIndex - 2; Ind++) - dRes += DimList[Ind].dDimension; - } - dRes = (valMax - dRes); - DimList[nIndex - 1].SetDimension(dRes); - } - else - { - m_dDimension = valMax; - return; - } + absolutValList[nIndex - 1] = absolutValList[nIndex - 1] + (absolutValList[nIndex] - valueInAbsolute); + absolutValList[nIndex] = valueInAbsolute; } } - m_dDimension = value; - m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); + else + { + // L'anta modificata non è l'ultima + if (nIndex < absolutValList.Count - 1) + { + absolutValList[nIndex + 1] = absolutValList[nIndex + 1] - (valueInAbsolute - absolutValList[nIndex]); + absolutValList[nIndex] = valueInAbsolute; + } + // L'anta modificata è l'ultima + else if (dimensions.Count > 1) + { + absolutValList[nIndex - 1] = absolutValList[nIndex - 1] - (valueInAbsolute - absolutValList[nIndex]); + absolutValList[nIndex] = valueInAbsolute; + } + } + if (MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + m_dDimension = value; + for(int i = 0; i < absolutValList.Count; i++) + { + var item = m_Parent.SashList.ElementAt(i); + item.SetDimension(ConvertIn(absolutValList[i], (MeasureTypes)item.SelMeasureTypeIndex, widthTot)); + } + } + else + { + m_dDimension = value; } - } - else - { - m_dDimension = value; m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); } + //// se sono in percentuale //if (m_MeasureType.Equals(MeasureTypes.PERCENTAGE)) //{ @@ -359,7 +378,13 @@ namespace WebWindowComplex.Models } set { - m_SelMeasureType = (MeasureTypes)value; + if(m_SelMeasureType != (MeasureTypes)value) + { + MeasureTypes newType = (MeasureTypes)value; + m_dDimension = ConvertDimension(m_SelMeasureType, newType); + m_SelMeasureType = (MeasureTypes)value; + m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); + } } } @@ -367,6 +392,57 @@ namespace WebWindowComplex.Models #region Public Methods + /// + /// Metodo per convertire la dimensione dal vecchio tipo al nuovo tipo + /// + /// Vecchio tipo + /// Nuovo tipo + /// + public double ConvertDimension(MeasureTypes oldType, MeasureTypes newType) + { + switch (oldType) + { + case MeasureTypes.ABSOLUT: + { + if (newType.Equals(MeasureTypes.PERCENTAGE)) + { + return Double.Round((m_dDimension / m_Parent.Width) * 100, 0); + } + else + { + return ricalculatePropVal(); + } + } + case MeasureTypes.PROPORTIONAL: + { + if (newType.Equals(MeasureTypes.ABSOLUT)) + { + return Double.Round(convertFromPropVal(newType), 2); + } + else + { + return Double.Round(convertFromPropVal(newType)); + } + } + case MeasureTypes.PERCENTAGE: + { + if (newType.Equals(MeasureTypes.ABSOLUT)) + { + return Double.Round((m_dDimension * m_Parent.Width) / 100); + } + else + { + return Double.Round(ricalculatePropVal()); + } + } + } + return -1; + } + + /// + /// Metodo per copiare l'intero oggetto + /// + /// public SashDimension Copy() { SashDimension newSashDim = new SashDimension(dDimension, MeasureType, m_Parent, m_nSashId); @@ -382,7 +458,7 @@ namespace WebWindowComplex.Models internal JsonSashDimension Serialize() { - JsonSashDimension JsonSashDimension = new JsonSashDimension(OpeningType, m_bHasHandle, m_dDimension, m_nSashId); + JsonSashDimension JsonSashDimension = new JsonSashDimension(OpeningType, MeasureType, m_bHasHandle, m_dDimension, m_nSashId); return JsonSashDimension; } @@ -406,6 +482,169 @@ namespace WebWindowComplex.Models m_SelMeasureType = value; } + /// + /// Metodo per trasformare una dimensione in valore assoluto rispetto alla larghezza totale + /// + /// Larghezza totale + /// + internal double CalculateAbsolutValue(double widthTot) + { + switch (MeasureType) + { + case MeasureTypes.ABSOLUT: + { + return dDimension; + } + case MeasureTypes.PROPORTIONAL: + { + return calculatePropVal(); + } + case MeasureTypes.PERCENTAGE: + { + return (dDimension / 100) * widthTot; + } + } + return 0; + } + + /// + /// Metodo per convertire una dimensione da un valore assoluto al suo rispettivo tipo + /// + /// Valore assoluto + /// Tipo di misura della dimensione + /// Larghezza totale + /// + internal double ConvertIn(double absolutVal, MeasureTypes type, double widthTot) + { + switch (type) + { + case MeasureTypes.ABSOLUT: + { + return absolutVal; + } + case MeasureTypes.PROPORTIONAL: + { + return calculatePropVal(); + } + case MeasureTypes.PERCENTAGE: + { + return (absolutVal / widthTot) * 100; + } + } + return -1; + } + + /// + /// Metodo per convertire da misura proporzionale a misura assoluta o percentuale + /// + /// + /// + internal double convertFromPropVal(MeasureTypes newType) + { + double tot = m_Parent.Width; + //Somma misura non proporzionali + double sumNotProp = m_Parent.SashList + .Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL && !m.Equals(this)) + .Sum(m => m.CalculateAbsolutValue(tot)); + //Calcolo residuo + double res = tot - sumNotProp; + if (res < 0) res = 0; + //Misure proporzionali + var proportionalList = m_Parent.SashList + .Where(m => m.SelMeasureType == MeasureTypes.PROPORTIONAL) + .ToList(); + + double sumPesi = proportionalList.Sum(p => p.dDimension); + if (sumPesi == 0) sumPesi = 1; + if (newType.Equals(MeasureTypes.ABSOLUT)) + { + return res / sumPesi * dDimension; + } + else + { + return (res / sumPesi * dDimension) / tot * 100; + } + } + + /// + /// Metodo per calcolare il valore proporzionale + /// + /// + internal double calculatePropVal() + { + double tot = m_Parent.Width; + //Somma misura non proporzionali + double sumNotProp = m_Parent.SashList + .Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL) + .Sum(m => m.CalculateAbsolutValue(tot)); + //Calcolo residuo + double res = tot - sumNotProp; + if (res < 0) res = 0; + //Misure proporzionali + var proportionalList = m_Parent.SashList + .Where(m => m.SelMeasureType == MeasureTypes.PROPORTIONAL) + .ToList(); + double sumPesi = proportionalList.Sum(p => p.dDimension); + if (sumPesi == 0) sumPesi = 1; + return res / sumPesi*dDimension; + } + + /// + /// Calcolo MCD + /// + /// + /// + /// + public static double CalcolaMCD(double a, double b) + { + while (b != 0) + { + double temp = b; + b = a % b; + a = temp; + } + return a; + } + + /// + /// Metodo per ricalcolare i valori proporzionali a causa della modifica di uno + /// + /// + internal double ricalculatePropVal() + { + if(m_Parent.SashList.Where(m => m.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count == 0) + { + return 1; + } + List absolutValue = new List(); + foreach (var item in m_Parent.SashList) + { + absolutValue.Add(item.CalculateAbsolutValue(m_Parent.Width)); + } + for(int i = 0; i < m_Parent.SashList.Count; i++) + { + if(!m_Parent.SashList.ElementAt(i).Equals(this) && + m_Parent.SashList.ElementAt(i).MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + { + int nIndex = m_Parent.SashList.IndexOf(this); + if (absolutValue.ElementAt(nIndex) <= absolutValue.ElementAt(i)) + { + var mcd = CalcolaMCD(absolutValue.ElementAt(nIndex), absolutValue.ElementAt(i)); + m_Parent.SashList.ElementAt(i).m_dDimension = absolutValue.ElementAt(i) / mcd; + m_dDimension = absolutValue.ElementAt(nIndex) / mcd; + } + else + { + var mcd = CalcolaMCD(absolutValue.ElementAt(nIndex), absolutValue.ElementAt(i)); + m_Parent.SashList.ElementAt(i).m_dDimension = absolutValue.ElementAt(i) / mcd; + m_dDimension = absolutValue.ElementAt(nIndex) / mcd; + } + break; + } + } + return m_dDimension; + } + #endregion Internal Methods #region Private Fields @@ -461,41 +700,5 @@ namespace WebWindowComplex.Models #endregion Private Fields - #region Private Methods - - /// - /// Recupero della larghezza del frame - /// - /// - private double GetWidth() - { - double width = 0; - int indexSash = 0; - if (m_Parent.ParentArea != null && m_Parent.ParentArea.ParentArea != null && m_Parent.ParentArea.ParentArea is Split) - { - Split splitParent = (Split)m_Parent.ParentArea.ParentArea; - if(splitParent.SplitVertList.Count > 0) - { - for(int i = 0; i < splitParent.AreaList.Count; i++) - { - if (splitParent.AreaList[i].AreaList[0].Equals(this)) - { - indexSash = i; - } - - } - } - //int indexSash = splitParent.AreaList.Where(x => x.AreaList[0].Equals(this)); - } - else - { - Frame a = m_Parent.ParentWindow.AreaList[0]; - FrameDimension? fd = a.DimensionList.Where(x => x.sName == "Width").SingleOrDefault(); - width = fd.dValue; - } - return width; - } - - #endregion Private Methods } } \ No newline at end of file diff --git a/WebWindowComplex/Models/Split.cs b/WebWindowComplex/Models/Split.cs index 084f696..7f876c0 100644 --- a/WebWindowComplex/Models/Split.cs +++ b/WebWindowComplex/Models/Split.cs @@ -20,6 +20,21 @@ namespace WebWindowComplex.Models #region Public Properties + /// + /// Larghezza gruppo split + /// + public double Width + { + get + { + return m_Width; + } + set + { + m_Width = value; + } + } + public bool bIsPercentage { get @@ -472,6 +487,8 @@ namespace WebWindowComplex.Models private List m_SplitVertList = new List(); + private double m_Width = 0; + #endregion Private Fields } } \ No newline at end of file diff --git a/WebWindowComplex/Models/SplitDimension.cs b/WebWindowComplex/Models/SplitDimension.cs index 8849369..70b6dfe 100644 --- a/WebWindowComplex/Models/SplitDimension.cs +++ b/WebWindowComplex/Models/SplitDimension.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using WebWindowComplex.Json; +using static WebWindowComplex.Json.WindowConst; namespace WebWindowComplex.Models { @@ -136,6 +137,54 @@ namespace WebWindowComplex.Models } } + public MeasureTypes MeasureType + { + get + { + return m_SelMeasureType; + } + } + + public List MeasureTypeList + { + get + { + return m_MeasureTypeList; + } + } + + public MeasureTypes SelMeasureType + { + get + { + return m_SelMeasureType; + } + set + { + m_SelMeasureType = value; + } + } + + public int SelMeasureTypeIndex + { + get + { + return (int)m_SelMeasureType; + } + set + { + if (m_SelMeasureType != (MeasureTypes)value) + { + m_SelMeasureType = (MeasureTypes)value; + if (m_SelMeasureType.Equals(MeasureTypes.PROPORTIONAL)) + { + dDimension = 1; + } + m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); + } + } + } + #endregion Public Properties #region Public Methods @@ -152,7 +201,7 @@ namespace WebWindowComplex.Models internal JsonSplitDimension Serialize() { - JsonSplitDimension JsonSplitDimension = new JsonSplitDimension(m_bIsRelative, m_dDimension); + JsonSplitDimension JsonSplitDimension = new JsonSplitDimension(m_bIsRelative, m_dDimension, MeasureType); return JsonSplitDimension; } @@ -171,6 +220,11 @@ namespace WebWindowComplex.Models m_bIsVertListDim = value; } + internal void SetMeasureType(MeasureTypes value) + { + m_SelMeasureType = value; + } + #endregion Internal Methods #region Private Fields @@ -181,6 +235,15 @@ namespace WebWindowComplex.Models private double m_dDimension; + private List m_MeasureTypeList = new List + { + new IdNameStruct((int)MeasureTypes.ABSOLUT, "Absolut"), + new IdNameStruct((int)MeasureTypes.PROPORTIONAL, "Proportional"), + new IdNameStruct((int)MeasureTypes.PERCENTAGE, "Percentage"), + }; + + private MeasureTypes m_SelMeasureType; + // reference private Split m_Parent; diff --git a/WebWindowComplex/TableComp.razor.cs b/WebWindowComplex/TableComp.razor.cs index 0d1b445..551f02e 100644 --- a/WebWindowComplex/TableComp.razor.cs +++ b/WebWindowComplex/TableComp.razor.cs @@ -424,6 +424,7 @@ namespace WebWindowComplex case AreaTypes.SASH: { m_SashList.Add((Sash)node); + calculateWidth((Sash)node); break; } case AreaTypes.FILL: @@ -434,6 +435,7 @@ namespace WebWindowComplex case AreaTypes.SPLIT: { m_SplitList.Add((Split)node); + calculateWidth((Split)node); break; } case AreaTypes.SPLITTED: @@ -452,6 +454,92 @@ namespace WebWindowComplex } } + protected void calculateWidth(Area area) + { + if (area is Sash) + { + Sash sash = (Sash)area; + if (area.ParentArea is Frame) + { + Frame frame = (Frame)area.ParentArea; + sash.Width = (frame.DimensionList.Where(x => x.sName == "Width").FirstOrDefault())!.dValue; + } + else if (sash.ParentArea.ParentArea is Split) + { + Split split = (Split)sash.ParentArea.ParentArea; + if (split.SplitVertList.Count > 0) + { + int indexSplit = 0; + for(int i = 0; i < split.AreaList.Count; i++) + { + if (split.AreaList.ElementAt(i).AreaList.First().Equals(sash)) + indexSplit = i; + } + switch (split.SplitVertList.ElementAt(indexSplit).MeasureType) + { + case MeasureTypes.ABSOLUT: + { + sash.Width = split.SplitVertList.ElementAt(indexSplit).dDimension; + break; + } + case MeasureTypes.PROPORTIONAL: + { + /// TO DO!!!!! + break; + } + case MeasureTypes.PERCENTAGE: + { + sash.Width = split.SplitVertList.ElementAt(indexSplit).dDimension / 100 * split.Width; + break; + } + } + } + else + { + Frame frame = (Frame)sash.ParentWindow.AreaList[0]; + sash.Width = (frame.DimensionList.Where(x => x.sName == "Width").FirstOrDefault())!.dValue; + } + } + } + else if (area is Split) + { + Split split = (Split)area; + if (area.ParentArea is Frame) + { + Frame frame = (Frame)area.ParentArea; + split.Width = (frame.DimensionList.Where(x => x.sName == "Width").FirstOrDefault())!.dValue; + } + else if (split.ParentArea.ParentArea is Sash) + { + Sash sash = (Sash)split.ParentArea.ParentArea; + int indexSash = 0; + for (int i = 0; i < sash.AreaList.Count; i++) + { + if (sash.AreaList.ElementAt(i).AreaList.First().Equals(split)) + indexSash = i; + } + switch (sash.SashList.ElementAt(indexSash).MeasureType) + { + case MeasureTypes.ABSOLUT: + { + split.Width = sash.SashList.ElementAt(indexSash).dDimension; + break; + } + case MeasureTypes.PROPORTIONAL: + { + /// TO DO!!!!! + break; + } + case MeasureTypes.PERCENTAGE: + { + split.Width = sash.SashList.ElementAt(indexSash).dDimension / 100 * sash.Width; + break; + } + } + } + } + } + /// /// Calcola CSS warning /// diff --git a/WebWindowComplex/WebWindowComplex.csproj b/WebWindowComplex/WebWindowComplex.csproj index bf62610..ca61afe 100644 --- a/WebWindowComplex/WebWindowComplex.csproj +++ b/WebWindowComplex/WebWindowComplex.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.11.1109 + 2.7.11.1318 Annamaria Sassi Egalware Componente gestione Configurazioni avanzate Window per LUX @@ -49,6 +49,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index 4240629..e554af6 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.11.1109 + 2.7.11.1318 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -69,6 +69,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +