83161fd2c4
- Eliminazione funzioni non più usate - Eliminazione pagine razor sostituite
333 lines
14 KiB
C#
333 lines
14 KiB
C#
using WebWindowComplex.Json;
|
|
using static WebWindowComplex.Json.WindowConst;
|
|
|
|
namespace WebWindowComplex.Models
|
|
{
|
|
public class ElementDimension
|
|
{
|
|
#region Public Constructors
|
|
|
|
public ElementDimension(Area ParentArea, int nIndex, double dDimension)
|
|
{
|
|
m_ParentArea = ParentArea;
|
|
m_nIndex = nIndex;
|
|
m_dDimension = dDimension;
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Properties
|
|
|
|
public double dDimension
|
|
{
|
|
get
|
|
{
|
|
return m_dDimension;
|
|
}
|
|
set
|
|
{
|
|
if(dDimension != value)
|
|
{
|
|
double dimensioneOld = m_dDimension;
|
|
if (value > m_dMax)
|
|
m_dDimension = m_dMax;
|
|
else if (value < m_dMin)
|
|
m_dDimension = m_dMin;
|
|
else
|
|
m_dDimension = value;
|
|
if (m_ParentArea is Split split)
|
|
{
|
|
SplitElementDimension splitElem = (SplitElementDimension)this;
|
|
List<SplitDimension> elemList = new List<SplitDimension>();
|
|
Frame? frame = split.ParentWindow.AreaList.First();
|
|
double dimTot = 0;
|
|
if (split.ElemDimVertList.Contains(splitElem))
|
|
elemList = split.SplitVertList;
|
|
else if (split.ElemDimHorizList.Contains(splitElem))
|
|
elemList = split.SplitHorizList;
|
|
if(elemList.ElementAt(m_nIndex).MeasureType is MeasureTypes.ABSOLUTE ||
|
|
elemList.ElementAt(m_nIndex - 1).MeasureType is MeasureTypes.ABSOLUTE)
|
|
{
|
|
if (m_dDimension > dimensioneOld)
|
|
{
|
|
dimTot = dimTot - (m_dDimension - dimensioneOld);
|
|
}
|
|
else
|
|
{
|
|
dimTot = dimTot + (dimensioneOld - m_dDimension);
|
|
}
|
|
double diff = (dimensioneOld - m_dDimension) /2;
|
|
if(elemList.ElementAt(m_nIndex - 1).MeasureType is MeasureTypes.ABSOLUTE)
|
|
elemList.ElementAt(m_nIndex - 1).SetDimension(elemList.ElementAt(m_nIndex - 1).dDimension + diff);
|
|
if(elemList.ElementAt(m_nIndex).MeasureType is MeasureTypes.ABSOLUTE)
|
|
elemList.ElementAt(m_nIndex).SetDimension(elemList.ElementAt(m_nIndex).dDimension + diff);
|
|
}
|
|
if (split.SplitHorizList.Count > 0)
|
|
{
|
|
SplitElementDimension currSplitElem = (SplitElementDimension)this;
|
|
List<AreaDimension> dimList = new List<AreaDimension>();
|
|
foreach (var itemDim in split.SplitHorizList)
|
|
dimList.Add(new AreaDimension(itemDim.dDimension, itemDim.MeasureType, itemDim.Parent));
|
|
// Per calcolare larghezza split gorup mi basta una qualsiasi dimensione
|
|
double height = 0;
|
|
if (frame != null)
|
|
{
|
|
height = split.CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false)).m_Dimension;
|
|
//height =split.SplitHorizList.First().CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false)).m_Dimension;
|
|
}
|
|
//double height = ParentArea.CalculateWidthArea(ParentArea.ParentWindow.AreaList[0], ParentArea.ParentWindow.AreaList[0].AvailHeightArea());
|
|
List<SplitElementDimension> horizElemList = split.ElemDimHorizList.Where(x=>x.m_nIndex== 1).ToList();
|
|
foreach (var elem in horizElemList)
|
|
height = height - elem.dDimension;
|
|
for (int i = 0; i < split.AreaList.Count; i++)
|
|
{
|
|
if (i < split.SplitHorizList.Count)
|
|
{
|
|
SplitDimension currSplitDim = split.SplitHorizList[i];
|
|
double dim = currSplitDim.dDimension;
|
|
if (!(currSplitDim.MeasureType.Equals(MeasureTypes.ABSOLUTE)))
|
|
dim = currSplitDim.ConvertDimension(dimList, currSplitDim.MeasureType, MeasureTypes.ABSOLUTE, height, -1);
|
|
split.AreaList.ElementAt(i).SearchAreaList(split.AreaList.ElementAt(i), dim, "Height");
|
|
}
|
|
}
|
|
}
|
|
if (split.SplitVertList.Count > 0)
|
|
{
|
|
List<AreaDimension> dimList = new List<AreaDimension>();
|
|
foreach (var itemDim in split.SplitVertList)
|
|
dimList.Add(new AreaDimension(itemDim.dDimension, itemDim.MeasureType, itemDim.Parent));
|
|
// Per calcolare larghezza split gorup mi basta una qualsiasi dimensione
|
|
double width = 0;
|
|
if (frame != null)
|
|
width = split.CalculateWidthSplitGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension;
|
|
//double width = ParentArea.CalculateWidthArea(ParentArea.ParentWindow.AreaList[0], ParentArea.ParentWindow.AreaList[0].AvailWidthArea());
|
|
List<SplitElementDimension> vertElemList = split.ElemDimVertList.Where(x => x.m_nIndex == 1).ToList();
|
|
foreach (var elem in vertElemList)
|
|
width = width - elem.dDimension;
|
|
for (int i = 0; i < split.AreaList.Count; i++)
|
|
{
|
|
if (i < split.SplitVertList.Count)
|
|
{
|
|
SplitDimension currSplitDim = split.SplitVertList[i];
|
|
double dim = currSplitDim.dDimension;
|
|
if (!(currSplitDim.MeasureType.Equals(MeasureTypes.ABSOLUTE)))
|
|
dim = currSplitDim.ConvertDimension(dimList, currSplitDim.MeasureType, MeasureTypes.ABSOLUTE, width, -1);
|
|
split.AreaList.ElementAt(i).SearchAreaList(split.AreaList.ElementAt(i), dim, "Width");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if(m_ParentArea is Sash sash)
|
|
{
|
|
if(m_nIndex == 2 || m_nIndex == 4)
|
|
{
|
|
if (sash.bIsDimensionLight)
|
|
{
|
|
int indSash = -1;
|
|
for(int i = 0; i < sash.SashList.Count; i++)
|
|
{
|
|
if (sash.SashList.ElementAt(i).ElementDimensionList.Contains(this))
|
|
{
|
|
indSash = i;
|
|
break;
|
|
}
|
|
}
|
|
if(sash.SashList.ElementAt(indSash).MeasureType is MeasureTypes.ABSOLUTE)
|
|
{
|
|
if (m_dDimension > dimensioneOld)
|
|
{
|
|
double diff = (m_dDimension - dimensioneOld);
|
|
sash.SashList.ElementAt(indSash).SetDimension(sash.SashList.ElementAt(indSash).dDimension - diff);
|
|
}
|
|
else
|
|
{
|
|
double diff = dimensioneOld - m_dDimension;
|
|
sash.SashList.ElementAt(indSash).SetDimension(sash.SashList.ElementAt(indSash).dDimension + diff);
|
|
}
|
|
for (int i = 0; i < sash.AreaList.Count; i++)
|
|
sash.AreaList.ElementAt(i).SearchAreaList(sash.AreaList.ElementAt(i), sash.SashList.ElementAt(i).dDimension, "Width");
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Frame? frame = sash.ParentWindow.AreaList.FirstOrDefault();
|
|
if(frame != null)
|
|
{
|
|
double height = sash.CalculateHeightSashGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false)).m_Dimension
|
|
- sash.SashList.First().ElementDimensionList.First().dDimension
|
|
- sash.SashList.First().ElementDimensionList.ElementAt(sash.SashList.First().ElementDimensionList.Count - 2).dDimension;
|
|
for (int i = 0; i < sash.AreaList.Count; i++)
|
|
{
|
|
sash.AreaList.ElementAt(i).SearchAreaList(sash.AreaList.ElementAt(i), height, "Height");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if(m_ParentArea is Frame frame)
|
|
{
|
|
for (int i = 0; i < frame.AreaList.Count; i++)
|
|
{
|
|
frame.AreaList.ElementAt(i).SearchAreaList(frame, frame.AvailWidthArea(), "Width");
|
|
frame.AreaList.ElementAt(i).SearchAreaList(frame, frame.AvailHeightArea(), "Height");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
public int nIndex
|
|
{
|
|
get
|
|
{
|
|
return m_nIndex;
|
|
}
|
|
}
|
|
public string sName
|
|
{
|
|
get
|
|
{
|
|
return m_sName;
|
|
}
|
|
set
|
|
{
|
|
if (m_sName != value)
|
|
{
|
|
m_sName = value;
|
|
}
|
|
}
|
|
}
|
|
public Area ParentArea
|
|
{
|
|
get
|
|
{
|
|
return m_ParentArea;
|
|
}
|
|
}
|
|
public double dOverlap
|
|
{
|
|
get
|
|
{
|
|
return m_dOverlap;
|
|
}
|
|
}
|
|
public double dMaxDim
|
|
{
|
|
get
|
|
{
|
|
return m_dMax;
|
|
}
|
|
}
|
|
public double dMinDim
|
|
{
|
|
get
|
|
{
|
|
return m_dMin;
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public void SetDimension(double dValue)
|
|
{
|
|
m_dDimension = dValue;
|
|
}
|
|
|
|
public void SetIndex(int nIndex)
|
|
{
|
|
m_nIndex = nIndex;
|
|
}
|
|
|
|
public void SetMaxDimension(double dValue)
|
|
{
|
|
m_dMax = dValue;
|
|
}
|
|
|
|
public void SetMinDimension(double dValue)
|
|
{
|
|
m_dMin = dValue;
|
|
}
|
|
|
|
public void SetNameElement(string dValue)
|
|
{
|
|
m_sName = dValue;
|
|
}
|
|
|
|
public void SetOverlapElement(double dValue)
|
|
{
|
|
m_dOverlap = dValue;
|
|
}
|
|
|
|
public virtual ElementDimension Copy()
|
|
{
|
|
ElementDimension newElementDimension = new ElementDimension(ParentArea, nIndex, dDimension);
|
|
return newElementDimension;
|
|
}
|
|
|
|
public override bool Equals(object? obj)
|
|
{
|
|
if (obj is null)
|
|
return false;
|
|
return Equals(obj as ElementDimension);
|
|
}
|
|
|
|
public bool Equals(ElementDimension other)
|
|
{
|
|
if (other is null)
|
|
return false;
|
|
if (dDimension != other.dDimension)
|
|
return false;
|
|
if (dOverlap != other.dOverlap)
|
|
return false;
|
|
if (ParentArea != other.ParentArea)
|
|
return false;
|
|
if (nIndex != other.nIndex)
|
|
return false;
|
|
if (sName != other.sName)
|
|
return false;
|
|
if (dMaxDim != other.dMaxDim)
|
|
return false;
|
|
if (dMinDim != other.dMinDim)
|
|
return false;
|
|
if (ReferenceEquals(this, other))
|
|
return true;
|
|
return true;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Internal Methods
|
|
|
|
internal JsonElementDimension Serialize()
|
|
{
|
|
JsonElementDimension JsonElementDimension = new JsonElementDimension(m_nIndex, m_dDimension);
|
|
return JsonElementDimension;
|
|
}
|
|
|
|
#endregion Internal Methods
|
|
|
|
#region Private Fields
|
|
|
|
private Area m_ParentArea;
|
|
|
|
private double m_dDimension;
|
|
|
|
private double m_dOverlap;
|
|
|
|
private int m_nIndex;
|
|
|
|
private string m_sName = "";
|
|
|
|
private double m_dMin = 40;
|
|
|
|
private double m_dMax = 100;
|
|
|
|
#endregion Private Fields
|
|
}
|
|
} |