using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.UserCenter { /// /// 设备明细信息的列表控件(设备信息界面专用,不建议别人使用) /// public class DeviceInformationListControl : VerticalScrolViewLayout { /// /// 弧度的圆的一半的高度(固定) /// public int halfRoundHeigth = Application.GetRealHeight(116) / 2; /// /// 明细标题高度(固定) /// public int titleHeight = Application.GetRealHeight(60); /// /// 明细列表控件的桌布 /// private FrameLayout detailBackFrame = null; /// /// 设备明细信息的列表控件(设备信息界面专用,不建议别人使用) /// 请不要添加到父控件中,调用InitControl()完成初始化 /// public DeviceInformationListControl() { } /// /// 初始化控件 /// /// 父容器,不能为null /// 底部白色背景控件的高度 /// 列表控件最大的高度 /// 明细Frame的最小高度 /// 菜单的行数(不含标题) /// 列表控件底部附加的空白高度(不添加在这个封装控件中) public void InitControl(FrameLayout frame, int bottomWhiteFrameHeight, int listViewMaxHeight, int minDetailFrameHeight, int menuRowCount, int appendHeight = 0) { //★★★★设备明细列表需要特效,估计以后我也看不懂这代码什么意思了★★★★ //列表控件最大的高度 listViewMaxHeight = listViewMaxHeight - appendHeight; //弧度的圆的一半的高度(固定) int halfRoundHeigth = Application.GetRealHeight(116) / 2; //明细标题高度(固定) int titleHeight = Application.GetRealHeight(60); //明细Frame的最小高度 minDetailFrameHeight = minDetailFrameHeight - appendHeight; //明细Frame实际的高度(菜单数 * 行的高度 + 明细标题高度) int realDetailHeight = menuRowCount * ControlCommonResourse.ListViewRowHeight + titleHeight; if (realDetailHeight < minDetailFrameHeight) { //明细Frame实际的高度不能低于最小高度,不然白色会铺不满 realDetailHeight = minDetailFrameHeight; } //列表控件的高度 int listViewHeight = listViewMaxHeight; if (realDetailHeight + halfRoundHeigth < listViewMaxHeight) { listViewHeight = realDetailHeight + halfRoundHeigth; } //列表控件实际高度与明细最小高度的差(此值只有0,或者大于0) int differValue = listViewHeight - minDetailFrameHeight - halfRoundHeigth; //列表控件 this.Y = ControlCommonResourse.BodyFrameHeight - listViewHeight - bottomWhiteFrameHeight - appendHeight; this.BackgroundColor = UserCenterColor.Current.Transparent; this.Height = listViewHeight; frame.AddChidren(this); //在列表控件里添加一层背景桌布 var listViewBackFrame = new FrameLayout(); listViewBackFrame.BackgroundColor = UserCenterColor.Current.Transparent; listViewBackFrame.Height = realDetailHeight + halfRoundHeigth + differValue; base.AddChidren(listViewBackFrame); if (differValue > 0) { //添加一个透明的东西到列表顶部 var frameTransparent = new FrameLayout(); frameTransparent.BackgroundColor = UserCenterColor.Current.Transparent; frameTransparent.Height = differValue; listViewBackFrame.AddChidren(frameTransparent); } //弧度的圆 var btnRound = new NormalViewControl(listViewBackFrame.Width, halfRoundHeigth * 2, false); btnRound.Y = differValue; btnRound.BackgroundColor = UserCenterColor.Current.White; btnRound.Radius = (uint)halfRoundHeigth; listViewBackFrame.AddChidren(btnRound); //明细列表的桌布,白色背景(覆盖弧度的圆的半边) this.detailBackFrame = new FrameLayout(); detailBackFrame.Y = btnRound.Bottom - btnRound.Height / 2; detailBackFrame.Height = realDetailHeight; detailBackFrame.BackgroundColor = UserCenterColor.Current.White; listViewBackFrame.AddChidren(detailBackFrame); } /// /// 添加子控件 /// /// public override void AddChidren(View view) { if (detailBackFrame != null) { var tempView = detailBackFrame.GetChildren(detailBackFrame.ChildrenCount - 1); if (tempView != null) { view.Y = tempView.Bottom; } detailBackFrame.AddChidren(view); } } } }