HDL Home App 第二版本 旧平台金堂用 正在使用
chenqiyang
2022-06-22 dc0309e64f02227d8e1468b7326c07955f804612
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/InformationEditorControl.cs
old mode 100755 new mode 100644
@@ -1,161 +1,161 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// 信息编辑控件(不建议别人使用)
    /// </summary>
    public class InformationEditorControl
    {
        #region ■ 变量声明___________________________
        /// <summary>
        /// 明细列表的桌布,白色背景
        /// </summary>
        private FrameLayout detailBackFrame = null;
        /// <summary>
        /// 列表控件
        /// </summary>
        private FrameListControl listview = null;
        /// <summary>
        /// 最小高度
        /// </summary>
        private int minHeight = -1;
        #endregion
        #region ■ 初始化_____________________________
        /// <summary>
        /// 初始化控件(返回的是信息容器控件)
        /// </summary>
        /// <param name="bodyFrameLayout">父控件</param>
        /// <param name="title">标题文本</param>
        /// <param name="Height">蓝湖UI里面它的高度</param>
        /// <param name="real">是否计算Height的真实值</param>
        /// <returns>信息容器控件</returns>
        public FrameListControl InitControl(FrameLayout bodyFrameLayout, string title, int Height, bool real = true)
        {
            if (real == true) { Height = Application.GetRealHeight(Height); }
            //明细列表的桌布,白色背景
            this.detailBackFrame = new FrameLayout();
            detailBackFrame.Height = 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 = Height - btnTile.Bottom - Application.GetRealHeight(17);
            detailBackFrame.AddChidren(listview);
            return listview;
        }
        /// <summary>
        /// 完成初始化
        /// </summary>
        /// <param name="HadBottomButton">这个控件所在的界面,底部有没有保存按钮</param>
        /// <param name="mandatoryAdjustment">强制调整高度</param>
        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 ■ 一般方法___________________________
        /// <summary>
        /// 获取listview所在的全局容器控件
        /// </summary>
        /// <param name="listview"></param>
        /// <returns></returns>
        private VerticalFrameControl GetVerticalFrameControl(FrameListControl listview)
        {
            var myContr = listview.Parent;
            while (myContr != null)
            {
                if (myContr is VerticalFrameControl)
                {
                    return (VerticalFrameControl)myContr;
                }
                myContr = myContr.Parent;
            }
            return null;
        }
        /// <summary>
        /// 获取坐标底部最下面的那个控件的底部坐标
        /// </summary>
        /// <returns></returns>
        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
    }
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// 信息编辑控件(不建议别人使用)
    /// </summary>
    public class InformationEditorControl
    {
        #region ■ 变量声明___________________________
        /// <summary>
        /// 明细列表的桌布,白色背景
        /// </summary>
        private FrameLayout detailBackFrame = null;
        /// <summary>
        /// 列表控件
        /// </summary>
        private FrameListControl listview = null;
        /// <summary>
        /// 最小高度
        /// </summary>
        private int minHeight = -1;
        #endregion
        #region ■ 初始化_____________________________
        /// <summary>
        /// 初始化控件(返回的是信息容器控件)
        /// </summary>
        /// <param name="bodyFrameLayout">父控件</param>
        /// <param name="title">标题文本</param>
        /// <param name="Height">蓝湖UI里面它的高度</param>
        /// <param name="real">是否计算Height的真实值</param>
        /// <returns>信息容器控件</returns>
        public FrameListControl InitControl(FrameLayout bodyFrameLayout, string title, int Height, bool real = true)
        {
            if (real == true) { Height = Application.GetRealHeight(Height); }
            //明细列表的桌布,白色背景
            this.detailBackFrame = new FrameLayout();
            detailBackFrame.Height = 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 = Height - btnTile.Bottom - Application.GetRealHeight(17);
            detailBackFrame.AddChidren(listview);
            return listview;
        }
        /// <summary>
        /// 完成初始化
        /// </summary>
        /// <param name="HadBottomButton">这个控件所在的界面,底部有没有保存按钮</param>
        /// <param name="mandatoryAdjustment">强制调整高度</param>
        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 ■ 一般方法___________________________
        /// <summary>
        /// 获取listview所在的全局容器控件
        /// </summary>
        /// <param name="listview"></param>
        /// <returns></returns>
        private VerticalFrameControl GetVerticalFrameControl(FrameListControl listview)
        {
            var myContr = listview.Parent;
            while (myContr != null)
            {
                if (myContr is VerticalFrameControl)
                {
                    return (VerticalFrameControl)myContr;
                }
                myContr = myContr.Parent;
            }
            return null;
        }
        /// <summary>
        /// 获取坐标底部最下面的那个控件的底部坐标
        /// </summary>
        /// <returns></returns>
        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
    }
}