gxc
2020-02-28 66a9965c44ecc32a6696abca876ab9d1cd091584
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/ListViewLayoutControls/VerticalListControl.cs
@@ -23,6 +23,21 @@
        /// 一个没什么用的东西
        /// </summary>
        private FrameLayout frameBackTemp = null;
        /// <summary>
        /// 自定义的获取子控件个数
        /// </summary>
        public new int ChildrenCount
        {
            get
            {
                int count = base.ChildrenCount;
                if (frameBackTemp != null && frameBackTemp.Parent != null)
                {
                    count--;
                }
                return count < 0 ? 0 : count;
            }
        }
        #endregion
@@ -34,7 +49,7 @@
        /// <param name="i_rowSpace">行之间的间距(这个值是与行控件绑定一起使用的)</param>
        public VerticalListControl(int i_rowSpace = 0)
        {
            rowSpace = Application.GetRealHeight(i_rowSpace);
            this.rowSpace = Application.GetRealHeight(i_rowSpace);
        }
        #endregion
@@ -82,16 +97,14 @@
        /// <param name="addSpace">当真实高度超过原有高度时,是否添加空白</param>
        public void AdjustRealHeight(int bottomSpace, bool addSpace = true)
        {
            int count = frameBackTemp == null ? this.ChildrenCount : this.ChildrenCount - 1;
            //总之,先重置至最大
            this.RecoverHeight();
            int count = this.ChildrenCount;
            if (count <= 0)
            {
                frameBackTemp?.RemoveFromParent();
                frameBackTemp = null;
                if (maxHeight != -1)
                {
                    //还原为最大高度
                    this.Height = maxHeight;
                }
                return;
            }
@@ -114,6 +127,42 @@
            }
        }
        /// <summary>
        /// 针对底部点击按钮,调整控件真实高度
        /// </summary>
        /// <param name="bottomSpace">底部空白间距(真实值,如果列表控件真实高度没有超过时,使用此值)</param>
        /// <param name="correctionsValue">Y轴补正值(真实值,列表控件不在bodyFramelayout的时候使用)</param>
        public void AdjustRealHeightByBottomButton(int bottomSpace, int correctionsValue = 0)
        {
            if (this.ChildrenCount == 0)
            {
                frameBackTemp?.RemoveFromParent();
                frameBackTemp = null;
                if (maxHeight != -1)
                {
                    //还原为最大高度
                    this.Height = maxHeight;
                }
                return;
            }
            var realHeight = this.ChildrenCount * this.GetChildren(0).Height + this.Y + correctionsValue;
            var btnTemp = new BottomClickButton();
            if (btnTemp.Yaxis >= realHeight)
            {
                //没有超过
                this.AdjustRealHeight(bottomSpace);
                return;
            }
            //超过时,重置至最大
            this.RecoverHeight();
            //添加临时控件,直至可以滑动超过底部按钮
            frameBackTemp?.RemoveFromParent();
            frameBackTemp = new FrameLayout();
            frameBackTemp.Height = ControlCommonResourse.BodyFrameHeight - btnTemp.Yaxis + bottomSpace;
            this.AddChidren(frameBackTemp);
        }
        #endregion
    }
}