From 47d1c43905afa377e411dbfa8bec325de3cd6579 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期一, 07 八月 2023 15:35:30 +0800
Subject: [PATCH] 2023年08月07日15:35:10

---
 HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/CornerFramLayout.cs |  317 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 286 insertions(+), 31 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/CornerFramLayout.cs b/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/CornerFramLayout.cs
index 2d3b075..443c3e0 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/CornerFramLayout.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/CornerFramLayout.cs
@@ -19,27 +19,28 @@
         /// </summary>
         private int mRowNumber;
 
-        private List<int> mList;
+        private List<string> mList;
 
-        public Action<int> selectAction = null;
+        public Action<string> selectAction = null;
         /// <summary>
         /// 褰撳墠閫夋嫨鐨勭储寮�(鍐呴儴浣跨敤)
         /// </summary>
         private int CurrnetSelectIndex = -1;
+
+
         /// <summary>
         /// 
         /// </summary>
         /// <param name="width">瀹瑰櫒瀹藉害</param>
         /// <param name="height">瀹瑰櫒楂樺害</param>
-        ///<param name="rowNumber">涓�琛屽嚑涓厓绱�</param>
         ///<param name="rowNumber">鍦嗚鍊�</param>
-        public CornerFramLayout(int width, int height, int rowNumber,int radius=0)
+        public CornerFramLayout(int width, int height, int radius = 0)
         {
             this.BackgroundColor = MusicColor.WhiteColor;
             this.Width = Application.GetRealWidth(width);
             this.Height = Application.GetRealHeight(height);
             this.Radius = (uint)Application.GetRealHeight(radius);
-            this.mRowNumber = rowNumber;
+
 
         }
         /// <summary>
@@ -61,11 +62,11 @@
         /// 璁剧疆鍒楄〃鏁版嵁(璇峰湪鍒濆鍖栧畬鎴愪箣鍓嶈皟鐢�)
         /// </summary>
         /// <param name="list"></param>
-        public void SetList(List<int> list)
+        public void SetList(List<string> list)
         {
             if (list == null)
             {
-                list = new List<int>();
+                list = new List<string>();
             }
             this.mList = list;
         }
@@ -73,12 +74,19 @@
         /// <summary>
         /// 鑾峰彇娴嬭瘯鍒楄〃鏁版嵁
         /// </summary>
-        public List<int> GetTestList(int count)
+        public List<string> GetTestList(int count)
         {
-            var list = new List<int>();
+            var list = new List<string>();
             for (int i = 1; i <= count; i++)
             {
-                list.Add(i);
+                if (i % 2 == 0)
+                {
+                    list.Add("浣犲ソ鍌诲摝!");
+                }
+                else
+                {
+                    list.Add("鐪熺殑鏄繖鏍风殑鍚�?");
+                }
             }
             return list;
         }
@@ -86,19 +94,22 @@
         /// <summary>
         /// 鍔ㄦ�佸姞杞芥寜閿晫闈�
         /// </summary>
-        public void LoadButtonPage()
+        /// <param name="mRowNumber">涓�琛屽灏戜釜鍏冪礌</param>
+        public void LoadButtonPage(int mRowNumber)
         {
-            if (this.mRowNumber == 0)
+            if (mRowNumber == 0)
             {
                 return;
             }
+            this.mRowNumber = mRowNumber;
             int line = 0;
             int xCount = 0;
             for (int i = 1; i <= this.mList.Count; i++)
             {
-                ButtonFramLayout buttonFram = new ButtonFramLayout();             
+                var d = this.mList[i - 1];
+                ButtonFramLayout buttonFram = new ButtonFramLayout();
                 this.AddChidren(buttonFram);
-                buttonFram.Tag = i - 1;
+                buttonFram.Tag = d;
                 buttonFram.Y = Application.GetRealHeight(this.topMargin) + Application.GetRealHeight(ButtonFramLayout.heightFrameLayout * line);
                 buttonFram.X = Application.GetRealWidth(this.leftMargin) + Application.GetRealWidth(ButtonFramLayout.widthFrameLayout * xCount);
                 buttonFram.AddImageView();
@@ -111,7 +122,7 @@
                 {
                     buttonFram.AddBottomLine();
                 }
-                buttonFram.GetNameButton().Text = i.ToString();
+                buttonFram.GetNameButton().Text = d;
 
                 xCount++;
                 if (i % this.mRowNumber == 0)
@@ -122,7 +133,10 @@
                 }
                 buttonFram.SetClickListener((fl, btnIcon, btnName) =>
                 {
-                    selectAction?.Invoke((int)buttonFram.Tag);
+                    if (buttonFram.Tag != null)
+                    {
+                        selectAction?.Invoke(buttonFram.Tag.ToString());
+                    }
                 });
 
                 //if (CurrnetSelectIndex != -1 && CurrnetSelectIndex == i)
@@ -134,30 +148,198 @@
             }
         }
 
