xm
2020-04-16 6fa9d69da922c8049f5acfcbb9ce9fd26811024c
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/ListViewLayoutControls/VerticalFrameControl.cs
@@ -5,7 +5,7 @@
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// 做成一个里面只装FrameLayout的列表型控件(它不会调整高度)
    /// 做成一个里面只装FrameLayout的列表型控件(它不会调整高度,有桌布)
    /// </summary>
    public class VerticalFrameControl : VerticalScrolViewLayout
    {
@@ -18,7 +18,18 @@
        /// <summary>
        /// 桌布控件
        /// </summary>
        private FrameLayout frameTable = null;
        private FrameLayout m_frameTable = null;
        /// <summary>
        /// 桌布控件
        /// </summary>
        public FrameLayout frameTable
        {
            get
            {
                if (m_frameTable == null) { this.InitFrameTable(); }
                return m_frameTable;
            }
        }
        #endregion
@@ -38,14 +49,14 @@
        /// </summary>
        private void InitFrameTable()
        {
            if (this.frameTable != null)
            if (this.m_frameTable != null && this.m_frameTable.Parent != null)
            {
                return;
            }
            this.frameTable = new FrameLayout();
            this.frameTable.Width = this.Width;
            this.frameTable.Height = this.Height;
            this.AddChidren(this.frameTable);
            this.m_frameTable = new FrameLayout();
            this.m_frameTable.Width = this.Width;
            this.m_frameTable.Height = this.Height;
            this.AddChidren(this.m_frameTable);
        }
        #endregion
@@ -61,16 +72,16 @@
            //初始化桌布控件
            this.InitFrameTable();
            var child = this.frameTable.GetChildren(this.frameTable.ChildrenCount - 1);
            var child = this.m_frameTable.GetChildren(this.m_frameTable.ChildrenCount - 1);
            if (child != null)
            {
                frame.Y = child.Bottom + rowSpace;
            }
            this.frameTable.AddChidren(frame);
            this.m_frameTable.AddChidren(frame);
            //调整桌布高度
            if (this.frameTable.Height < frame.Bottom)
            if (this.m_frameTable.Height < frame.Bottom)
            {
                this.frameTable.Height = frame.Bottom;
                this.m_frameTable.Height = frame.Bottom;
            }
        }
@@ -85,13 +96,14 @@
        /// <param name="buttomSpace">底部空白间距(真实值)</param>
        public void AdjustChidrenFrameHeight(FrameLayout frame, int buttomSpace)
        {
            var child = frame.GetChildren(frame.ChildrenCount - 1);
            if (child != null)
            //获取坐标底部最下面的那个控件的底部坐标
            int value = this.GetLocationMostLastViewBottom(frame);
            if (value != -1)
            {
                //调整桌布高度
                if (frame.Height < child.Bottom + buttomSpace)
                if (frame.Height < value + buttomSpace)
                {
                    frame.Height = child.Bottom + buttomSpace;
                    frame.Height = value + buttomSpace;
                }
            }
        }
@@ -101,15 +113,66 @@
        /// </summary>
        public void AdjustTableHeight()
        {
            var child = this.frameTable?.GetChildren(this.frameTable.ChildrenCount - 1);
            if (child != null)
            //获取坐标底部最下面的那个控件的底部坐标
            int value = this.GetLocationMostLastViewBottom(this.m_frameTable);
            if (value != -1)
            {
                //调整桌布高度
                if (this.frameTable.Height < child.Bottom)
                this.m_frameTable.Height = value;
            }
        }
        /// <summary>
        /// 针对底部点击按钮,调整控件真实高度
        /// </summary>
        /// <param name="correctionsValue">Y轴补正值(真实值,列表控件不在bodyFramelayout的时候使用)</param>
        public void AdjustRealHeightByBottomButton(int correctionsValue = 0)
        {
            var btnTemp = new BottomClickButton();
            if (btnTemp.Yaxis >= this.m_frameTable.Height + correctionsValue)
            {
                //没有超过
                return;
            }
            //添加临时控件,直至可以滑动超过底部按钮
            int oldRowSpace = this.rowSpace;
            this.rowSpace = 0;
            var frameBackTemp = new FrameLayout();
            frameBackTemp.Height = ControlCommonResourse.BodyFrameHeight - btnTemp.Yaxis + Application.GetRealHeight(23);
            this.AddChidrenFrame(frameBackTemp);
            this.rowSpace = oldRowSpace;
        }
        /// <summary>
        /// 还原桌布高度
        /// </summary>
        public void RecoverTableHeight()
        {
            if (this.m_frameTable != null)
            {
                m_frameTable.Height = this.Height;
            }
        }
        /// <summary>
        /// 获取坐标底部最下面的那个控件的底部坐标
        /// </summary>
        /// <returns></returns>
        private int GetLocationMostLastViewBottom(FrameLayout frame)
        {
            int bottomHeight = -1;
            if (frame == null) { return bottomHeight; }
            for (int i = 0; i < frame.ChildrenCount; i++)
            {
                var child = frame.GetChildren(i);
                if (child.Bottom > bottomHeight)
                {
                    this.frameTable.Height = child.Bottom;
                    bottomHeight = child.Bottom;
                }
            }
            return bottomHeight;
        }
        #endregion