diff --git a/WebWindowComplex/Compo/AreaSash.razor b/WebWindowComplex/Compo/AreaSash.razor index a95d609..da9d293 100644 --- a/WebWindowComplex/Compo/AreaSash.razor +++ b/WebWindowComplex/Compo/AreaSash.razor @@ -11,10 +11,31 @@ } +
+ + +
Dimension - % + @switch (CurrSashDim.MeasureType) + { + case Json.WindowConst.MeasureTypes.ABSOLUT: + { + mm + break; + } + case Json.WindowConst.MeasureTypes.PERCENTAGE: + { + % + break; + } + }
diff --git a/WebWindowComplex/Json/WindowConst.cs b/WebWindowComplex/Json/WindowConst.cs index da32eae..34a7e29 100644 --- a/WebWindowComplex/Json/WindowConst.cs +++ b/WebWindowComplex/Json/WindowConst.cs @@ -118,6 +118,14 @@ namespace WebWindowComplex.Json COMBO = 3 } + public enum MeasureTypes: int + { + NULL = 0, + ABSOLUT = 1, + PROPORTIONAL = 2, + PERCENTAGE = 3 + } + // Specifies the display state of an element. public enum Visibility { diff --git a/WebWindowComplex/Models/Sash.cs b/WebWindowComplex/Models/Sash.cs index 3bd936f..9d9617b 100644 --- a/WebWindowComplex/Models/Sash.cs +++ b/WebWindowComplex/Models/Sash.cs @@ -46,13 +46,13 @@ namespace WebWindowComplex.Models } } - public bool bIsPercentage - { - get - { - return m_bIsPercentage; - } - } + //public bool bIsPercentage + //{ + // get + // { + // return m_bIsPercentage; + // } + //} public bool bIsSashVertical { @@ -128,7 +128,7 @@ namespace WebWindowComplex.Models // aggiungo area Sash di default for (var SplitIndex = m_SashList.Count; SplitIndex <= value - 1; SplitIndex++) { - SashList.Add(new SashDimension(dNewDimension, true, this, SplitIndex + 1)); + SashList.Add(new SashDimension(dNewDimension, MeasureTypes.PERCENTAGE, this, SplitIndex + 1)); } } else if (value < m_SashList.Count) @@ -804,7 +804,7 @@ namespace WebWindowComplex.Models 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)); + SashList.Add(new SashDimension(dNewDimension, MeasureTypes.PERCENTAGE, this, SplitIndex + 1)); } else if (Qty < m_SashList.Count) { @@ -864,8 +864,6 @@ namespace WebWindowComplex.Models private bool m_bIsMeasureGlass; - private bool m_bIsPercentage = true; - private bool m_bIsSashVertical; private bool m_bSashBottomRail; diff --git a/WebWindowComplex/Models/SashDimension.cs b/WebWindowComplex/Models/SashDimension.cs index 4ed2591..1f3350b 100644 --- a/WebWindowComplex/Models/SashDimension.cs +++ b/WebWindowComplex/Models/SashDimension.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using WebWindowComplex.Json; +using WebWindowComplex.Json; using static WebWindowComplex.Json.WindowConst; namespace WebWindowComplex.Models @@ -12,12 +7,12 @@ namespace WebWindowComplex.Models { #region Public Constructors - public SashDimension(double dDimension, bool bIsRelative, Sash Parent, int nSashId) + public SashDimension(double dDimension, MeasureTypes MeasureType, Sash Parent, int nSashId) { m_dDimension = dDimension; - m_bIsRelative = bIsRelative; m_Parent = Parent; m_nSashId = nSashId; + SetMeasureType(MeasureType); // assengno maniglia if (Parent.SashList.Count == 0 || !Parent.SashList.Any(x => x.bHasHandle)) m_bHasHandle = true; @@ -110,14 +105,6 @@ namespace WebWindowComplex.Models } } - public bool bIsRelative - { - get - { - return m_bIsRelative; - } - } - public double dDimension { get @@ -126,69 +113,150 @@ namespace WebWindowComplex.Models } set { - // Controllo che il valore inserito sia compreso tra 0 e 100 - if (value > 0 && value < 100) + double valMax = 0; + bool valueAccept = false; + switch (MeasureType) { - // 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) + case MeasureTypes.ABSOLUT: { - if (m_Parent.bIsPercentage) + valMax = m_Parent.SashList.Sum(x => x.dDimension); + valueAccept = (value < valMax && value > 0) ? true: false; + break; + } + case MeasureTypes.PROPORTIONAL: + { + valMax = m_Parent.SashList.Sum(x => x.dDimension); + break; + } + case MeasureTypes.PERCENTAGE: + { + valMax = 100; + valueAccept = (value < valMax && value > 0) ? true : false; + break; + } + } + if (!MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + { + if (valueAccept) + { + + // verifico se ci sono altri in percentuale + List DimList = m_Parent.SashList.Where(x => x.MeasureType.Equals(MeasureType)).ToList(); + if (DimList.Count > 0) + { + int nIndex = DimList.IndexOf(this); + // se diminuisce dimensione + if (value < m_dDimension) { - 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 + 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 { - double dRes = value; - // se non ultima anta - if (nIndex < RelativeDimList.Count - 1) + m_dDimension = valMax; + return; + } + } + // se aumenta dimensione + else + { + 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 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; - } - - dRes = (100 - dRes); - RelativeDimList[nIndex - 1].SetDimension(dRes); - } - else - { - m_dDimension = 100; - return; + 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; } } } + m_dDimension = value; + m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); } + } + else + { m_dDimension = value; m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); } + //// se sono in percentuale + //if (m_MeasureType.Equals(MeasureTypes.PERCENTAGE)) + //{ + // // Controllo che il valore inserito sia compreso tra 0 e 100 + // if (value > 0 && value < 100) + // { + // // verifico se ci sono altri in percentuale + // List RelativeDimList = m_Parent.SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).ToList(); + // if (RelativeDimList.Count > 0) + // { + // 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; + // } + // dRes = (100 - dRes); + // RelativeDimList[nIndex - 1].SetDimension(dRes); + // } + // else + // { + // m_dDimension = 100; + // return; + // } + // } + // } + // } + // m_dDimension = value; + // m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); + //} } } @@ -204,7 +272,7 @@ namespace WebWindowComplex.Models { get { - return (Openings)m_SelOpeningType; + return m_SelOpeningType; } } @@ -255,13 +323,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 + { + m_SelMeasureType = (MeasureTypes)value; + } + } + #endregion Public Properties #region Public Methods public SashDimension Copy() { - SashDimension newSashDim = new SashDimension(dDimension, bIsRelative, m_Parent, m_nSashId); + SashDimension newSashDim = new SashDimension(dDimension, MeasureType, m_Parent, m_nSashId); + newSashDim.SetMeasureType(MeasureType); newSashDim.SetOpeningType(SelOpeningType); newSashDim.SetHasHandle(bHasHandle); return newSashDim; @@ -292,14 +401,17 @@ namespace WebWindowComplex.Models m_SelOpeningType = value; } + internal void SetMeasureType(MeasureTypes value) + { + m_SelMeasureType = value; + } + #endregion Internal Methods #region Private Fields private bool m_bHasHandle; - private bool m_bIsRelative = false; - private double m_dDimension; private int m_nSashId; @@ -333,11 +445,57 @@ namespace WebWindowComplex.Models //new IdNameStruct((int)Openings.LIFTSLIDE_RIGHT, "←┐") }; + private List m_MeasureTypeList = new List + { + new IdNameStruct((int)MeasureTypes.ABSOLUT, "Absolut"), + new IdNameStruct((int)MeasureTypes.PROPORTIONAL, "Proportional"), + new IdNameStruct((int)MeasureTypes.PERCENTAGE, "Percentage"), + }; + // reference private Sash m_Parent; private Openings m_SelOpeningType; + private MeasureTypes m_SelMeasureType; + #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/WebWindowComplex.csproj b/WebWindowComplex/WebWindowComplex.csproj index ae1d671..0b308b3 100644 --- a/WebWindowComplex/WebWindowComplex.csproj +++ b/WebWindowComplex/WebWindowComplex.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.11.717 + 2.7.11.1015 Annamaria Sassi Egalware Componente gestione Configurazioni avanzate Window per LUX @@ -41,3 +41,7 @@ + + + + diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index 0c5b2ff..dffea52 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.11.717 + 2.7.11.1015 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -48,3 +48,11 @@ + + + + + + + +