HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2020-06-01 0bf9e65bc3ba98391e7835c922b15baab3c77876
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/ListViewLayoutControls/VerticalFrameRefreshControl.cs
@@ -5,7 +5,7 @@
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// 做成一个里面只装FrameLayout的列表型控件,有刷新功能(它不会调整高度)
    /// 做成一个里面只装FrameLayout的列表型控件,有刷新功能(有桌布,它不会调整高度)
    /// </summary>
    public class VerticalFrameRefreshControl : VerticalRefreshLayout
    {
@@ -30,6 +30,11 @@
                return m_frameTable;
            }
        }
        /// <summary>
        /// 一个临时的东西
        /// </summary>
        private FrameLayout frameBackTemp = null;
        #endregion
@@ -80,10 +85,10 @@
            //初始化桌布控件
            this.InitFrameTable();
            var child = this.m_frameTable.GetChildren(this.m_frameTable.ChildrenCount - 1);
            if (child != null)
            int value = this.GetLocationMostLastViewBottom(this.m_frameTable);
            if (value != -1)
            {
                frame.Y = child.Bottom + rowSpace;
                frame.Y = value + rowSpace;
            }
            this.m_frameTable.AddChidren(frame);
            //调整桌布高度
@@ -102,10 +107,11 @@
            //初始化桌布控件
            this.InitFrameTable();
            var child = this.m_frameTable.GetChildren(this.m_frameTable.ChildrenCount - 1);
            if (child != null)
            //获取坐标底部最下面的那个控件的底部坐标
            int value = this.GetLocationMostLastViewBottom(this.m_frameTable);
            if (value != -1)
            {
                frame.Y = child.Bottom;
                frame.Y = value;
            }
            this.m_frameTable.AddChidren(frame);
            if (rowSpace > 0)
@@ -128,10 +134,11 @@
            //初始化桌布控件
            this.InitFrameTable();
            var child = this.m_frameTable.GetChildren(this.m_frameTable.ChildrenCount - 1);
            if (child != null)
            //获取坐标底部最下面的那个控件的底部坐标
            int value = this.GetLocationMostLastViewBottom(this.m_frameTable);
            if (value != -1)
            {
                row.Y = child.Bottom;
                row.Y = value;
            }
            this.m_frameTable.AddChidren(row);
            if (rowSpace > 0)
@@ -156,14 +163,12 @@
        /// <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)
                {
                    frame.Height = child.Bottom + buttomSpace;
                }
                frame.Height = value + buttomSpace;
            }
        }
@@ -173,15 +178,23 @@
        /// <param name="buttomSpace">底部空白间距(真实值)</param>
        public void AdjustTableHeight(int buttomSpace = 0)
        {
            var child = this.m_frameTable?.GetChildren(this.m_frameTable.ChildrenCount - 1);
            if (child != null)
            //2020.05.25追加
            if (this.frameBackTemp != null && this.frameBackTemp.Parent != null)
            {
                this.frameBackTemp.RemoveFromParent();
            }
            //获取坐标底部最下面的那个控件的底部坐标
            int value = this.GetLocationMostLastViewBottom(this.m_frameTable);
            if (value != -1)
            {
                //调整桌布高度
                this.m_frameTable.Height = child.Bottom + buttomSpace;
                //if (this.m_frameTable.Height < child.Bottom)
                //{
                //    this.m_frameTable.Height = child.Bottom;
                //}
                this.m_frameTable.Height = value + buttomSpace;
            }
            else
            {
                //还原为原来的高度
                this.RecoverTableHeight();
            }
        }
@@ -191,6 +204,9 @@
        /// <param name="correctionsValue">Y轴补正值(真实值,列表控件不在bodyFramelayout的时候使用)</param>
        public void AdjustRealHeightByBottomButton(int correctionsValue = 0)
        {
            //调整桌布高度 2020.05.25追加
            this.AdjustTableHeight();
            var btnTemp = new BottomClickButton();
            if (btnTemp.Yaxis >= this.m_frameTable.Height + correctionsValue)
            {
@@ -198,9 +214,46 @@
                return;
            }
            //添加临时控件,直至可以滑动超过底部按钮
            var frameBackTemp = new FrameLayout();
            int oldRowSpace = this.rowSpace;
            this.rowSpace = 0;
            this.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)
                {
                    bottomHeight = child.Bottom;
                }
            }
            return bottomHeight;
        }
        #endregion