using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.UserCenter { /// /// 信息编辑控件(不建议别人使用) /// public class InformationEditorControl { #region ■ 变量声明___________________________ /// /// 明细列表的桌布,白色背景 /// private FrameLayout detailBackFrame = null; /// /// 列表控件 /// private FrameListControl listview = null; /// /// 最小高度 /// private int minHeight = -1; #endregion #region ■ 初始化_____________________________ /// /// 初始化控件(返回的是信息容器控件) /// /// 父控件 /// 标题文本 /// 蓝湖UI里面它的高度 /// 信息容器控件 public FrameListControl InitControl(FrameLayout bodyFrameLayout, string title, int Height) { //明细列表的桌布,白色背景 this.detailBackFrame = new FrameLayout(); detailBackFrame.Height = Application.GetRealHeight(Height); detailBackFrame.BackgroundColor = UserCenterColor.Current.White; detailBackFrame.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight); detailBackFrame.Gravity = Gravity.BottomCenter; bodyFrameLayout.AddChidren(detailBackFrame); this.minHeight = detailBackFrame.Height; //信息编辑 var btnTile = new NormalViewControl(800, 60, true); btnTile.X = ControlCommonResourse.XXLeft; btnTile.Y = Application.GetRealHeight(81); btnTile.TextSize = 15; btnTile.TextColor = UserCenterColor.Current.TextColor2; btnTile.Text = title; detailBackFrame.AddChidren(btnTile); //列表控件 this.listview = new FrameListControl(12); listview.Y = btnTile.Bottom + Application.GetRealHeight(17); listview.Height = Application.GetRealHeight(Height) - btnTile.Bottom - Application.GetRealHeight(17); detailBackFrame.AddChidren(listview); return listview; } /// /// 完成初始化 /// /// 这个控件所在的界面,底部有没有保存按钮 /// 强制调整高度 public void FinishInitControl(bool HadBottomButton = true, bool mandatoryAdjustment = false) { if (HadBottomButton == true) { var btnFinish = new BottomClickButton(); //让它别改变坐标 int tempSpace = listview.rowSpace; listview.rowSpace = 0; //促使被挡住的菜单能够向上滑动 var frameTemp = new FrameLayout(); frameTemp.Height = ControlCommonResourse.BodyFrameHeight - btnFinish.Yaxis + Application.GetRealHeight(23); listview.AddChidren(frameTemp); listview.rowSpace = tempSpace; } //调整容器高度大小 int value = this.GetLocationMostLastViewBottom(); if (mandatoryAdjustment == false) { if (value + Application.GetRealHeight(23) < listview.Height) { //不需要调整 return; } } //调整大小 listview.Height = value + Application.GetRealHeight(23); int backHeigth = listview.Bottom; if (minHeight > backHeigth) { //它有个最小高度 backHeigth = minHeight; } this.detailBackFrame.Height = backHeigth; //获取listview所在的全局容器控件 var contrFather = GetVerticalFrameControl(listview); //调整桌布大小 contrFather?.AdjustTableHeight(); } #endregion #region ■ 一般方法___________________________ /// /// 获取listview所在的全局容器控件 /// /// /// private VerticalFrameControl GetVerticalFrameControl(FrameListControl listview) { var myContr = listview.Parent; while (myContr != null) { if (myContr is VerticalFrameControl) { return (VerticalFrameControl)myContr; } myContr = myContr.Parent; } return null; } /// /// 获取坐标底部最下面的那个控件的底部坐标 /// /// private int GetLocationMostLastViewBottom() { int bottomHeight = -1; for (int i = 0; i < this.listview.ChildrenCount; i++) { var child = this.listview.GetChildren(i); if (child.Bottom > bottomHeight) { bottomHeight = child.Bottom; } } return bottomHeight; } #endregion } }