Correzione conversione dimensione in proporzionale
This commit is contained in:
@@ -128,10 +128,11 @@ namespace WebWindowComplex.Models
|
||||
//return Double.Round((m_dDimension / m_Parent.Width) * 100, 1);
|
||||
return (dDimension / dimTot) * 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Double.Round(CalculatePropVal(itemList, indexSash, dimTot));
|
||||
}
|
||||
return -1;
|
||||
//else
|
||||
//{
|
||||
// return Double.Round(CalculatePropVal(itemList, indexSash, dimTot));
|
||||
//}
|
||||
}
|
||||
case MeasureTypes.PROPORTIONAL:
|
||||
{
|
||||
@@ -153,10 +154,11 @@ namespace WebWindowComplex.Models
|
||||
//return Double.Round((m_dDimension * m_Parent.Width) / 100, 2);
|
||||
return (dDimension * dimTot) / 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Double.Round(CalculatePropVal(itemList, indexSash, dimTot));
|
||||
}
|
||||
return -1;
|
||||
//else
|
||||
//{
|
||||
// return Double.Round(CalculatePropVal(itemList, indexSash, dimTot));
|
||||
//}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@@ -188,11 +190,13 @@ namespace WebWindowComplex.Models
|
||||
/// Metodo per ricalcolare i valori proporzionali a causa della modifica di uno
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal double CalculatePropVal(List<AreaDimension> itemList, int indexArea, double widthTot)
|
||||
internal List<AreaDimension> CalculatePropVal(List<AreaDimension> itemList, int indexArea, double widthTot)
|
||||
{
|
||||
List <AreaDimension> ans = itemList;
|
||||
if (itemList.Where(m => m.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count == 0)
|
||||
{
|
||||
return 1;
|
||||
ans.ElementAt(indexArea).SetDimension(1);
|
||||
return ans;
|
||||
}
|
||||
List<double> absoluteValue = new List<double>();
|
||||
foreach (var item in itemList)
|
||||
@@ -217,20 +221,20 @@ namespace WebWindowComplex.Models
|
||||
if (absoluteValue.ElementAt(indexArea) <= absoluteValue.ElementAt(i))
|
||||
{
|
||||
var mcd = CalculateMCD(absoluteValue.ElementAt(indexArea), absoluteValue.ElementAt(i));
|
||||
itemList.ElementAt(i).SetDimension(absoluteValue.ElementAt(i) / mcd);
|
||||
itemList.ElementAt(indexArea).SetDimension(absoluteValue.ElementAt(indexArea) / mcd);
|
||||
ans.ElementAt(i).SetDimension(absoluteValue.ElementAt(i) / mcd);
|
||||
ans.ElementAt(indexArea).SetDimension(absoluteValue.ElementAt(indexArea) / mcd);
|
||||
}
|
||||
else
|
||||
{
|
||||
var mcd = CalculateMCD(absoluteValue.ElementAt(indexArea), absoluteValue.ElementAt(i));
|
||||
itemList.ElementAt(i).SetDimension(absoluteValue.ElementAt(i) / mcd);
|
||||
itemList.ElementAt(indexArea).SetDimension(absoluteValue.ElementAt(indexArea) / mcd);
|
||||
ans.ElementAt(i).SetDimension(absoluteValue.ElementAt(i) / mcd);
|
||||
ans.ElementAt(indexArea).SetDimension(absoluteValue.ElementAt(indexArea) / mcd);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return itemList.ElementAt(indexArea).dDimension;
|
||||
return ans;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1241,7 +1241,8 @@ namespace WebWindowComplex.Models
|
||||
{
|
||||
adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType, it.Parent));
|
||||
}
|
||||
foreach (var elem in split.ElemDimHorizList)
|
||||
int minSubArea = split.ElemDimHorizList.Min(x=>x.nSubArea);
|
||||
foreach (var elem in split.ElemDimHorizList.Where(x=>x.nSubArea == minSubArea))
|
||||
{
|
||||
widthGlass = widthGlass - elem.dDimension;
|
||||
}
|
||||
@@ -1250,7 +1251,8 @@ namespace WebWindowComplex.Models
|
||||
}
|
||||
case MeasureTypes.PERCENTAGE:
|
||||
{
|
||||
foreach (var elem in split.ElemDimHorizList)
|
||||
int minSubArea = split.ElemDimHorizList.Min(x => x.nSubArea);
|
||||
foreach (var elem in split.ElemDimHorizList.Where(x => x.nSubArea == minSubArea))
|
||||
{
|
||||
dim = dim - elem.dDimension;
|
||||
}
|
||||
|
||||
@@ -46,13 +46,15 @@ namespace WebWindowComplex.Models
|
||||
double dimensionTot = 0;
|
||||
List<SplitDimension> dimensions = new List<SplitDimension>();
|
||||
Frame frame = m_Parent.ParentWindow.AreaList.FirstOrDefault() ?? new Frame(null, Parent.ParentWindow);
|
||||
int subAreaVert = m_Parent.ElemDimVertList.Min(x => x.nSubArea);
|
||||
int subAreaHoriz = m_Parent.ElemDimHorizList.Min(x => x.nSubArea);
|
||||
double width = CalculateWidthSplitGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension;
|
||||
foreach (var item in m_Parent.ElemDimVertList)
|
||||
foreach (var item in m_Parent.ElemDimVertList.Where(x=>x.nSubArea == subAreaVert))
|
||||
{
|
||||
width = width - item.dDimension;
|
||||
}
|
||||
double height = (CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false))).m_Dimension;
|
||||
foreach (var item in m_Parent.ElemDimHorizList)
|
||||
foreach (var item in m_Parent.ElemDimHorizList.Where(x => x.nSubArea == subAreaHoriz))
|
||||
{
|
||||
height = height - item.dDimension;
|
||||
}
|
||||
@@ -308,7 +310,14 @@ namespace WebWindowComplex.Models
|
||||
{
|
||||
dimSplitGroup = dimSplitGroup - item.dDimension;
|
||||
}
|
||||
m_dDimension = ad.ConvertDimension(adList, m_SelMeasureType, newType, dimSplitGroup, splitList.IndexOf(this));
|
||||
if (newType is MeasureTypes.PROPORTIONAL)
|
||||
{
|
||||
adList = ad.CalculatePropVal(adList, splitList.IndexOf(this), dimSplitGroup);
|
||||
for (int i = 0; i < adList.Count; i++)
|
||||
splitList.ElementAt(i).SetDimension(adList.ElementAt(i).dDimension);
|
||||
}
|
||||
else
|
||||
m_dDimension = ad.ConvertDimension(adList, m_SelMeasureType, newType, dimSplitGroup, splitList.IndexOf(this));
|
||||
m_SelMeasureType = (MeasureTypes)value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user