From 3f6685c77beeb12baf840733fb890860f4c26e7c Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期四, 25 七月 2024 17:25:59 +0800
Subject: [PATCH] 2024年07月25日17:24:45

---
 HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/TypeSingleFramLayout.cs |  198 +++++++++++++++++++++++++------------------------
 1 files changed, 101 insertions(+), 97 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/TypeSingleFramLayout.cs b/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/TypeSingleFramLayout.cs
index 73763f8..bd98ba4 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/TypeSingleFramLayout.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/TypeSingleFramLayout.cs
@@ -4,105 +4,82 @@
 
 namespace HDL_ON.UI.UI2.FuntionControlView.Aks.CommonView
 {
-    public class TypeSingleFramLayout : BaseFramLayout
+    public class TypeSingleFramLayout
     {
+        /// <summary>
+        /// 鏄惁鍙互鐐瑰嚮
+        /// </summary>
+        private bool mIsClick = true;
+        private uint UpBackgroundColor = BaseFramLayout.unParentBackgroundColor;
+        private uint DownBackgroundColor = BaseFramLayout.seleBackgroundColor;
 
-        private uint UpBackgroundColor = 0x00000000;
-        private uint DownBackgroundColor = 0xff454635;
-        public TypeSingleFramLayout(int width, int height)
+        /// <summary>
+        /// 璁剧疆鎺у埗鐐瑰嚮浜嬩欢
+        /// </summary>
+        /// <param name="isClick">false鐐瑰嚮鏃犳晥</param>
+        public void setClick(bool isClick)
         {
-            this.Width = Application.GetRealWidth(width);
-            this.Height = Application.GetRealHeight(height);
-            this.Radius = (uint)Application.GetRealHeight(20);
-            this.BackgroundColor = MusicColor.ViewColor;
-
+            this.mIsClick = isClick;
         }
-
-        Button btnLeftImage = new Button
+       
+        /// <summary>
+        /// 鍗曚釜绫诲瀷瀹瑰櫒
+        /// </summary>
+        public FrameLayout singleFramLayout = new FrameLayout
         {
-            X=Application.GetRealWidth(16),
+            BackgroundColor = MusicColor.ViewColor,
+            //Gravity = Gravity.CenterHorizontal,
+            Width = Application.GetRealWidth(101),
+            Height = Application.GetRealHeight(34),//40
+            Radius = (uint)Application.GetRealHeight(17),
+        };
+
+        public Button btnLeftImage = new Button
+        {
+            X = Application.GetRealWidth(16),
             Width = Application.GetRealWidth(16),
             Height = Application.GetRealWidth(16),
             UnSelectedImagePath = "AksIcon/yingku.png",
             Gravity = Gravity.CenterVertical,
             Name = "btnLeftImage",
         };
-        Button btnName = new Button
+
+        public Button btnName = new Button
         {
+
             Width = Application.GetRealWidth(32),
             Height = Application.GetRealHeight(23),
-           TextID=StringId.yingku,
+            TextID = StringId.yingku,
             TextSize = TextSize.Text16,
             TextColor = MusicColor.TextColor,
             TextAlignment = TextAlignment.Center,
             Gravity = Gravity.CenterVertical,
-            IsMoreLines = true,
+            Padding = new Padding(0, 0, 0, 0),
             Name = "btnName",
         };
 
-        Button btnRightImage = new Button
+        public Button btnRightImage = new Button
         {
-            Width = Application.GetRealWidth(16),
-            Height = Application.GetRealWidth(16),
+
+            Width = Application.GetRealWidth(5),
+            Height = Application.GetRealWidth(8),
             UnSelectedImagePath = "AksIcon/yingkunext.png",
             Gravity = Gravity.CenterVertical,
             Name = "btnRightImage",
         };
 
 
-        public void AddBtnLeftImage()
+        public void AddView(FrameLayout layout)
         {
-            this.AddChidren(btnLeftImage);
-        }
-
-        public void AddBtnName(int gap = 4)
-        {
-            this.AddChidren(btnName);
-            if (this.IsAddBtn(btnLeftImage))
-            {
-                btnName.X = btnLeftImage.Right + Application.GetRealWidth(gap);
-            }
-
-            //if (btnName.GetTextWidth() < btnName.Width)
-            //{
-            //    btnName.Width = btnName.GetTextWidth();
-            //}
-        
-        }
-
-        public void AddBtnRightImage(int gap = 8)
-        {
-            this.AddChidren(btnRightImage);
-            if (this.IsAddBtn(btnName))
-            {
-                btnRightImage.X = btnName.Right + Application.GetRealWidth(gap);
-                if (gap == 8)
-                {
-                    btnRightImage.Width = Application.GetRealWidth(5);
-                    btnRightImage.Height = Application.GetRealHeight(8);
-                }
-
-            }
-         
+            layout.AddChidren(singleFramLayout);
+            singleFramLayout.AddChidren(btnLeftImage);
+            singleFramLayout.AddChidren(btnName);
+            singleFramLayout.AddChidren(btnRightImage);
+            btnName.X = btnLeftImage.Right + Application.GetRealWidth(4);
+            btnRightImage.X = btnName.Right + Application.GetRealWidth(8);
         }
 
 
-
-
-        public Button GetBtnLeftImage()
-        {
-            return btnLeftImage;
-        }
-
-        public Button GetBtnName()
-        {
-            return btnName;
-        }
-
-        public Button GetBtnRightImage()
-        {
-            return btnRightImage;
-        }
 
         public void SetClickUpBackgroundColor(uint backgroundColor)
         {
@@ -118,16 +95,17 @@
         /// <summary>
         /// 浜嬩欢鐩戝惉鏂规硶
         /// </summary>
-        /// <param name="action">鍥炶皟(绗竴涓槸鐖剁被瀵硅薄;绗簩涓槸鍥炬爣瀵硅薄;绗笁涓槸鐘舵�佸璞�</param>
-        public void SetClickListener(Action<FrameLayout, Button, Button, Button> action)
+        /// <param name="action">鍥炶皟(绗竴涓槸鐖剁被瀵硅薄;</param>
+        public void SetClickListener(Action<FrameLayout> action)
         {
             EventHandler<MouseEventArgs> UpClick = (sender, e) =>
             {
-                this.BackgroundColor = this.UpBackgroundColor;
-                action?.Invoke(this, btnLeftImage, btnName, btnRightImage);
+                action?.Invoke(singleFramLayout);
+                //singleFramLayout.BackgroundColor = this.UpBackgroundColor;
+
                 //寮硅捣鏉ヨ繕鍘熻儗鏅鑹�
             };
-            this.MouseUpEventHandler += UpClick;
+            singleFramLayout.MouseUpEventHandler += UpClick;
             btnLeftImage.MouseUpEventHandler += UpClick;
             btnName.MouseUpEventHandler += UpClick;
             btnRightImage.MouseUpEventHandler += UpClick;
@@ -135,45 +113,71 @@
             EventHandler<MouseEventArgs> DownClick = (sender, e) =>
             {
                 //鎸変笅鍘绘敼鍙樿儗鏅鑹�
-                this.BackgroundColor = this.DownBackgroundColor;
+                //singleFramLayout.BackgroundColor = this.DownBackgroundColor;
+
             };
-            this.MouseDownEventHandler += DownClick;
+            singleFramLayout.MouseDownEventHandler += DownClick;
             btnLeftImage.MouseDownEventHandler += DownClick;
             btnName.MouseDownEventHandler += DownClick;
             btnRightImage.MouseDownEventHandler += DownClick;
         }
+
+
         /// <summary>
-        /// 鍦ㄧ埗甯冨眬鏌ユ壘瀛愭帶浠舵槸鍚﹀瓨鍦�
+        /// 鑷姩璁$畻鎺т欢闀垮害
         /// </summary>
-        /// <param name="btn">鏌ユ壘瀵硅薄</param>
-        /// <returns>瀛樺湪涓簍rue,鍚﹀垯涓篺alse</returns>
-        private bool IsAddBtn(View btn)
+        /// <param name="orientation">浣嶇疆(宸︽垨鍙�)</param>
+        /// <param name="frame">鐖跺鍣�</param>
+        /// <param name="btnName">澶囨敞鎺т欢</param>
+        /// <param name="btnImage">鍥炬爣澶囨敞鎺т欢</param>
+        /// <param name="btnNameWidth">澶囨敞鎺т欢瀹藉害</param>
+        /// <param name="btnNameWidthMaxValue">澶囨敞鎺т欢瀹藉害鏈�澶у��</param> 
+        /// <param name="parentDefaultWidthMaxValue">鐖舵帶浠跺搴﹂粯璁ゆ渶澶у��</param>
+        public void CustomCalculationWidth(Orientation orientation, FrameLayout frame, Button btnName, Button btnImage, int btnNameWidth,int btnNameWidthMaxValue = 110, int parentDefaultWidthMaxValue = 101)
         {
 
-            if (this.ChildrenCount <= 0 || btn == null)
-            {
-                return false;
-            }
-            for (int i = 0; i < this.ChildrenCount; i++)
-            {
-                View view = this.GetChildren(i);
-                if (view == null)
-                {
-                    continue;
-                }
-                if (view is Button)
-                {
-                    if (view.Name == btn.Name)
-                    {
-                        return true;
-                    }
-                }
+            int parentRightX = 226;
+            int parentLeftX = 16;
 
+
+            if (btnName.GetTextWidth() > Application.GetRealWidth(btnNameWidth))
+            {
+                frame.Width = Application.GetRealWidth(parentDefaultWidthMaxValue - btnNameWidth) + btnName.GetTextWidth();
+                if (orientation == Orientation.right)
+                {
+                    frame.X = Application.GetRealWidth(parentRightX + btnNameWidth) - btnName.GetTextWidth();
+                }
+                else if (orientation == Orientation.left)
+                {
+                    frame.X = Application.GetRealWidth(parentLeftX);
+                }
+                btnName.Width = btnName.GetTextWidth();
+                btnImage.X = btnName.Right + Application.GetRealWidth(8);
             }
-            return false;
+
+            if (btnName.GetTextWidth() > Application.GetRealWidth(btnNameWidthMaxValue))
+            {
+
+                btnName.Width = Application.GetRealWidth(btnNameWidthMaxValue);
+                if (orientation == Orientation.right)
+                {
+                    frame.X =Application.GetRealWidth(parentRightX+ btnNameWidth) - btnName.Width;
+                }
+                else if (orientation == Orientation.left)
+                {
+                    frame.X = Application.GetRealWidth(parentLeftX);
+                }
+                frame.Width = Application.GetRealWidth(parentDefaultWidthMaxValue - btnNameWidth) + btnName.Width;
+                btnImage.X = btnName.Right + Application.GetRealWidth(8);
+            }
 
         }
 
+        public enum Orientation
+        {
+            left,
+            right,
 
+        }
     }
 }
\ No newline at end of file

--
Gitblit v1.8.0