From 3793a9a38ac6c4c4111c2bba3a35a71c30601e82 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 13 四月 2020 19:38:24 +0800
Subject: [PATCH] 上传个东西

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/InformationEditorControl.cs |  136 ++++++++++++++++++++++++++++++++++++--------
 1 files changed, 110 insertions(+), 26 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/InformationEditorControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/InformationEditorControl.cs
index cbae180..62f0a2b 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/InformationEditorControl.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/InformationEditorControl.cs
@@ -9,23 +9,42 @@
     /// </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">bodyFrameLayout</param>
+        /// <param name="bodyFrameLayout">鐖舵帶浠�</param>
         /// <param name="title">鏍囬鏂囨湰</param>
-        /// <param name="Y">bodyFrameLayout閲岄潰鐨刌杞村潗鏍�</param>
         /// <param name="Height">钃濇箹UI閲岄潰瀹冪殑楂樺害</param>
         /// <returns>淇℃伅瀹瑰櫒鎺т欢</returns>
-        public VerticalListControl InitControl(FrameLayout bodyFrameLayout, string title, int Y, int Height)
+        public FrameListControl InitControl(FrameLayout bodyFrameLayout, string title, int Height)
         {
             //鏄庣粏鍒楄〃鐨勬甯冿紝鐧借壊鑳屾櫙
-            var detailBackFrame = new FrameLayout();
-            detailBackFrame.Y = Application.GetRealHeight(Y);
-            detailBackFrame.Height = Application.GetRealHeight(Height + 100);//楂樺害灏辨槸瑕佸畠瓒呰繃
+            this.detailBackFrame = new FrameLayout();
+            detailBackFrame.Height = Application.GetRealHeight(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);
@@ -36,7 +55,8 @@
             btnTile.Text = title;
             detailBackFrame.AddChidren(btnTile);
 
-            var listview = new VerticalListControl(12);
+            //鍒楄〃鎺т欢
+            this.listview = new FrameListControl(12);
             listview.Y = btnTile.Bottom + Application.GetRealHeight(17);
             listview.Height = Application.GetRealHeight(Height) - btnTile.Bottom - Application.GetRealHeight(17);
             detailBackFrame.AddChidren(listview);
@@ -45,31 +65,95 @@
         }
 
         /// <summary>
-        /// 瀹屾垚鍒濆鍖�(褰撹鏁板鐨勬椂鍊�,杩欎釜鍑芥暟寰堟湁鐢ㄣ�傝鏁颁笉瓒呰繃瀹瑰櫒鏃讹紝璋冧笉璋冪敤杩欎釜鍑芥暟閮芥病浜�)
+        /// 瀹屾垚鍒濆鍖�
         /// </summary>
-        /// <param name="bodyFrameLayout">bodyFrameLayout</param>
-        /// <param name="listview">瀹瑰櫒鎺т欢</param>
-        public void FinishInitControl(FrameLayout bodyFrameLayout, VerticalListControl listview)
+        /// <param name="HadBottomButton">杩欎釜鎺т欢鎵�鍦ㄧ殑鐣岄潰,搴曢儴鏈夋病鏈変繚瀛樻寜閽�</param>
+        /// <param name="mandatoryAdjustment">寮哄埗璋冩暣楂樺害</param>
+        public void FinishInitControl(bool HadBottomButton = true, bool mandatoryAdjustment = false)
         {
-            var btnFinish = new BottomClickButton();
-            //鍊熺敤Y杞村潗鏍�(璁╄繖涓尯鍩熶笉鑳界偣鍑昏彍鍗�)
-            //var frameBack = new FrameLayout();
-            //frameBack.Y = btnFinish.Yaxis;
-            //frameBack.Height = bodyFrameLayout.Height - btnFinish.Yaxis;
-            //bodyFrameLayout.AddChidren(frameBack);
-
-            if (listview.ChildrenCount > 0)
+            if (HadBottomButton == true)
             {
-                var realHeight = listview.GetChildren(0).Height * listview.ChildrenCount;
-                if (bodyFrameLayout.Height - btnFinish.Yaxis + realHeight > listview.Height)
+                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)
                 {
-                    //淇冧娇琚尅浣忕殑鑿滃崟鑳藉鍚戜笂婊戝姩
-                    var frameTemp = new FrameLayout();
-                    //frameTemp.Height = frameBack.Height + Application.GetRealHeight(115);
-                    frameTemp.Height = bodyFrameLayout.Height - btnFinish.Yaxis + Application.GetRealHeight(115);
-                    listview.AddChidren(frameTemp);
+                    //涓嶉渶瑕佽皟鏁�
+                    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
     }
 }

--
Gitblit v1.8.0