using System;
using System.Collections.Generic;
using System.Text;
namespace Shared.Phone.UserCenter
{
///
/// 做成一个里面只装FrameLayout的列表型控件,有刷新功能(它不会调整高度)
///
public class VerticalFrameRefreshControl : VerticalRefreshLayout
{
#region ■ 变量声明___________________________
///
/// 行之间的间距
///
public int rowSpace = 0;
///
/// 桌布控件
///
private FrameLayout m_frameTable = null;
///
/// 桌布控件
///
public FrameLayout frameTable
{
get
{
if (m_frameTable == null) { this.InitFrameTable(); }
return m_frameTable;
}
}
#endregion
#region ■ 初始化_____________________________
///
/// 做成一个列表型的FrameLayout,有刷新功能(它不会调整高度)
///
/// 行之间的间距(这个值是与行控件绑定一起使用的)
public VerticalFrameRefreshControl(int i_rowSpace = 0)
{
rowSpace = Application.GetRealHeight(i_rowSpace);
this.VerticalScrollBarEnabled = false;
#if iOS
//自动偏移取消
if (UIKit.UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
{
(this.uiView as UIKit.UIScrollView).ContentInsetAdjustmentBehavior = UIKit.UIScrollViewContentInsetAdjustmentBehavior.Never;
}
#endif
}
///
/// 初始化桌布控件
///
private void InitFrameTable()
{
if (this.m_frameTable != null && this.m_frameTable.Parent != null)
{
return;
}
this.m_frameTable = new FrameLayout();
this.m_frameTable.Width = this.Width;
this.m_frameTable.Height = this.Height;
this.AddChidren(this.m_frameTable);
}
#endregion
#region ■ 添加子控件_________________________
///
/// 添加Frame子控件(此方法是改变Y轴)
///
///
public void AddChidrenFrame(FrameLayout frame)
{
//初始化桌布控件
this.InitFrameTable();
var child = this.m_frameTable.GetChildren(this.m_frameTable.ChildrenCount - 1);
if (child != null)
{
frame.Y = child.Bottom + rowSpace;
}
this.m_frameTable.AddChidren(frame);
//调整桌布高度
if (this.m_frameTable.Height < frame.Bottom)
{
this.m_frameTable.Height = frame.Bottom;
}
}
///
/// 添加Frame子控件(此方法是改变高度)
///
///
public void AddChidrenFrame2(FrameLayout frame)
{
//初始化桌布控件
this.InitFrameTable();
var child = this.m_frameTable.GetChildren(this.m_frameTable.ChildrenCount - 1);
if (child != null)
{
frame.Y = child.Bottom;
}
this.m_frameTable.AddChidren(frame);
if (rowSpace > 0)
{
frame.Height += rowSpace;
}
//调整桌布高度
if (this.m_frameTable.Height < frame.Bottom)
{
this.m_frameTable.Height = frame.Bottom;
}
}
///
/// 添加Frame子控件(此方法是改变高度)
///
///
public void AddChidrenRow(RowLayout row)
{
//初始化桌布控件
this.InitFrameTable();
var child = this.m_frameTable.GetChildren(this.m_frameTable.ChildrenCount - 1);
if (child != null)
{
row.Y = child.Bottom;
}
this.m_frameTable.AddChidren(row);
if (rowSpace > 0)
{
row.Height += rowSpace;
}
//调整桌布高度
if (this.m_frameTable.Height < row.Bottom)
{
this.m_frameTable.Height = row.Bottom;
}
}
#endregion
#region ■ 一般方法___________________________
///
/// 调整子FrameLayout的高度
///
///
/// 底部空白间距(真实值)
public void AdjustChidrenFrameHeight(FrameLayout frame, int buttomSpace)
{
var child = frame.GetChildren(frame.ChildrenCount - 1);
if (child != null)
{
//调整桌布高度
if (frame.Height < child.Bottom + buttomSpace)
{
frame.Height = child.Bottom + buttomSpace;
}
}
}
///
/// 调整桌布高度
///
/// 底部空白间距(真实值)
public void AdjustTableHeight(int buttomSpace = 0)
{
var child = this.m_frameTable?.GetChildren(this.m_frameTable.ChildrenCount - 1);
if (child != null)
{
//调整桌布高度
this.m_frameTable.Height = child.Bottom + buttomSpace;
//if (this.m_frameTable.Height < child.Bottom)
//{
// this.m_frameTable.Height = child.Bottom;
//}
}
}
///
/// 针对底部点击按钮,调整控件真实高度
///
/// Y轴补正值(真实值,列表控件不在bodyFramelayout的时候使用)
public void AdjustRealHeightByBottomButton(int correctionsValue = 0)
{
var btnTemp = new BottomClickButton();
if (btnTemp.Yaxis >= this.m_frameTable.Height + correctionsValue)
{
//没有超过
return;
}
//添加临时控件,直至可以滑动超过底部按钮
var frameBackTemp = new FrameLayout();
frameBackTemp.Height = ControlCommonResourse.BodyFrameHeight - btnTemp.Yaxis + Application.GetRealHeight(23);
this.AddChidrenFrame(frameBackTemp);
}
#endregion
}
}