615 lines
28 KiB
C#
615 lines
28 KiB
C#
using System.Linq;
|
|
using WebWindowComplex.Compo;
|
|
using WebWindowComplex.Json;
|
|
using static WebWindowComplex.Json.WindowConst;
|
|
|
|
namespace WebWindowComplex.Models
|
|
{
|
|
public abstract class Area
|
|
{
|
|
#region Public Constructors
|
|
|
|
public Area(Area ParentArea, Window ParentWindow)
|
|
{
|
|
m_ParentWindow = ParentWindow;
|
|
m_ParentArea = ParentArea;
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Properties
|
|
|
|
public static int nCounterGroup
|
|
{
|
|
get => m_CounterGroup;
|
|
set => m_CounterGroup = value;
|
|
}
|
|
|
|
public List<Area> AreaList
|
|
{
|
|
get
|
|
{
|
|
return m_AreaList;
|
|
}
|
|
set
|
|
{
|
|
m_AreaList = value;
|
|
}
|
|
}
|
|
|
|
public AreaTypes AreaType
|
|
{
|
|
get
|
|
{
|
|
return m_AreaType;
|
|
}
|
|
set
|
|
{
|
|
m_AreaType = value;
|
|
}
|
|
}
|
|
|
|
public int GroupId
|
|
{
|
|
get
|
|
{
|
|
return m_GroupId;
|
|
}
|
|
|
|
set
|
|
{
|
|
m_GroupId = value;
|
|
}
|
|
}
|
|
|
|
public int nAreaId
|
|
{
|
|
get
|
|
{
|
|
return m_nAreaId;
|
|
}
|
|
set
|
|
{
|
|
m_nAreaId = value;
|
|
}
|
|
}
|
|
|
|
public Area ParentArea
|
|
{
|
|
get
|
|
{
|
|
return m_ParentArea;
|
|
}
|
|
}
|
|
|
|
public Window ParentWindow
|
|
{
|
|
get
|
|
{
|
|
return m_ParentWindow;
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public static void AddCounterGroup()
|
|
{
|
|
m_CounterGroup++;
|
|
}
|
|
|
|
public void AddFirstSash()
|
|
{
|
|
// Salvo il parent
|
|
Frame? f = null;
|
|
if(this is Frame || ParentArea.AreaList.Last().Equals(this))
|
|
{
|
|
if (this is Frame)
|
|
f = (Frame)this;
|
|
else
|
|
f = (Frame)ParentWindow.AreaList.First();
|
|
f.BottomRailQty = 0;
|
|
f.BottomRailElemDimList.Clear();
|
|
}
|
|
// Creo area sash di default
|
|
Sash SashArea = Sash.CreateSash(this);
|
|
// Inserisco famiglia hardware vuota
|
|
SashArea.SetSelFamilyHardware("");
|
|
// Inserisco hardware di default
|
|
SashArea.SetSelHardwareFromId("000000");
|
|
if(f != null && (f.SelShapeIndex == (int)Shapes.ARC
|
|
|| f.SelShapeIndex == (int)Shapes.DOUBLEARC
|
|
|| f.SelShapeIndex == (int)Shapes.ARC_FULL
|
|
|| f.SelShapeIndex == (int)Shapes.THREECENTERARC))
|
|
{
|
|
if(SashArea.SashList.FirstOrDefault() != null)
|
|
{
|
|
int joint = SashArea.SashList.FirstOrDefault()!.JointList.Count - 1;
|
|
SashArea.SashList.FirstOrDefault()!.JointList.ElementAt(joint).SelJointTypeIndex = (int) Joints.ANGLED;
|
|
}
|
|
if (SashArea.SashList.LastOrDefault() != null)
|
|
{
|
|
SashArea.SashList.LastOrDefault()!.JointList.ElementAt(2).SelJointTypeIndex = (int)Joints.ANGLED;
|
|
}
|
|
// SashArea.SashArcElem = new SashArcElement(SashArea, ParentWindow, 10, true);
|
|
}
|
|
//else
|
|
// SashArea.SashArcElem = null;
|
|
// Salvo gli oggetti già presenti e li cancello da AreaList
|
|
List <Area> ContentArea = new List<Area>();
|
|
ContentArea.Add(AreaList[0]);
|
|
AreaList.Remove(AreaList[0]);
|
|
// Aggiungo area
|
|
AreaList.Add(SashArea);
|
|
// Inserisco il riempimento precedente
|
|
AreaList[0].AreaList.Add(ContentArea[0]);
|
|
AreaList[0].AreaList[0].SetParentArea(AreaList[0]);
|
|
}
|
|
|
|
public void AddSplit()
|
|
{
|
|
// Salvo il parent
|
|
Area ParentArea = AreaList[0].ParentArea;
|
|
List<Area> ContentArea = new List<Area>();
|
|
// Salvo gli oggetti già presenti e li cancello da AreaList
|
|
ContentArea.Add(AreaList[0]);
|
|
AreaList.Remove(AreaList[0]);
|
|
// Aggiungo Area split di default
|
|
Split SplitArea = Split.CreateSplit(this, SplitShapes.HORIZONTAL);
|
|
// imposto i parametri di default
|
|
SplitArea.SetSplitStartVert(false);
|
|
SplitArea.SetSplitQtyHoriz(1, 0);
|
|
// Aggiungo area
|
|
AreaList.Add(SplitArea);
|
|
// Creo le due aree Splitted
|
|
List<Splitted> newSplittedList = new List<Splitted>();
|
|
for (int i = 0; i < 2; i++)
|
|
newSplittedList.Add(Splitted.CreateSplitted(SplitArea));
|
|
// Inserisco nelle aree Splitted Fill e la struttura precedente (e setto ParentArea del fill)
|
|
ContentArea[0].SetParentArea(newSplittedList[1]);
|
|
newSplittedList[0].AreaList.Add(ContentArea[0]);
|
|
if (ContentArea[0] is Fill fill1)
|
|
{
|
|
Fill fill2 = Fill.CreateFill(newSplittedList[1], fill1.FillType);
|
|
newSplittedList[1].AreaList.Add(fill2);
|
|
}
|
|
else
|
|
{
|
|
Fill fill2 = Fill.CreateFill(newSplittedList[1], FillTypes.GLASS);
|
|
newSplittedList[1].AreaList.Add(fill2);
|
|
}
|
|
// All'area Split aggiunto le due aree Splitted
|
|
for (int i = 0; i < 2; i++)
|
|
AreaList[0].AreaList.Add(newSplittedList[i]);
|
|
Frame frame = ParentWindow.AreaList.First();
|
|
if(frame != null)
|
|
{
|
|
// Aggiorno joint di tutte le ante
|
|
if(AreaList.FirstOrDefault()!.AreaList.FirstOrDefault()!.AreaList.FirstOrDefault() is Sash sash && sash != null)
|
|
{
|
|
foreach(var anta in sash.SashList)
|
|
{
|
|
foreach (var j in anta.JointList)
|
|
j.SelJointType = anta.JointList.FirstOrDefault().SelJointType;
|
|
}
|
|
}
|
|
// Aggiorno altezza sotto aree
|
|
frame.SearchAreaList(frame, frame.AvailHeightArea(), "Height");
|
|
}
|
|
}
|
|
|
|
public void AddInglesina()
|
|
{
|
|
// Creo l'inglesina
|
|
Inglesina InglesinaArea = Inglesina.CreateInglesina(this.AreaList[0], SplitShapes.HORIZONTAL);
|
|
// imposto i parametri di default
|
|
InglesinaArea.SetSplitStartVert(false);
|
|
InglesinaArea.SetSplitQtyHoriz(1, 0);
|
|
// Aggiungo l'inglesina nell'AreaList del Fill
|
|
Fill fill = (Fill)AreaList.First();
|
|
fill.AreaList.Add(InglesinaArea);
|
|
}
|
|
|
|
public abstract Area Copy(Area ParentArea);
|
|
|
|
public void SetGroupId(int nGroupId)
|
|
{
|
|
m_GroupId = nGroupId;
|
|
}
|
|
|
|
public void SwapAree()
|
|
{
|
|
Area tempArea;
|
|
Frame frame = ParentWindow.AreaList.First();
|
|
if (this is Split)
|
|
{
|
|
tempArea = AreaList[0];
|
|
AreaList[0] = AreaList[1];
|
|
AreaList[1] = tempArea;
|
|
if(frame.SelThreshold.Name.Equals("Threshold") && AreaList.First().AreaList.First() is Fill)
|
|
{
|
|
frame.SetSelThresholdFromName("Bottom") ;
|
|
string profileName = "Frame_Sash_Bottom";
|
|
frame.ElementDimensionList.First().SetNameElement(profileName);
|
|
frame.ElementDimensionList.First().SetMinDimension(Window.m_ParameterList.GetValueOrDefault(profileName + "_DimMin"));
|
|
frame.ElementDimensionList.First().SetMaxDimension(Window.m_ParameterList.GetValueOrDefault(profileName + "_DimMax"));
|
|
frame.ElementDimensionList.First().SetDimension(Window.m_ParameterList.GetValueOrDefault(profileName + "_DimStd"));
|
|
string overlapName = "Sash_Bottom_Overlap";
|
|
frame.ElementDimensionList.First().SetOverlapElement(Window.m_ParameterList.GetValueOrDefault(overlapName));
|
|
if (frame.AreaList.Count > 0)
|
|
{
|
|
SearchAreaList(frame, frame.AvailHeightArea(), "Height");
|
|
}
|
|
}
|
|
}
|
|
string heightName = "Height";
|
|
switch (frame.Shape)
|
|
{
|
|
case Shapes.RIGHTCHAMFER:
|
|
{
|
|
heightName = "Left Height";
|
|
break;
|
|
}
|
|
|
|
case Shapes.LEFTCHAMFER:
|
|
{
|
|
heightName = "Right Height";
|
|
break;
|
|
}
|
|
|
|
case Shapes.DOUBLECHAMFER:
|
|
case Shapes.ARC:
|
|
case Shapes.DOUBLEARC:
|
|
case Shapes.THREECENTERARC:
|
|
{
|
|
heightName = "Full Height";
|
|
break;
|
|
}
|
|
}
|
|
SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Width")).First().dDimension, "Width");
|
|
SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals(heightName)).First().dDimension, heightName);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Cerca nell'albero gli oggetti Sash e Split per associare la larghezza
|
|
/// </summary>
|
|
/// <param name="node"></param>
|
|
public void SearchAreaList(Area node, double dim, string nameDim)
|
|
{
|
|
if (node != null)
|
|
{
|
|
if (node.AreaType.Equals(AreaTypes.SASH))
|
|
UpdateSash((Sash)node, dim, nameDim);
|
|
else if (node.AreaType.Equals(AreaTypes.SPLIT))
|
|
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))
|
|
{
|
|
Sash s = (Sash)node;
|
|
List<AreaDimension> dimList = new List<AreaDimension>();
|
|
double dimTot = dim;
|
|
foreach (var item in s.SashList)
|
|
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
|
|
+ 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)
|
|
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)
|
|
{
|
|
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;
|
|
|
|
}
|
|
SearchAreaList(node.AreaList.ElementAt(i), widthAnta, nameDim);
|
|
}
|
|
else if (s.SashList.First().ElementDimensionList.Count > 0)
|
|
{
|
|
if (s.ParentArea.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)
|
|
{
|
|
foreach (var bottomRail in s.BottomRailElemDimList)
|
|
dimTot = dimTot - bottomRail.dDimension
|
|
+ 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;
|
|
SearchAreaList(node.AreaList.ElementAt(i), dimTot, nameDim);
|
|
}
|
|
}
|
|
else if (node.AreaType.Equals(AreaTypes.SPLIT))
|
|
{
|
|
Split s = (Split)node;
|
|
double dimTot = dim;
|
|
List<AreaDimension> dimList = new List<AreaDimension>();
|
|
if (s.SplitHorizList.Count > 0 && i < s.SplitHorizList.Count)
|
|
{
|
|
foreach (var item in s.SplitHorizList)
|
|
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 && sash.SashList.First().ElementDimensionList.Count > 0)
|
|
dimTot = dimTot + sash.SashList.Last().ElementDimensionList.ElementAt(1).dOverlap + sash.SashList.First().ElementDimensionList.Last().dOverlap;
|
|
SearchAreaList(node.AreaList.ElementAt(i), dimTot, nameDim);
|
|
}
|
|
else
|
|
{
|
|
foreach (var item in s.ElemDimHorizList)
|
|
dimTot = dimTot - item.dDimension;
|
|
SearchAreaList(node.AreaList.ElementAt(i), s.SplitHorizList.ElementAt(i).CalculateAbsoluteValue(dimList, dimTot), nameDim);
|
|
}
|
|
}
|
|
if (s.SplitVertList.Count > 0 && i < s.SplitVertList.Count)
|
|
{
|
|
foreach (var item in s.SplitVertList)
|
|
dimList.Add(new AreaDimension(item.dDimension, item.MeasureType, item.Parent));
|
|
if (nameDim.Equals("Width"))
|
|
{
|
|
foreach (var elem in s.ElemDimVertList)
|
|
dimTot = dimTot - elem.dDimension;
|
|
SearchAreaList(node.AreaList.ElementAt(i), s.SplitVertList.ElementAt(i).CalculateAbsoluteValue(dimList, dimTot), nameDim);
|
|
}
|
|
else
|
|
SearchAreaList(node.AreaList.ElementAt(i), dimTot, nameDim);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SearchAreaList(node.AreaList.ElementAt(i), dim, nameDim);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
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"))
|
|
{
|
|
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));
|
|
}
|
|
}
|
|
}
|
|
else if (area is Split split)
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Internal Methods
|
|
internal abstract JsonArea Serialize(bool hideHw);
|
|
|
|
internal void SetAreaType(AreaTypes AreaType)
|
|
{
|
|
m_AreaType = AreaType;
|
|
}
|
|
|
|
internal void SetParentArea(Area ParentArea)
|
|
{
|
|
m_ParentArea = ParentArea;
|
|
}
|
|
|
|
#endregion Internal Methods
|
|
|
|
#region Protected Fields
|
|
|
|
protected int m_nAreaId = -1;
|
|
|
|
protected Window m_ParentWindow;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Private Fields
|
|
|
|
// Conteggio dei macro elementi
|
|
private static int m_CounterGroup = 0;
|
|
|
|
private List<Area> m_AreaList = new List<Area>();
|
|
private AreaTypes m_AreaType;
|
|
private int m_GroupId;
|
|
private Area m_ParentArea;
|
|
|
|
#endregion Private Fields
|
|
}
|
|
} |