using Shared;
using System;
using System.Collections.Generic;
using System.Text;
namespace HDL_ON.Stan
{
///
/// 做成一个列表型的FrameLayout(它与VerticalListControl同一性质,但是它是FrameLayout,它会改变高度)
///
public class FrameListControl : FrameLayoutBase
{
///
/// 行之间的间距
///
public int rowSpace = 0;
///
/// 做成一个列表型的FrameLayout(它与VerticalListControl同一性质,但是它是FrameLayout,它会改变高度)
///
/// 行之间的间距(这个值是与行控件绑定一起使用的)
public FrameListControl(int i_rowSpace = 0)
{
rowSpace = Application.GetRealHeight(i_rowSpace);
}
///
/// 添加子控件
///
///
public override void AddChidren(View view)
{
if (view is FrameRowControl || view is RowLayoutControl)
{
//FrameRowLayout控件的时候,直接扩大它的高度
var intBottom = this.GetLocationMostLastViewBottom();
if (intBottom != -1)
{
view.Y = intBottom;
}
base.AddChidren(view);
if (rowSpace > 0)
{
view.Height += rowSpace;
}
}
else
{
//非FrameRowLayout控件的时候,计算的是坐标
var intBottom = this.GetLocationMostLastViewBottom();
if (intBottom != -1)
{
view.Y = intBottom + rowSpace;
}
base.AddChidren(view);
}
}
///
/// 调整真实高度
///
/// 底部高度(非真实值)
public void AdjustRealHeight(int bottomSpace = 0)
{
int bottomHeight = -1;
for (int i = 0; i < this.ChildrenCount; i++)
{
var child = this.GetChildren(i);
if (child.Bottom > bottomHeight)
{
bottomHeight = child.Bottom;
}
}
if (bottomHeight != -1)
{
this.Height = bottomHeight + bottomSpace;
}
}
///
/// 获取坐标底部最下面的那个控件的底部坐标
///
///
private int GetLocationMostLastViewBottom()
{
int bottomHeight = -1;
for (int i = 0; i < this.ChildrenCount; i++)
{
var child = this.GetChildren(i);
if (child.Bottom > bottomHeight)
{
bottomHeight = child.Bottom;
}
}
return bottomHeight;
}
}
}