- Aggiunta Copy per Inglesina
- Iniziato a sistemare per converisone dimensione Inglesina
This commit is contained in:
+122
-17
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using WebWindowComplex.Compo;
|
||||
using WebWindowComplex.Json;
|
||||
using static WebWindowComplex.Json.WindowConst;
|
||||
|
||||
@@ -281,9 +282,11 @@ namespace WebWindowComplex.Models
|
||||
if (node != null)
|
||||
{
|
||||
if (node.AreaType.Equals(AreaTypes.SASH))
|
||||
UpdateDimSubArea((Sash)node, dim, nameDim);
|
||||
UpdateSash((Sash)node, dim, nameDim);
|
||||
else if (node.AreaType.Equals(AreaTypes.SPLIT))
|
||||
UpdateDimSubArea((Split)node, dim, nameDim);
|
||||
UpdateSplit((Split)node, dim, nameDim);
|
||||
else if (node.AreaType.Equals(AreaTypes.INGLESINA))
|
||||
UpdateSplit((Inglesina)node, dim, nameDim);
|
||||
for (int i = 0; i < node.AreaList.Count; i++)
|
||||
{
|
||||
if (node.AreaType.Equals(AreaTypes.SASH))
|
||||
@@ -295,36 +298,36 @@ namespace WebWindowComplex.Models
|
||||
dimList.Add(new AreaDimension(item.dDimension, item.MeasureType, item.Parent));
|
||||
if (nameDim.Equals("Width") && s.SashList.First().ElementDimensionList.Count > 0)
|
||||
{
|
||||
|
||||
|
||||
if (s.ParentArea.ParentArea is Split)
|
||||
dimTot = dim + s.SashList.First().ElementDimensionList.Last().dOverlap
|
||||
dimTot = dim + s.SashList.First().ElementDimensionList.Last().dOverlap
|
||||
+ s.SashList.Last().ElementDimensionList.ElementAt(1).dOverlap;
|
||||
double widthAnta = s.SashList.ElementAt(i).CalculateAbsoluteValue(dimList, dimTot);
|
||||
if(s.bIsDimensionLight || s.AreaList.ElementAt(i) is Split)
|
||||
if (s.bIsDimensionLight || s.AreaList.ElementAt(i) is Split)
|
||||
widthAnta = widthAnta - s.SashList.ElementAt(i).ElementDimensionList.ElementAt(1).dDimension
|
||||
- s.SashList.ElementAt(i).ElementDimensionList.Last().dDimension;
|
||||
else if(s.AreaList.ElementAt(i).AreaList != null || s.AreaList.ElementAt(i).AreaList.Count > 0)
|
||||
- s.SashList.ElementAt(i).ElementDimensionList.Last().dDimension;
|
||||
else if (s.AreaList.ElementAt(i).AreaList != null || s.AreaList.ElementAt(i).AreaList.Count > 0)
|
||||
{
|
||||
if(s.AreaList.ElementAt(i).AreaList.FirstOrDefault() is Split)
|
||||
if (s.AreaList.ElementAt(i).AreaList.FirstOrDefault() is Split)
|
||||
widthAnta = widthAnta - s.SashList.ElementAt(i).ElementDimensionList.ElementAt(1).dDimension
|
||||
- s.SashList.ElementAt(i).ElementDimensionList.Last().dDimension;
|
||||
- s.SashList.ElementAt(i).ElementDimensionList.Last().dDimension;
|
||||
|
||||
}
|
||||
SearchAreaList(node.AreaList.ElementAt(i), widthAnta, nameDim);
|
||||
}
|
||||
else if(s.SashList.First().ElementDimensionList.Count > 0)
|
||||
else if (s.SashList.First().ElementDimensionList.Count > 0)
|
||||
{
|
||||
if(s.ParentArea is Split split && split.SplitHorizList.Count > 0)
|
||||
if (s.ParentArea is Split split && split.SplitHorizList.Count > 0)
|
||||
dimTot = dimTot + s.SashList.ElementAt(i).ElementDimensionList.First().dOverlap
|
||||
+ s.SashList.ElementAt(i).ElementDimensionList.ElementAt(s.SashList.ElementAt(i).ElementDimensionList.Count() - 2).dOverlap;
|
||||
if(s.SashBottomRailQty > 0)
|
||||
+ s.SashList.ElementAt(i).ElementDimensionList.ElementAt(s.SashList.ElementAt(i).ElementDimensionList.Count() - 2).dOverlap;
|
||||
if (s.SashBottomRailQty > 0)
|
||||
{
|
||||
foreach (var bottomRail in s.BottomRailElemDimList)
|
||||
dimTot = dimTot - bottomRail.dDimension
|
||||
+ bottomRail.dOverlap;
|
||||
+ bottomRail.dOverlap;
|
||||
}
|
||||
dimTot = dimTot - s.SashList.ElementAt(i).ElementDimensionList.First().dDimension
|
||||
- s.SashList.ElementAt(i).ElementDimensionList.ElementAt(s.SashList.ElementAt(i).ElementDimensionList.Count() - 2).dDimension;
|
||||
- s.SashList.ElementAt(i).ElementDimensionList.ElementAt(s.SashList.ElementAt(i).ElementDimensionList.Count() - 2).dDimension;
|
||||
SearchAreaList(node.AreaList.ElementAt(i), dimTot, nameDim);
|
||||
}
|
||||
}
|
||||
@@ -339,9 +342,9 @@ namespace WebWindowComplex.Models
|
||||
dimList.Add(new AreaDimension(item.dDimension, item.MeasureType, item.Parent));
|
||||
if (nameDim.Equals("Width"))
|
||||
{
|
||||
if(s.AreaList.ElementAt(i).AreaList.First() is Sash sash && sash != null)
|
||||
if (s.AreaList.ElementAt(i).AreaList.First() is Sash sash && sash != null)
|
||||
dimTot = dimTot + sash.SashList.Last().ElementDimensionList.ElementAt(1).dOverlap
|
||||
+ sash.SashList.First().ElementDimensionList.Last().dOverlap;
|
||||
+ sash.SashList.First().ElementDimensionList.Last().dOverlap;
|
||||
SearchAreaList(node.AreaList.ElementAt(i), dimTot, nameDim);
|
||||
}
|
||||
else
|
||||
@@ -369,6 +372,108 @@ namespace WebWindowComplex.Models
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateSash(Sash sash, double dim, string nameDim)
|
||||
{
|
||||
if (nameDim.Equals("Width"))
|
||||
{
|
||||
int countAbsolute = sash.SashList.Where(x => x.MeasureType.Equals(MeasureTypes.ABSOLUTE)).Count();
|
||||
int countProportional = sash.SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).Count();
|
||||
int countPercentage = sash.SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).Count();
|
||||
List<AreaDimension> dimList = new();
|
||||
Split split = new Split(null, null);
|
||||
if (sash.ParentArea.ParentArea is Split)
|
||||
split = (Split)sash.ParentArea.ParentArea;
|
||||
if (sash.ParentArea is Frame || (sash.ParentArea.ParentArea is Split && split.SplitHorizList.Count > 0))
|
||||
{
|
||||
Frame? frame = sash.m_ParentWindow.AreaList.FirstOrDefault();
|
||||
if (frame != null)
|
||||
{
|
||||
foreach (var i in frame.DimensionList)
|
||||
dimList.Add(new AreaDimension(i.dDimension, i.SelMeasureType, i.Parent));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var i in split.SplitVertList)
|
||||
dimList.Add(new AreaDimension(i.dDimension, i.SelMeasureType, i.Parent));
|
||||
}
|
||||
if (countAbsolute == sash.SashList.Count)
|
||||
{
|
||||
double sum = sash.SashList.Sum(x => x.dDimension);
|
||||
if ((sash.ParentArea.ParentArea is Split && split.SplitHorizList.Count > 0))
|
||||
{
|
||||
for (int i = 1; i < sash.SashList.Count; i++)
|
||||
dim = dim + sash.SashList.ElementAt(i).ElementDimensionList.Last().dOverlap;
|
||||
}
|
||||
else if (sash.ParentArea.ParentArea is Split && split.SplitVertList.Count > 0)
|
||||
{
|
||||
dim = dim + sash.SashList.First().ElementDimensionList.ElementAt(1).dOverlap
|
||||
+ sash.SashList.First().ElementDimensionList.Last().dOverlap;
|
||||
}
|
||||
if (sash.bIsDimensionLight)
|
||||
{
|
||||
dim = dim - sash.SashList.First().ElementDimensionList.ElementAt(1).dDimension
|
||||
- sash.SashList.First().ElementDimensionList.Last().dDimension;
|
||||
for (int i = 1; i < sash.SashList.Count; i++)
|
||||
dim = dim - sash.SashList[i].ElementDimensionList.ElementAt(1).dDimension
|
||||
- sash.SashList[i].ElementDimensionList.Last().dDimension
|
||||
+ sash.SashList[i].ElementDimensionList.Last().dOverlap;
|
||||
}
|
||||
else if (sash.SashList.Count > 1)
|
||||
{
|
||||
for (int i = 1; i < sash.SashList.Count; i++)
|
||||
dim = dim + sash.SashList[i].ElementDimensionList.Last().dOverlap;
|
||||
}
|
||||
double res = dim - sum;
|
||||
foreach (var sashDim in sash.SashList)
|
||||
sashDim.SetDimension(sashDim.dDimension + res / countAbsolute);
|
||||
}
|
||||
else if (countAbsolute < sash.SashList.Count && countPercentage != sash.SashList.Count && countProportional != sash.SashList.Count)
|
||||
{
|
||||
if (countPercentage > 0 && countPercentage <= sash.SashList.Count && countProportional == 0)
|
||||
{
|
||||
double sumAbsolute = sash.SashList.Where(x => x.MeasureType.Equals(MeasureTypes.ABSOLUTE)).Sum(x => x.dDimension);
|
||||
var percentageList = sash.SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).ToList();
|
||||
foreach (var i in percentageList)
|
||||
i.SetDimension(i.ConvertAbsoluteIn(dimList, (dim - sumAbsolute) / countPercentage, i.MeasureType, dim));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateSplit(Split split, double dim, string nameDim)
|
||||
{
|
||||
List<SplitDimension> splitList = new();
|
||||
List<SplitElementDimension> elemList = new();
|
||||
double sum = 0;
|
||||
if (nameDim.Equals("Width"))
|
||||
{
|
||||
splitList = split.SplitVertList;
|
||||
elemList = split.ElemDimVertList;
|
||||
}
|
||||
else
|
||||
{
|
||||
splitList = split.SplitHorizList;
|
||||
elemList = split.ElemDimHorizList;
|
||||
}
|
||||
int countAbsolute = splitList.Where(x => x.MeasureType.Equals(MeasureTypes.ABSOLUTE)).Count();
|
||||
if (countAbsolute != 0 && countAbsolute == splitList.Count)
|
||||
{
|
||||
sum = sum + splitList.Sum(x => x.dDimension);
|
||||
List<AreaDimension> dimensionList = new();
|
||||
foreach (var i in splitList)
|
||||
dimensionList.Add(new AreaDimension(i.dDimension, i.MeasureType, i.Parent));
|
||||
double widthGlass = dim;
|
||||
foreach (var item in elemList)
|
||||
widthGlass = widthGlass - item.dDimension;
|
||||
foreach (var item in splitList)
|
||||
{
|
||||
double widthPerc = item.ConvertDimension(dimensionList, item.MeasureType, MeasureTypes.PERCENTAGE, sum, splitList.IndexOf(item));
|
||||
item.SetDimension(widthGlass * widthPerc / 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateDimSubArea(Area area, double dim, string nameDim)
|
||||
{
|
||||
if (area is Sash sash && nameDim.Equals("Width"))
|
||||
|
||||
Reference in New Issue
Block a user