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 | 92 +++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 82 insertions(+), 10 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/TypeSingleFramLayout.cs b/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/TypeSingleFramLayout.cs index c357a73..bd98ba4 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/TypeSingleFramLayout.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/TypeSingleFramLayout.cs @@ -6,19 +6,32 @@ { public class TypeSingleFramLayout { + /// <summary> + /// 鏄惁鍙互鐐瑰嚮 + /// </summary> + private bool mIsClick = true; + private uint UpBackgroundColor = BaseFramLayout.unParentBackgroundColor; + private uint DownBackgroundColor = BaseFramLayout.seleBackgroundColor; - private uint UpBackgroundColor = MusicColor.ViewColor; - private uint DownBackgroundColor = 0xff454635; + /// <summary> + /// 璁剧疆鎺у埗鐐瑰嚮浜嬩欢 + /// </summary> + /// <param name="isClick">false鐐瑰嚮鏃犳晥</param> + public void setClick(bool isClick) + { + this.mIsClick = isClick; + } + /// <summary> /// 鍗曚釜绫诲瀷瀹瑰櫒 /// </summary> public FrameLayout singleFramLayout = new FrameLayout { BackgroundColor = MusicColor.ViewColor, - Gravity = Gravity.CenterHorizontal, + //Gravity = Gravity.CenterHorizontal, Width = Application.GetRealWidth(101), - Height = Application.GetRealHeight(40), - Radius = (uint)Application.GetRealHeight(20), + Height = Application.GetRealHeight(34),//40 + Radius = (uint)Application.GetRealHeight(17), }; public Button btnLeftImage = new Button @@ -41,7 +54,7 @@ TextColor = MusicColor.TextColor, TextAlignment = TextAlignment.Center, Gravity = Gravity.CenterVertical, - IsMoreLines = true, + Padding = new Padding(0, 0, 0, 0), Name = "btnName", }; @@ -87,8 +100,9 @@ { EventHandler<MouseEventArgs> UpClick = (sender, e) => { - singleFramLayout.BackgroundColor = this.UpBackgroundColor; - + action?.Invoke(singleFramLayout); + //singleFramLayout.BackgroundColor = this.UpBackgroundColor; + //寮硅捣鏉ヨ繕鍘熻儗鏅鑹� }; singleFramLayout.MouseUpEventHandler += UpClick; @@ -99,13 +113,71 @@ EventHandler<MouseEventArgs> DownClick = (sender, e) => { //鎸変笅鍘绘敼鍙樿儗鏅鑹� - singleFramLayout.BackgroundColor = this.DownBackgroundColor; - action?.Invoke(singleFramLayout); + //singleFramLayout.BackgroundColor = this.DownBackgroundColor; + }; singleFramLayout.MouseDownEventHandler += DownClick; btnLeftImage.MouseDownEventHandler += DownClick; btnName.MouseDownEventHandler += DownClick; btnRightImage.MouseDownEventHandler += DownClick; } + + + /// <summary> + /// 鑷姩璁$畻鎺т欢闀垮害 + /// </summary> + /// <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) + { + + 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); + } + + 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