Corretti alcuni Warnings
This commit is contained in:
@@ -149,168 +149,171 @@ namespace WebWindowComplex.Models
|
||||
}
|
||||
set
|
||||
{
|
||||
double widthTot = CalculateWidthSashGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dDimension);
|
||||
//double widthTot = ((Frame)m_Parent.ParentArea).AvailArea();
|
||||
double valMinAbsolute = 100;
|
||||
double valMaxAbsolute = widthTot - valMinAbsolute * (m_Parent.SashList.Count - 1);
|
||||
bool valueAccept = false;
|
||||
switch (MeasureType)
|
||||
if(m_Parent.ParentWindow.AreaList.FirstOrDefault() != null)
|
||||
{
|
||||
case MeasureTypes.ABSOLUTE:
|
||||
{
|
||||
valueAccept = (value < valMaxAbsolute && value > valMinAbsolute) ? true : false;
|
||||
break;
|
||||
}
|
||||
case MeasureTypes.PROPORTIONAL:
|
||||
{
|
||||
valMaxAbsolute = 20;
|
||||
valueAccept = (value >= 1) ? true : false;
|
||||
break;
|
||||
}
|
||||
case MeasureTypes.PERCENTAGE:
|
||||
{
|
||||
valMaxAbsolute = valMaxAbsolute / widthTot * 100;
|
||||
valMinAbsolute = valMinAbsolute / widthTot * 100;
|
||||
valueAccept = (value < valMaxAbsolute && value > valMinAbsolute) ? true : false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (valueAccept)
|
||||
{
|
||||
List<SashDimension> dimensions = m_Parent.SashList;
|
||||
List<double> absoluteValList = new List<double>();
|
||||
AreaDimension ad = new AreaDimension(m_dDimension, SelMeasureType);
|
||||
List<AreaDimension> adList = new List<AreaDimension>();
|
||||
foreach (var it in m_Parent.SashList)
|
||||
double widthTot = CalculateWidthSashGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault()!, m_Parent.ParentWindow.AreaList.FirstOrDefault()!.DimensionList.Where(x => x.sName == "Width").First().dDimension);
|
||||
//double widthTot = ((Frame)m_Parent.ParentArea).AvailArea();
|
||||
double valMinAbsolute = 100;
|
||||
double valMaxAbsolute = widthTot - valMinAbsolute * (m_Parent.SashList.Count - 1);
|
||||
bool valueAccept = false;
|
||||
switch (MeasureType)
|
||||
{
|
||||
adList.Add(new AreaDimension(it.m_dDimension, it.SelMeasureType));
|
||||
case MeasureTypes.ABSOLUTE:
|
||||
{
|
||||
valueAccept = (value < valMaxAbsolute && value > valMinAbsolute) ? true : false;
|
||||
break;
|
||||
}
|
||||
case MeasureTypes.PROPORTIONAL:
|
||||
{
|
||||
valMaxAbsolute = 20;
|
||||
valueAccept = (value >= 1) ? true : false;
|
||||
break;
|
||||
}
|
||||
case MeasureTypes.PERCENTAGE:
|
||||
{
|
||||
valMaxAbsolute = valMaxAbsolute / widthTot * 100;
|
||||
valMinAbsolute = valMinAbsolute / widthTot * 100;
|
||||
valueAccept = (value < valMaxAbsolute && value > valMinAbsolute) ? true : false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int index = 0;
|
||||
foreach (var item in m_Parent.SashList)
|
||||
if (valueAccept)
|
||||
{
|
||||
absoluteValList.Add(adList.ElementAt(index).CalculateAbsoluteValue(adList, widthTot));
|
||||
index++;
|
||||
}
|
||||
int nIndex = dimensions.IndexOf(this);
|
||||
int proportionalCount = dimensions.Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count;
|
||||
int percentageCount = dimensions.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).ToList().Count;
|
||||
// Le dimensioni sono solo in proporzionale
|
||||
if (proportionalCount == absoluteValList.Count || SelMeasureType.Equals(MeasureTypes.PROPORTIONAL) ||
|
||||
(SelMeasureType.Equals(MeasureTypes.ABSOLUTE) && proportionalCount == absoluteValList.Count -1))
|
||||
{
|
||||
m_dDimension = value;
|
||||
}
|
||||
// Le dimensioni sono solo in percentuale
|
||||
else if (percentageCount == dimensions.Count)
|
||||
{
|
||||
if (value < m_dDimension)
|
||||
List<SashDimension> dimensions = m_Parent.SashList;
|
||||
List<double> absoluteValList = new List<double>();
|
||||
AreaDimension ad = new AreaDimension(m_dDimension, SelMeasureType);
|
||||
List<AreaDimension> adList = new List<AreaDimension>();
|
||||
foreach (var it in m_Parent.SashList)
|
||||
{
|
||||
// L'anta modificata non è l'ultima
|
||||
if (nIndex < dimensions.Count - 1)
|
||||
dimensions[nIndex + 1].SetDimension(dimensions[nIndex + 1].m_dDimension + (m_dDimension - value));
|
||||
else if (dimensions.Count > 1)
|
||||
dimensions[nIndex - 1].SetDimension(dimensions[nIndex - 1].m_dDimension + (m_dDimension - value));
|
||||
else
|
||||
{
|
||||
m_dDimension = 100;
|
||||
return;
|
||||
}
|
||||
adList.Add(new AreaDimension(it.m_dDimension, it.SelMeasureType));
|
||||
}
|
||||
else
|
||||
int index = 0;
|
||||
foreach (var item in m_Parent.SashList)
|
||||
{
|
||||
double dRes = value;
|
||||
// se non ultima anta
|
||||
if (nIndex < dimensions.Count - 1)
|
||||
{
|
||||
for (var nInd = 0; nInd <= nIndex - 1; nInd++)
|
||||
dRes += dimensions[nInd].m_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].m_dDimension;
|
||||
}
|
||||
dRes = (100 - dRes);
|
||||
dimensions[nIndex - 1].SetDimension(dRes);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_dDimension = 100;
|
||||
return;
|
||||
}
|
||||
absoluteValList.Add(adList.ElementAt(index).CalculateAbsoluteValue(adList, widthTot));
|
||||
index++;
|
||||
}
|
||||
m_dDimension = value;
|
||||
}
|
||||
// Le dimensioni sono miste o solo in assoluto
|
||||
else
|
||||
{
|
||||
double valueInAbsolute = 0;
|
||||
switch (MeasureType)
|
||||
int nIndex = dimensions.IndexOf(this);
|
||||
int proportionalCount = dimensions.Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count;
|
||||
int percentageCount = dimensions.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).ToList().Count;
|
||||
// Le dimensioni sono solo in proporzionale
|
||||
if (proportionalCount == absoluteValList.Count || SelMeasureType.Equals(MeasureTypes.PROPORTIONAL) ||
|
||||
(SelMeasureType.Equals(MeasureTypes.ABSOLUTE) && proportionalCount == absoluteValList.Count -1))
|
||||
{
|
||||
case MeasureTypes.ABSOLUTE:
|
||||
{
|
||||
valueInAbsolute = value;
|
||||
break;
|
||||
}
|
||||
case MeasureTypes.PROPORTIONAL:
|
||||
{
|
||||
var pesi = value + dimensions.Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL) && !x.Equals(this))
|
||||
.Sum(x => x.m_dDimension);
|
||||
valueInAbsolute = widthTot / pesi * value;
|
||||
break;
|
||||
}
|
||||
case MeasureTypes.PERCENTAGE:
|
||||
{
|
||||
valueInAbsolute = (value / 100) * widthTot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (value < m_dDimension)
|
||||
{
|
||||
// L'anta modificata non è l'ultima
|
||||
if (nIndex < absoluteValList.Count - 1)
|
||||
{
|
||||
absoluteValList[nIndex + 1] = absoluteValList[nIndex + 1] + (absoluteValList[nIndex] - valueInAbsolute);
|
||||
absoluteValList[nIndex] = valueInAbsolute;
|
||||
}
|
||||
// L'anta modificata è l'ultima
|
||||
else if (dimensions.Count > 1)
|
||||
{
|
||||
absoluteValList[nIndex - 1] = absoluteValList[nIndex - 1] + (absoluteValList[nIndex] - valueInAbsolute);
|
||||
absoluteValList[nIndex] = valueInAbsolute;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// L'anta modificata non è l'ultima
|
||||
if (nIndex < absoluteValList.Count - 1)
|
||||
{
|
||||
absoluteValList[nIndex + 1] = absoluteValList[nIndex + 1] - (valueInAbsolute - absoluteValList[nIndex]);
|
||||
absoluteValList[nIndex] = valueInAbsolute;
|
||||
}
|
||||
// L'anta modificata è l'ultima
|
||||
else if (dimensions.Count > 1)
|
||||
{
|
||||
absoluteValList[nIndex - 1] = absoluteValList[nIndex - 1] - (valueInAbsolute - absoluteValList[nIndex]);
|
||||
absoluteValList[nIndex] = valueInAbsolute;
|
||||
}
|
||||
}
|
||||
if (MeasureType.Equals(MeasureTypes.PROPORTIONAL))
|
||||
m_dDimension = value;
|
||||
for (int i = 0; i < absoluteValList.Count; i++)
|
||||
{
|
||||
var item = m_Parent.SashList.ElementAt(i);
|
||||
item.SetDimension(ad.ConvertIn(adList, absoluteValList[i], (MeasureTypes)item.SelMeasureTypeIndex, widthTot));
|
||||
}
|
||||
// Le dimensioni sono solo in percentuale
|
||||
else if (percentageCount == dimensions.Count)
|
||||
{
|
||||
if (value < m_dDimension)
|
||||
{
|
||||
// L'anta modificata non è l'ultima
|
||||
if (nIndex < dimensions.Count - 1)
|
||||
dimensions[nIndex + 1].SetDimension(dimensions[nIndex + 1].m_dDimension + (m_dDimension - value));
|
||||
else if (dimensions.Count > 1)
|
||||
dimensions[nIndex - 1].SetDimension(dimensions[nIndex - 1].m_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].m_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].m_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)
|
||||
{
|
||||
case MeasureTypes.ABSOLUTE:
|
||||
{
|
||||
valueInAbsolute = value;
|
||||
break;
|
||||
}
|
||||
case MeasureTypes.PROPORTIONAL:
|
||||
{
|
||||
var pesi = value + dimensions.Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL) && !x.Equals(this))
|
||||
.Sum(x => x.m_dDimension);
|
||||
valueInAbsolute = widthTot / pesi * value;
|
||||
break;
|
||||
}
|
||||
case MeasureTypes.PERCENTAGE:
|
||||
{
|
||||
valueInAbsolute = (value / 100) * widthTot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (value < m_dDimension)
|
||||
{
|
||||
// L'anta modificata non è l'ultima
|
||||
if (nIndex < absoluteValList.Count - 1)
|
||||
{
|
||||
absoluteValList[nIndex + 1] = absoluteValList[nIndex + 1] + (absoluteValList[nIndex] - valueInAbsolute);
|
||||
absoluteValList[nIndex] = valueInAbsolute;
|
||||
}
|
||||
// L'anta modificata è l'ultima
|
||||
else if (dimensions.Count > 1)
|
||||
{
|
||||
absoluteValList[nIndex - 1] = absoluteValList[nIndex - 1] + (absoluteValList[nIndex] - valueInAbsolute);
|
||||
absoluteValList[nIndex] = valueInAbsolute;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// L'anta modificata non è l'ultima
|
||||
if (nIndex < absoluteValList.Count - 1)
|
||||
{
|
||||
absoluteValList[nIndex + 1] = absoluteValList[nIndex + 1] - (valueInAbsolute - absoluteValList[nIndex]);
|
||||
absoluteValList[nIndex] = valueInAbsolute;
|
||||
}
|
||||
// L'anta modificata è l'ultima
|
||||
else if (dimensions.Count > 1)
|
||||
{
|
||||
absoluteValList[nIndex - 1] = absoluteValList[nIndex - 1] - (valueInAbsolute - absoluteValList[nIndex]);
|
||||
absoluteValList[nIndex] = valueInAbsolute;
|
||||
}
|
||||
}
|
||||
if (MeasureType.Equals(MeasureTypes.PROPORTIONAL))
|
||||
m_dDimension = value;
|
||||
for (int i = 0; i < absoluteValList.Count; i++)
|
||||
{
|
||||
var item = m_Parent.SashList.ElementAt(i);
|
||||
item.SetDimension(ad.ConvertIn(adList, absoluteValList[i], (MeasureTypes)item.SelMeasureTypeIndex, widthTot));
|
||||
}
|
||||
}
|
||||
foreach(var item in m_Parent.AreaList)
|
||||
item.SearchAreaList(item, dDimension, "Width");
|
||||
}
|
||||
foreach(var item in m_Parent.AreaList)
|
||||
item.SearchAreaList(item, dDimension, "Width");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -405,16 +408,18 @@ namespace WebWindowComplex.Models
|
||||
if(SelMeasureType != (MeasureTypes)value)
|
||||
{
|
||||
MeasureTypes newType = (MeasureTypes)value;
|
||||
double widthTot = CalculateWidthSashGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dDimension);
|
||||
AreaDimension ad = new AreaDimension(m_dDimension, SelMeasureType);
|
||||
List<AreaDimension> adList = new List<AreaDimension>();
|
||||
foreach (var it in m_Parent.SashList)
|
||||
if (m_Parent.ParentWindow.AreaList.FirstOrDefault() != null)
|
||||
{
|
||||
adList.Add(new AreaDimension(it.m_dDimension, it.SelMeasureType));
|
||||
double widthTot = CalculateWidthSashGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault()!, m_Parent.ParentWindow.AreaList.FirstOrDefault()!.DimensionList.Where(x => x.sName == "Width").First().dDimension);
|
||||
AreaDimension ad = new AreaDimension(m_dDimension, SelMeasureType);
|
||||
List<AreaDimension> adList = new List<AreaDimension>();
|
||||
foreach (var it in m_Parent.SashList)
|
||||
{
|
||||
adList.Add(new AreaDimension(it.m_dDimension, it.SelMeasureType));
|
||||
}
|
||||
m_dDimension = ad.ConvertDimension(adList, SelMeasureType, newType, widthTot, nSashId-1);
|
||||
SelMeasureType = (MeasureTypes)value;
|
||||
}
|
||||
m_dDimension = ad.ConvertDimension(adList, SelMeasureType, newType, widthTot, nSashId-1);
|
||||
//m_dDimension = Convert.ConvertDimension(this, m_SelMeasureType, newType, m_dDimension, widthTot);
|
||||
SelMeasureType = (MeasureTypes)value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -458,6 +463,8 @@ namespace WebWindowComplex.Models
|
||||
/// <returns></returns>
|
||||
internal double CalculateWidthSashGroup(Area area, double width)
|
||||
{
|
||||
if (width < 1)
|
||||
return width;
|
||||
for(int i = 0; i < area.AreaList.Count; i++)
|
||||
{
|
||||
double risultato = -1;
|
||||
@@ -577,20 +584,23 @@ namespace WebWindowComplex.Models
|
||||
if (SelMeasureType != (MeasureTypes)value)
|
||||
{
|
||||
MeasureTypes newType = (MeasureTypes)value;
|
||||
double widthTot = CalculateWidthSashGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dDimension);
|
||||
AreaDimension ad = new AreaDimension(dDimension, SelMeasureType);
|
||||
List<AreaDimension> newDimensions = new List<AreaDimension>();
|
||||
foreach(var item in m_Parent.SashList)
|
||||
if(m_Parent.ParentWindow.AreaList.FirstOrDefault() != null)
|
||||
{
|
||||
newDimensions.Add(new AreaDimension(item.dDimension, item.SelMeasureType));
|
||||
double widthTot = CalculateWidthSashGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault()!, m_Parent.ParentWindow.AreaList.FirstOrDefault()!.DimensionList.Where(x => x.sName == "Width").First().dDimension);
|
||||
AreaDimension ad = new AreaDimension(dDimension, SelMeasureType);
|
||||
List<AreaDimension> newDimensions = new List<AreaDimension>();
|
||||
foreach(var item in m_Parent.SashList)
|
||||
{
|
||||
newDimensions.Add(new AreaDimension(item.dDimension, item.SelMeasureType));
|
||||
}
|
||||
m_dDimension = ad.ConvertDimension(newDimensions, SelMeasureType, newType, widthTot, indexSash);
|
||||
if(newType is MeasureTypes.PROPORTIONAL)
|
||||
{
|
||||
for (int i = 0; i < newDimensions.Count; i++)
|
||||
m_Parent.SashList.ElementAt(i).SetDimension(newDimensions.ElementAt(i).dDimension);
|
||||
}
|
||||
SelMeasureType = (MeasureTypes)value;
|
||||
}
|
||||
m_dDimension = ad.ConvertDimension(newDimensions, SelMeasureType, newType, widthTot, indexSash);
|
||||
if(newType is MeasureTypes.PROPORTIONAL)
|
||||
{
|
||||
for (int i = 0; i < newDimensions.Count; i++)
|
||||
m_Parent.SashList.ElementAt(i).SetDimension(newDimensions.ElementAt(i).dDimension);
|
||||
}
|
||||
SelMeasureType = (MeasureTypes)value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user