diff --git a/Test.UI/Components/Pages/EditJWD.razor.cs b/Test.UI/Components/Pages/EditJWD.razor.cs index 3891743..3e41df8 100644 --- a/Test.UI/Components/Pages/EditJWD.razor.cs +++ b/Test.UI/Components/Pages/EditJWD.razor.cs @@ -126,7 +126,7 @@ namespace Test.UI.Components.Pages protected override async Task OnInitializedAsync() { ConfInit(); - //InitialJwd = File.ReadAllText("Data\\FinestraDueAnteSeparate.jwd"); + //InitialJwd = File.ReadAllText("Data\\FinestraSplitVert.jwd"); InitialJwd = File.ReadAllText("Data\\AntaDoppia.jwd"); currJwd = InitialJwd; // rileggo altri dati diff --git a/Test.UI/appsettings.json b/Test.UI/appsettings.json index 4dfc168..4c35289 100644 --- a/Test.UI/appsettings.json +++ b/Test.UI/appsettings.json @@ -10,14 +10,14 @@ "Redis": "redis.ufficio:26379, serviceName=devel, DefaultDatabase=6, keepAlive=180, connectTimeout=15000, syncTimeout=15000, asyncTimeout=15000, abortConnect=false, ssl=false, allowAdmin=true" }, "ServerConf": { - "ChannelPng": "Egw:png:img", - "ChannelSvg": "Egw:svg:img", - "ChannelShape": "Egw:shape:curr", - "ChannelHwList": "Egw:hw:list", - "ChannelHwOpt": "Egw:hw:opt", - "ChannelProfList": "Egw:prof:list", - "ChannelBom": "Egw:bom", - "ChannelUpdate": "Egw:update", + "ChannelPng": "lux:png:img", + "ChannelSvg": "lux:svg:img", + "ChannelShape": "lux:shape:curr", + "ChannelHwList": "lux:hw:list", + "ChannelHwOpt": "lux:hw:opt", + "ChannelProfList": "lux:prof:list", + "ChannelBom": "lux:bom", + "ChannelUpdate": "lux:update", "ChannelPub": "EgwEngineInput", "ChannelSub": "EgwEngineOutput", diff --git a/WebWindowComplex/Compo/AreaSash.razor b/WebWindowComplex/Compo/AreaSash.razor index da9d293..0d9473e 100644 --- a/WebWindowComplex/Compo/AreaSash.razor +++ b/WebWindowComplex/Compo/AreaSash.razor @@ -1,4 +1,5 @@ -
+@using EgwCoreLib.Razor +
Sash @(CurrSashGroup.SashList.Count == 1 ? "" : (IndexSash + 1))
@@ -11,7 +12,7 @@ }
-
+ @*
-
+
*@
Dimension - - @switch (CurrSashDim.MeasureType) - { - case Json.WindowConst.MeasureTypes.ABSOLUT: - { - mm - break; - } - case Json.WindowConst.MeasureTypes.PERCENTAGE: - { - % - break; - } - } + + @* *@ +
diff --git a/WebWindowComplex/Compo/AreaSash.razor.cs b/WebWindowComplex/Compo/AreaSash.razor.cs index 997b23d..f217e26 100644 --- a/WebWindowComplex/Compo/AreaSash.razor.cs +++ b/WebWindowComplex/Compo/AreaSash.razor.cs @@ -1,4 +1,7 @@ +using EgwCoreLib.Razor; using Microsoft.AspNetCore.Components; +using Newtonsoft.Json.Linq; +using System; using WebWindowComplex.Models; namespace WebWindowComplex.Compo @@ -43,7 +46,7 @@ namespace WebWindowComplex.Compo get { if(CurrSashGroup.AreaList[IndexSash] is Splitted) -{ + { return CurrSashGroup.AreaList[IndexSash]; } else @@ -57,6 +60,26 @@ namespace WebWindowComplex.Compo } } + public int CssDecimals() + { + switch (CurrSashDim.MeasureType) + { + case Json.WindowConst.MeasureTypes.ABSOLUT: + { + return 2; + } + case Json.WindowConst.MeasureTypes.PROPORTIONAL: + { + return 0; + } + case Json.WindowConst.MeasureTypes.PERCENTAGE: + { + return 1; + } + } + return 0; + } + /// /// Sollevo evento per cambiare l'anta su cui è presente la maniglia /// diff --git a/WebWindowComplex/Compo/CardSplit.razor b/WebWindowComplex/Compo/CardSplit.razor index 568ba2f..df5adc9 100644 --- a/WebWindowComplex/Compo/CardSplit.razor +++ b/WebWindowComplex/Compo/CardSplit.razor @@ -69,41 +69,71 @@
@if (CurrItem.SplitVertList.Count > 0 && CurrItem.SplitHorizList.Count > 0) { -
+
@foreach (var dim in CurrItem.SplitVertList) { -
- - -
Width - % +
}
-
+
@foreach (var dim in CurrItem.SplitHorizList) { -
- - -
Height - % +
}
@@ -112,20 +142,35 @@ { @foreach (var dim in CurrItem.SplitHorizList) { -
-
- - -
+
Height - % +
} @@ -134,20 +179,35 @@ { @foreach (var dim in CurrItem.SplitVertList) { -
-
- - -
+
Width - % +
} diff --git a/WebWindowComplex/Models/FrameDimension.cs b/WebWindowComplex/Models/FrameDimension.cs index 6c6feac..2a71c14 100644 --- a/WebWindowComplex/Models/FrameDimension.cs +++ b/WebWindowComplex/Models/FrameDimension.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 { @@ -41,6 +42,8 @@ namespace WebWindowComplex.Models { m_dValue = MinDim; } + //if(ParentFrame.AreaList.Count > 0) + // SearchAreaList(ParentFrame); m_ParentFrame.ParentWindow.OnUpdatePreview(m_ParentFrame.ParentWindow.sSerialized()); } } @@ -73,6 +76,115 @@ namespace WebWindowComplex.Models #region Internal Methods + /// + /// Cerca nell'albero gli oggetti Sash e Split per associare la larghezza + /// + /// + //protected void SearchAreaList(Area node) + //{ + // if (node != null) + // { + // if(node.AreaType.Equals(AreaTypes.SASH)) + // calculateWidth((Sash)node); + // else if(node.AreaType.Equals(AreaTypes.SPLIT)) + // calculateWidth((Split)node); + // foreach (var item in node.AreaList) + // { + // SearchAreaList(item); + // } + // } + //} + + /// + /// Ricalcolo larghezza Sash e SPlit + /// + /// + //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; + // } + // } + // } + // } + //} + internal JsonFrameDimension Serialize() { JsonFrameDimension JsonFrameDimension = new JsonFrameDimension(m_nIndex, m_sName, m_dValue); diff --git a/WebWindowComplex/Models/Sash.cs b/WebWindowComplex/Models/Sash.cs index c7f82af..0255e20 100644 --- a/WebWindowComplex/Models/Sash.cs +++ b/WebWindowComplex/Models/Sash.cs @@ -34,20 +34,51 @@ namespace WebWindowComplex.Models #region Public Properties - /// - /// Larghezza gruppo ante - /// - public double Width - { - get - { - return m_Width; - } - set - { - m_Width = value; - } - } + ///// + ///// Larghezza gruppo ante + ///// + //public double Width + //{ + // get + // { + // return m_Width; + // } + // set + // { + // if (m_Width != value && m_Width != 0) + // { + // // Se larghezza aumentata + // if (SashList.Sum(x => x.CalculateAbsolutValue(m_Width)) < value) + // { + // if (SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count == 0 && + // SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).ToList().Count != SashList.Count) + // { + // double res = value - m_Width; + // foreach (var item in SashList) + // item.SetDimension(item.ConvertIn(item.CalculateAbsolutValue(m_Width) + res / SashList.Count, (MeasureTypes)item.SelMeasureTypeIndex, value)); + // } + // } + // // Larghezza diminuita + // else if (SashList.Sum(x => x.CalculateAbsolutValue(m_Width)) > value) + // { + // if (SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count == 0 && + // SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).ToList().Count != SashList.Count) + // { + // double res = m_Width - value; + // foreach (var item in SashList) + // item.SetDimension(item.ConvertIn(item.CalculateAbsolutValue(m_Width) - res / SashList.Count, (MeasureTypes)item.SelMeasureTypeIndex, value)); + // } + // } + // m_Width = value; + // m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + // } + // else + // { + // m_Width = value; + // m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + // } + // } + //} public bool bIsMeasureGlass { @@ -158,7 +189,8 @@ namespace WebWindowComplex.Models itemDelete = m_SashList[SplitIndex]; SashList.RemoveAt(SplitIndex); } - double deleteDim = itemDelete.ConvertDimension(itemDelete.SelMeasureType, m_SashList[SashList.Count - 1].SelMeasureType); + double widthTot = CalculateWidthSashGroup(ParentWindow.AreaList.First(), ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dValue); + double deleteDim = itemDelete.ConvertDimension(itemDelete.SelMeasureType, m_SashList[SashList.Count - 1].SelMeasureType, widthTot); //dLastDimension += m_SashList[SashList.Count - 1].dDimension; dLastDimension = deleteDim + m_SashList[SashList.Count - 1].dDimension; SashList[SashList.Count - 1].SetDimension(dLastDimension); @@ -570,7 +602,64 @@ namespace WebWindowComplex.Models #endregion Public Methods #region Internal Methods - + internal double CalculateWidthSashGroup(Area area, double width) + { + if (area.Equals(this)) + return width; + for (int i = 0; i < area.AreaList.Count; i++) + { + Area item = area.AreaList[i]; + if (area is Split) + { + Split split = (Split)area; + switch (split.SplitVertList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUT: + { + CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PROPORTIONAL: + { + //CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PERCENTAGE: + { + CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension * width / 100); + break; + } + } + } + else if (area is Sash) + { + Sash sash = (Sash)area; + switch (sash.SashList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUT: + { + CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PROPORTIONAL: + { + //CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PERCENTAGE: + { + CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension * width / 100); + break; + } + } + } + else + { + CalculateWidthSashGroup(item, width); + } + } + return -1; + } internal static Sash CreateSash(Area Area) { Sash newSash = new Sash(Area, Area.ParentWindow); @@ -909,8 +998,6 @@ namespace WebWindowComplex.Models 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 bf27283..16161f3 100644 --- a/WebWindowComplex/Models/SashDimension.cs +++ b/WebWindowComplex/Models/SashDimension.cs @@ -1,4 +1,5 @@ -using WebWindowComplex.Json; +using System.Security.Principal; +using WebWindowComplex.Json; using static WebWindowComplex.Json.WindowConst; namespace WebWindowComplex.Models @@ -113,42 +114,96 @@ namespace WebWindowComplex.Models } set { - double valMax = 0; + double widthTot = CalculateWidthSashGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dValue); + double valMinAbsolut = 100; + double valMaxAbsolut = widthTot - valMinAbsolut * (m_Parent.SashList.Count - 1); bool valueAccept = false; switch (MeasureType) { case MeasureTypes.ABSOLUT: { - valMax = m_Parent.Width; - valueAccept = (value < valMax && value > 0) ? true : false; + valueAccept = (value < valMaxAbsolut && value > valMinAbsolut) ? true : false; break; } case MeasureTypes.PROPORTIONAL: { - valMax = 20; - valueAccept = true ; + valMaxAbsolut = 20; + valueAccept = (value > 1) ? true : false; break; } case MeasureTypes.PERCENTAGE: { - valMax = 100; - valueAccept = (value < valMax && value > 0) ? true : false; + valMaxAbsolut = valMaxAbsolut / widthTot * 100; + valMinAbsolut = valMinAbsolut / widthTot * 100; + valueAccept = (value < valMaxAbsolut && value > valMinAbsolut) ? true : false; break; } } if (valueAccept) { - double widthTot = m_Parent.Width; - List dimensions = m_Parent.SashList; + List dimensions = m_Parent.SashList; List absolutValList = new List(); - foreach(var item in m_Parent.SashList) + foreach (var item in m_Parent.SashList) { 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) + int percentageCount = dimensions.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).ToList().Count; + // Le dimensioni sono solo in proporzionale + if (proportionalCount == absolutValList.Count) + { + m_dDimension = value; + } + // Le dimensioni sono solo in percentuale + else if (percentageCount == dimensions.Count) + { + if (value < dDimension) + { + // L'anta modificata non è l'ultima + if (nIndex < dimensions.Count - 1) + dimensions[nIndex + 1].SetDimension(dimensions[nIndex + 1].dDimension + (m_dDimension - value)); + else if (dimensions.Count > 1) + dimensions[nIndex - 1].SetDimension(dimensions[nIndex - 1].dDimension + (m_dDimension - value)); + else + { + m_dDimension = 100; + return; + } + } + else + { + double dRes = value; + // se non ultima anta + if (nIndex < dimensions.Count - 1) + { + for (var nInd = 0; nInd <= nIndex - 1; nInd++) + dRes += dimensions[nInd].dDimension; + dRes = (100 - dRes) / (dimensions.Count - nIndex - 1); + for (var Ind = nIndex + 1; Ind <= dimensions.Count - 1; Ind++) + dimensions[Ind].SetDimension(dRes); + } + // se ultima anta + else if (dimensions.Count > 1) + { + if (dimensions.Count > 2) + { + for (var Ind = 0; Ind <= nIndex - 2; Ind++) + dRes += dimensions[Ind].dDimension; + } + dRes = (100 - dRes); + dimensions[nIndex - 1].SetDimension(dRes); + } + else + { + m_dDimension = 100; + return; + } + } + m_dDimension = value; + } + // Le dimensioni sono miste o solo in assoluto + else { double valueInAbsolute = 0; switch (MeasureType) @@ -204,78 +259,75 @@ namespace WebWindowComplex.Models } if (MeasureType.Equals(MeasureTypes.PROPORTIONAL)) m_dDimension = value; - for(int i = 0; i < absolutValList.Count; i++) + 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; - } + 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()); - //} + //// 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()); + //} } } @@ -381,7 +433,8 @@ namespace WebWindowComplex.Models if(m_SelMeasureType != (MeasureTypes)value) { MeasureTypes newType = (MeasureTypes)value; - m_dDimension = ConvertDimension(m_SelMeasureType, newType); + double widthTot = CalculateWidthSashGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dValue); + m_dDimension = ConvertDimension(m_SelMeasureType, newType, widthTot); m_SelMeasureType = (MeasureTypes)value; m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); } @@ -398,7 +451,7 @@ namespace WebWindowComplex.Models /// Vecchio tipo /// Nuovo tipo /// - public double ConvertDimension(MeasureTypes oldType, MeasureTypes newType) + public double ConvertDimension(MeasureTypes oldType, MeasureTypes newType, double widthTot) { switch (oldType) { @@ -406,33 +459,37 @@ namespace WebWindowComplex.Models { if (newType.Equals(MeasureTypes.PERCENTAGE)) { - return Double.Round((m_dDimension / m_Parent.Width) * 100, 0); + //return Double.Round((m_dDimension / m_Parent.Width) * 100, 1); + return (m_dDimension / widthTot) * 100; } else { - return ricalculatePropVal(); + return CalculatePropVal(widthTot); } } case MeasureTypes.PROPORTIONAL: { if (newType.Equals(MeasureTypes.ABSOLUT)) { - return Double.Round(convertFromPropVal(newType), 2); + //return Double.Round(ConvertFromPropVal(newType), 2); + return ConvertFromPropVal(newType, widthTot); } else { - return Double.Round(convertFromPropVal(newType)); + //return Double.Round(ConvertFromPropVal(newType), 1); + return ConvertFromPropVal(newType, widthTot); } } case MeasureTypes.PERCENTAGE: { if (newType.Equals(MeasureTypes.ABSOLUT)) { - return Double.Round((m_dDimension * m_Parent.Width) / 100); + //return Double.Round((m_dDimension * m_Parent.Width) / 100, 2); + return (m_dDimension * widthTot) / 100; } else { - return Double.Round(ricalculatePropVal()); + return CalculatePropVal(widthTot); } } } @@ -456,6 +513,72 @@ namespace WebWindowComplex.Models #region Internal Methods + internal double CalculateWidthSashGroup(Area area, double width) + { + for(int i = 0; i < area.AreaList.Count; i++) + { + double risultato = -1; + if (area.Equals(m_Parent)) + return width; + Area item = area.AreaList[i]; + if(area is Split) + { + Split split = (Split)area; + switch (split.SplitVertList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUT: + { + risultato = CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PROPORTIONAL: + { + //risultato = CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PERCENTAGE: + { + risultato = CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension * width / 100); + break; + } + } + if (risultato != -1) + return risultato; + } + else if (area is Sash) + { + Sash sash = (Sash)area; + switch (sash.SashList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUT: + { + risultato = CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PROPORTIONAL: + { + //risultato = CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PERCENTAGE: + { + risultato = CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension * width / 100); + break; + } + } + if (risultato != -1) + return risultato; + } + else + { + risultato = CalculateWidthSashGroup(item, width); + if (risultato != -1) + return risultato; + } + } + return width; + } + internal JsonSashDimension Serialize() { JsonSashDimension JsonSashDimension = new JsonSashDimension(OpeningType, MeasureType, m_bHasHandle, m_dDimension, m_nSashId); @@ -487,20 +610,23 @@ namespace WebWindowComplex.Models /// /// Larghezza totale /// - internal double CalculateAbsolutValue(double widthTot) + public double CalculateAbsolutValue(double widthTot) { switch (MeasureType) { case MeasureTypes.ABSOLUT: { + //return Double.Round(dDimension, 2); return dDimension; } case MeasureTypes.PROPORTIONAL: { - return calculatePropVal(); + //return Double.Round(Proportional2AbsolutVal(), 2); + return Proportional2AbsolutVal(widthTot); } case MeasureTypes.PERCENTAGE: { + //return Double.Round((dDimension / 100) * widthTot, 1); return (dDimension / 100) * widthTot; } } @@ -514,20 +640,23 @@ namespace WebWindowComplex.Models /// Tipo di misura della dimensione /// Larghezza totale /// - internal double ConvertIn(double absolutVal, MeasureTypes type, double widthTot) + public double ConvertIn(double absolutVal, MeasureTypes type, double widthTot) { switch (type) { case MeasureTypes.ABSOLUT: { + //return Double.Round(absolutVal, 2); return absolutVal; } case MeasureTypes.PROPORTIONAL: { - return calculatePropVal(); + //return Proportional2AbsolutVal(); + return Proportional2AbsolutVal(widthTot); } case MeasureTypes.PERCENTAGE: { + //return Double.Round((absolutVal / widthTot) * 100, 1); return (absolutVal / widthTot) * 100; } } @@ -539,9 +668,9 @@ namespace WebWindowComplex.Models /// /// /// - internal double convertFromPropVal(MeasureTypes newType) + internal double ConvertFromPropVal(MeasureTypes newType, double widthTot) { - double tot = m_Parent.Width; + double tot = widthTot; //Somma misura non proporzionali double sumNotProp = m_Parent.SashList .Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL && !m.Equals(this)) @@ -570,9 +699,9 @@ namespace WebWindowComplex.Models /// Metodo per calcolare il valore proporzionale /// /// - internal double calculatePropVal() + internal double Proportional2AbsolutVal(double widthTot) { - double tot = m_Parent.Width; + double tot = widthTot; //Somma misura non proporzionali double sumNotProp = m_Parent.SashList .Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL) @@ -595,14 +724,15 @@ namespace WebWindowComplex.Models /// /// /// - public static double CalcolaMCD(double a, double b) + internal static double CalcolaMCD(double a, double b) { - while (b != 0) + while (b >= 0.01) { double temp = b; b = a % b; a = temp; } + //return Double.Round(a,2); return a; } @@ -610,7 +740,7 @@ namespace WebWindowComplex.Models /// Metodo per ricalcolare i valori proporzionali a causa della modifica di uno /// /// - internal double ricalculatePropVal() + internal double CalculatePropVal(double widthTot) { if(m_Parent.SashList.Where(m => m.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count == 0) { @@ -619,7 +749,7 @@ namespace WebWindowComplex.Models List absolutValue = new List(); foreach (var item in m_Parent.SashList) { - absolutValue.Add(item.CalculateAbsolutValue(m_Parent.Width)); + absolutValue.Add(item.CalculateAbsolutValue(widthTot)); } for(int i = 0; i < m_Parent.SashList.Count; i++) { @@ -630,12 +760,16 @@ namespace WebWindowComplex.Models if (absolutValue.ElementAt(nIndex) <= absolutValue.ElementAt(i)) { var mcd = CalcolaMCD(absolutValue.ElementAt(nIndex), absolutValue.ElementAt(i)); + //m_Parent.SashList.ElementAt(i).m_dDimension = Double.Round(absolutValue.ElementAt(i) / mcd, 2); + //m_dDimension = Double.Round(absolutValue.ElementAt(nIndex) / mcd, 2); 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 = Double.Round(absolutValue.ElementAt(i) / mcd, 2); + //m_dDimension = Double.Round(absolutValue.ElementAt(nIndex) / mcd, 2); m_Parent.SashList.ElementAt(i).m_dDimension = absolutValue.ElementAt(i) / mcd; m_dDimension = absolutValue.ElementAt(nIndex) / mcd; } diff --git a/WebWindowComplex/Models/Split.cs b/WebWindowComplex/Models/Split.cs index b07be20..6833f1c 100644 --- a/WebWindowComplex/Models/Split.cs +++ b/WebWindowComplex/Models/Split.cs @@ -23,17 +23,17 @@ namespace WebWindowComplex.Models /// /// Larghezza gruppo split /// - public double Width - { - get - { - return m_Width; - } - set - { - m_Width = value; - } - } + //public double Width + //{ + // get + // { + // return m_Width; + // } + // set + // { + // m_Width = value; + // } + //} public bool bIsPercentage { @@ -487,7 +487,7 @@ namespace WebWindowComplex.Models private List m_SplitVertList = new List(); - private double m_Width = 0; + //private double m_Width = 0; #endregion Private Fields } diff --git a/WebWindowComplex/TableComp.razor.cs b/WebWindowComplex/TableComp.razor.cs index 551f02e..0557c97 100644 --- a/WebWindowComplex/TableComp.razor.cs +++ b/WebWindowComplex/TableComp.razor.cs @@ -424,7 +424,6 @@ namespace WebWindowComplex case AreaTypes.SASH: { m_SashList.Add((Sash)node); - calculateWidth((Sash)node); break; } case AreaTypes.FILL: @@ -435,7 +434,6 @@ namespace WebWindowComplex case AreaTypes.SPLIT: { m_SplitList.Add((Split)node); - calculateWidth((Split)node); break; } case AreaTypes.SPLITTED: @@ -454,91 +452,91 @@ 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; - } - } - } - } - } + //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: + // { + // //split.Width = Proportional2AbsolutVal(split); + // break; + // } + // case MeasureTypes.PERCENTAGE: + // { + // split.Width = sash.SashList.ElementAt(indexSash).dDimension / 100 * sash.Width; + // break; + // } + // } + // } + // } + //} /// /// Calcola CSS warning diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index e554af6..99e62b5 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.11.1318 + 2.7.11.1815 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -165,6 +165,16 @@ + + + + + + + + + +