+        /// <summary>
+        /// 鍔ㄦ�佸姞杞芥寜閿晫闈�
+        /// </summary>
+        /// <param name="list">绱㈠紩鍒楄〃,琛ㄧず鏌愪竴鏉″搴﹀姞瀹�</param>
+        public void LoadButtonPage(List<int> list)
+        {
+
+            int currnetheightValue = 0;
+            int currnetWidthValue = 0;
+            //鑾峰彇鐩稿涓�涓含搴﹀��
+            int heightDimensionValue = this.Height - Application.GetRealHeight(this.topMargin) - Application.GetRealHeight(this.bottomMargin) - Application.GetRealHeight(ButtonFramLayout.heightFrameLayout / 2);
+            int widthDimensionValue = this.Width - Application.GetRealWidth(this.leftMargin) - Application.GetRealWidth(this.rightMargin) - Application.GetRealHeight(ButtonFramLayout.widthFrameLayout / 2);
+            for (int i = 1; i <= this.mList.Count; i++)
+            {
+                var d = this.mList[i - 1];
+                ButtonFramLayout buttonFram = null;
+                if (list.Contains(i))
+                {
+                    buttonFram = new ButtonFramLayout(ButtonFramLayout.widthFrameLayout * 2);
+                    buttonFram.Y = Application.GetRealHeight(this.topMargin) + Application.GetRealHeight(currnetheightValue);
+                    buttonFram.X = Application.GetRealWidth(this.leftMargin) + Application.GetRealWidth(currnetWidthValue);
+                    currnetWidthValue += ButtonFramLayout.widthFrameLayout * 2;
+                }
+                else
+                {
+                    buttonFram = new ButtonFramLayout();
+                    buttonFram.Y = Application.GetRealHeight(this.topMargin) + Application.GetRealHeight(currnetheightValue);
+                    buttonFram.X = Application.GetRealWidth(this.leftMargin) + Application.GetRealWidth(currnetWidthValue);
+                    currnetWidthValue += ButtonFramLayout.widthFrameLayout;
+
+                }
+
+                this.AddChidren(buttonFram);
+                buttonFram.AddImageView();
+                buttonFram.AddNameView();
+                buttonFram.Tag = d;//鏍囪鏁版嵁
+                buttonFram.GetNameButton().Text = d.ToString();
+                if (widthDimensionValue > Application.GetRealWidth(currnetWidthValue))
+                {
+                    //鍔犲彸绾�
+                    buttonFram.AddRightLine();
+                }
+
+                if (heightDimensionValue > buttonFram.Bottom)
+                {
+                    //鍔犲簳绾�
+                    buttonFram.AddBottomLine();
+                }
+
+                if (widthDimensionValue < Application.GetRealWidth(currnetWidthValue))
+                {
+                    currnetheightValue += ButtonFramLayout.heightFrameLayout;
+                    currnetWidthValue = 0;
+                }
+
+                buttonFram.SetClickListener((fl, btnIcon, btnName) =>
+                {
+                    if (buttonFram.Tag != null)
+                    {
+                        selectAction?.Invoke(buttonFram.Tag.ToString());
+                    }
+                });
+
+                //if (CurrnetSelectIndex != -1 && CurrnetSelectIndex == i)
+                //{
+                //    selectAction?.Invoke((int)buttonFram.Tag);
+                //}
+            }
+        }
+
+        /// <summary>
+        ///鍔ㄦ�佸姞杞芥暟瀛楁寜閿晫闈�
+        /// </summary>
+        public void LoadNumberButtonPage()
+        {
+            int currnetheightValue = 0;
+            int currnetWidthValue = 0;
+            int heightMaxValue = 84;
+            int widthMaxValue = 78;
+            //鑾峰彇鐩稿涓�涓含搴﹀��
+            int heightDimensionValue = this.Height - Application.GetRealHeight(this.topMargin) - Application.GetRealHeight(this.bottomMargin) - Application.GetRealHeight(heightMaxValue / 2);
+            int widthDimensionValue = this.Width - Application.GetRealWidth(this.leftMargin) - Application.GetRealWidth(this.rightMargin) - Application.GetRealHeight(widthMaxValue / 2);
+            for (int i = 1; i <= this.GetNumberTextList().Count; i++)
+            {
+                var d = this.GetNumberTextList()[i - 1];
+                Button button = new Button
+                {
+                    Y = Application.GetRealHeight(this.topMargin) + Application.GetRealHeight(currnetheightValue),
+                    X = Application.GetRealWidth(this.leftMargin) + Application.GetRealWidth(currnetWidthValue),
+                    Width = Application.GetRealWidth(widthMaxValue),
+                    Height = Application.GetRealHeight(heightMaxValue),
+                    Text = d,
+                    TextSize = TextSize.Text20,
+                    TextColor = MusicColor.TextColor,
+                    TextAlignment = TextAlignment.Center,
+                    IsBold = true,
+                    Tag = d,
+                    BackgroundColor = MusicColor.WhiteColor,
+                    SelectedBackgroundColor = 0xff454635,
+                };
+                this.AddChidren(button);
+
+                currnetWidthValue += widthMaxValue;
+                if (widthDimensionValue < Application.GetRealWidth(currnetWidthValue))
+                {
+                    currnetheightValue += heightMaxValue;
+                    currnetWidthValue = 0;
+                }
+                button.MouseDownEventHandler += (sen, e) =>
+                {
+                    if (button.Tag == null || string.IsNullOrEmpty(button.Tag.ToString()))
+                    {
+                        return;
+                    }
+                    button.IsSelected = true;
+                    selectAction?.Invoke(button.Tag.ToString());
+                };
+                button.MouseUpEventHandler += (sen, e) =>
+                {
+                    button.IsSelected = false;
+                };
+
+                //if (CurrnetSelectIndex != -1 && CurrnetSelectIndex == i)
+                //{
+                //    selectAction?.Invoke((int)buttonFram.Tag);
+                //}
+            }
+        }
 
         /// <summary>
         /// 鍔ㄦ�佸姞杞藉浘鐗囩晫闈�
         /// </summary>
         public void LoadImagePage()
         {
-            if (this.mRowNumber == 0)
+            int currnetheightValue = 0;
+            int currnetWidthValue = 0;
+            int heightMaxValue = ImageFramlayout.heightFrameLayout;
+            int widthMaxValue = ImageFramlayout.widthFrameLayout;
+            //鑾峰彇鐩稿涓�涓含搴﹀��
+            int heightDimensionValue = this.Height - Application.GetRealHeight(this.topMargin) - Application.GetRealHeight(this.bottomMargin) - Application.GetRealHeight(heightMaxValue / 2);
+            int widthDimensionValue = this.Width - Application.GetRealWidth(this.leftMargin) - Application.GetRealWidth(this.rightMargin) - Application.GetRealHeight(widthMaxValue / 2);
+            for (int i = 1; i <= this.mList.Count; i++)
+            {
+                var d = this.mList[i - 1];
+                ImageFramlayout imageFram = new ImageFramlayout();
+                imageFram.AddView(this);
+                imageFram.Tag = d;
+                imageFram.Y = Application.GetRealHeight(this.topMargin) + Application.GetRealHeight(currnetheightValue);
+                imageFram.X = Application.GetRealWidth(currnetWidthValue);
+                imageFram.btnName.Text = d;
+                currnetWidthValue += (widthMaxValue + 8);//8鏄殧闂村��
+                if (widthDimensionValue < Application.GetRealWidth(currnetWidthValue))
+                {
+                    currnetheightValue += (heightMaxValue + 20);//20鏄殧闂村��
+                    currnetWidthValue = 0;
+                }
+
+                imageFram.SetClickListener((fl) =>
+                {
+                    if (imageFram.Tag != null)
+                    {
+                        selectAction?.Invoke(imageFram.Tag.ToString());
+                    }
+                });
+                //if (CurrnetSelectIndex != -1 && CurrnetSelectIndex == i)
+                //{
+                //    selectAction?.Invoke((int)imageFram.Tag);
+                //}
+            }
+        }
+        /// <summary>
+        /// 鍔ㄦ�佸姞杞藉浘鐗囩晫闈�
+        /// </summary>
+        /// <param name="mRowNumber">涓�琛屽灏戜釜鍏冪礌</param>
+        public void LoadImagePage(int mRowNumber)
+        {
+            if (mRowNumber == 0)
             {
                 return;
             }
+            this.mRowNumber = mRowNumber;
             int line = 0;
             int xCount = 0;
             for (int i = 1; i <= this.mList.Count; i++)
             {
+                var d = this.mList[i - 1];
                 ImageFramlayout imageFram = new ImageFramlayout();
                 imageFram.AddView(this);
-                //this.AddChidren(imageFram);
-                imageFram.Tag = i - 1;
-                imageFram.Y = Application.GetRealHeight(this.topMargin)+ Application.GetRealHeight((ImageFramlayout.heightFrameLayout + 20) * line);
+                imageFram.Tag = d;
+                imageFram.Y = Application.GetRealHeight(this.topMargin) + Application.GetRealHeight((ImageFramlayout.heightFrameLayout + 20) * line);
                 imageFram.X = Application.GetRealWidth((ImageFramlayout.widthFrameLayout + 8) * xCount);
-                //imageFram.AddImageView();
-                //imageFram.AddScoreButton();
-                //imageFram.AddNameButton();
-                imageFram.btnName.Text = i.ToString();
+                imageFram.btnName.Text = d;
 
                 xCount++;
                 if (i % this.mRowNumber == 0)
@@ -168,7 +350,10 @@
                 }
                 imageFram.SetClickListener((fl) =>
                 {
-                    selectAction?.Invoke((int)imageFram.Tag);
+                    if (imageFram.Tag != null)
+                    {
+                        selectAction?.Invoke(imageFram.Tag.ToString());
+                    }
                 });
 
                 //if (CurrnetSelectIndex != -1 && CurrnetSelectIndex == i)
@@ -192,29 +377,33 @@
         /// <summary>
         /// 鏈�鍚庝竴琛�
         /// </summary>
-        /// <param name="value"></param>
+        /// <param name="index">褰撳墠绱㈠紩鍊�</param>
         /// <returns></returns>
-        private bool IsLastColumn(int value)
+        private bool IsLastColumn(int index)
         {
-            int lineCount = this.mList.Count / this.mRowNumber;
+            if (this.mRowNumber == 0 || this.mList == null || this.mList.Count == 0)
+            {
+                return false;
+            }
+            int lineCount = this.mList.Count / this.mRowNumber;//寰楀嚭琛屾暟
             int number = this.mList.Count % this.mRowNumber;
             if (number != 0)
             {
-                if (value > lineCount * this.mRowNumber)
+                if (index > lineCount * this.mRowNumber)
                 {
                     return true;
                 }
             }
             else
             {
-                if (value > lineCount-- * this.mRowNumber)
+                int value = --lineCount * this.mRowNumber;
+                if (index > value)
                 {
                     return true;
                 }
 
             }
             return false;
-
         }
         /// <summary>
         /// 鏈�鍚庡彸杈归偅涓�涓�
@@ -223,11 +412,77 @@
         /// <returns></returns>
         private bool IsLastRight(int value)
         {
+            if (this.mRowNumber == 0)
+            {
+                return false;
+            }
             if (value % this.mRowNumber == 0)
             {
                 return true;
             };
             return false;
         }
+
+
+        /// <summary>
+        /// 閲嶆柊璁$畻button瀹藉害
+        /// </summary>
+        /// <param name="button">鎺т欢</param>
+        /// <param name="widthMax">瀹藉害鏈�澶ф渶</param>
+        /// <param name="padding">鍐呰竟璺�</param>
+        private void AdjustRealWidth(Button button, int widthMax = 0, int padding = 0)
+        {
+            if (button == null)
+            {
+                return;
+            }
+            int width;
+            if (widthMax == 0)
+            {
+                //鍐呰竟璺�
+                width = button.GetTextWidth() + Application.GetRealWidth(padding * 2);
+            }
+            else
+            {
+                if (button.GetTextWidth() > Application.GetRealWidth(widthMax))
+                {
+
+                    button.TextSize = 10;//鎺т欢楂樺害涓嶅彉,鏀瑰彉瀛椾綋澶у皬,鍑嗗鎹㈣;
+                    width = Application.GetRealWidth(widthMax);
+                }
+                else
+                {
+                    width = button.GetTextWidth();
+                }
+
+            }
+
+            button.Width = width;
+        }
+
+
+
+        public List<string> GetNumberTextList()
+        {
+            return new List<string>
+            {
+                "1",
+                "2",
+                "3",
+                Language.StringByID(StringId.pindaojia),
+                "4",
+                "5",
+                "6",
+                Language.StringByID(StringId.pindaojian),
+                "7",
+                "8",
+                "9",
+                "-/--",
+                "",//杩欎釜鏄负浜嗗崰浣嶇疆
+                "0"
+
+            };
+
+        }
     }
 }

--
Gitblit v1.8.0