陈嘉乐
2020-06-24 adb12dcdbb2ddaeac687c3aa9e57bb7ed459ab7e
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
    {
@@ -20,7 +20,7 @@
        /// </summary>
        private FrameLayout m_frameTable = null;
        /// <summary>
        /// 桌布控件
        /// 桌布控件(这个东西不能删,因为有些界面需要他的桌布)
        /// </summary>
        public FrameLayout frameTable
        {
@@ -30,6 +30,11 @@
                return m_frameTable;
            }
        }
        /// <summary>
        /// 一个临时的东西
        /// </summary>
        private FrameLayout frameBackTemp = null;
        #endregion
@@ -42,6 +47,13 @@
        public VerticalFrameControl(int i_rowSpace = 0)
        {
            rowSpace = Application.GetRealHeight(i_rowSpace);
#if iOS
            //自动偏移取消
            if (UIKit.UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                (this.uiView as UIKit.UIScrollView).ContentInsetAdjustmentBehavior = UIKit.UIScrollViewContentInsetAdjustmentBehavior.Never;
            }
#endif
        }
        /// <summary>
@@ -56,7 +68,7 @@
            this.m_frameTable = new FrameLayout();
            this.m_frameTable.Width = this.Width;
            this.m_frameTable.Height = this.Height;
            this.AddChidren(this.m_frameTable);
            base.AddChidren(this.m_frameTable);
        }
        #endregion
@@ -64,24 +76,25 @@
        #region ■ 添加子控件_________________________
        /// <summary>
        /// 添加Frame子控件
        /// 添加Frame子控件(注意,它是往下加控件,只会改变坐标,桌布大小会增加)
        /// </summary>
        /// <param name="view"></param>
        public void AddChidrenFrame(FrameLayout frame)
        public override void AddChidren(View view)
        {
            //初始化桌布控件
            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;
                view.Y = value + rowSpace;
            }
            this.m_frameTable.AddChidren(frame);
            this.m_frameTable.AddChidren(view);
            //调整桌布高度
            if (this.m_frameTable.Height < frame.Bottom)
            if (this.m_frameTable.Height < view.Bottom)
            {
                this.m_frameTable.Height = frame.Bottom;
                this.m_frameTable.Height = view.Bottom;
            }
        }
@@ -90,20 +103,36 @@
        #region ■ 一般方法___________________________
        /// <summary>
        /// 调整子FrameLayout的高度
        /// 调整子FrameLayout的高度(只扩大,不缩小)
        /// </summary>
        /// <param name="frame"></param>
        /// <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;
                }
            }
        }
        /// <summary>
        /// 调整子FrameLayout的真实高度
        /// </summary>
        /// <param name="frame"></param>
        public void AdjustChidrenFrameRealHeight(FrameLayout frame)
        {
            //获取坐标底部最下面的那个控件的底部坐标
            int value = this.GetLocationMostLastViewBottom(frame);
            if (value != -1)
            {
                //调整桌布高度
                frame.Height = value;
            }
        }
@@ -112,24 +141,38 @@
        /// </summary>
        public void AdjustTableHeight()
        {
            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;
                //if (this.m_frameTable.Height < child.Bottom)
                //{
                //    this.m_frameTable.Height = child.Bottom;
                //}
                this.m_frameTable.Height = value;
            }
            else
            {
                //还原为原来的高度
                this.RecoverTableHeight();
            }
        }
        /// <summary>
        /// 针对底部点击按钮,调整控件真实高度
        /// </summary>
        /// <param name="correctionsValue">Y轴补正值(真实值,列表控件不在bodyFramelayout的时候使用)</param>
        /// <param name="correctionsValue">
        /// <para>Y轴补正值(真实值,列表控件不在bodyFramelayout的时候使用)</para>
        /// <para>一般为正数,如果为负数代表bodyFramelayout超出了顶部</para>
        /// </param>
        public void AdjustRealHeightByBottomButton(int correctionsValue = 0)
        {
            //调整桌布高度 2020.05.25追加
            this.AdjustTableHeight();
            var btnTemp = new BottomClickButton();
            if (btnTemp.Yaxis >= this.m_frameTable.Height + correctionsValue)
            {
@@ -137,9 +180,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.AddChidren(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