From 44d6b49d86f8c531cbed718a8c109f3bc2db2177 Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期三, 09 八月 2023 16:27:23 +0800 Subject: [PATCH] 2023年08月09日16:27:16 --- HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/CornerFramLayout.cs | 380 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 336 insertions(+), 44 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/CornerFramLayout.cs b/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/CornerFramLayout.cs index eb902d3..63c868a 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/CornerFramLayout.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/CornerFramLayout.cs @@ -2,6 +2,7 @@ using HDL_ON.UI.Music; using Shared; using System.Collections.Generic; +using HDL_ON.UI.UI2.FuntionControlView.Aks.Entity; namespace HDL_ON.UI.UI2.FuntionControlView.Aks.CommonView { @@ -10,26 +11,43 @@ /// </summary> public class CornerFramLayout : BaseFramLayout { - public const int cornerValue = 17; private int topMargin; private int leftMargin; private int bottomMargin; private int rightMargin; - + /// <summary> + /// 涓�琛屽嚑涓厓绱� + /// </summary> private int mRowNumber; + /// <summary> + /// 鍒楄〃鏈�澶у�� + /// </summary> + private int mListCount; - private List<int> mList; + public Action<KeypadEntity> selectAction = null; + /// <summary> + /// 褰撳墠閫夋嫨鐨勭储寮�(鍐呴儴浣跨敤) + /// </summary> + private int CurrnetSelectIndex = -1; - public CornerFramLayout(int width, int height) + + /// <summary> + /// + /// </summary> + /// <param name="width">瀹瑰櫒瀹藉害</param> + /// <param name="height">瀹瑰櫒楂樺害</param> + ///<param name="rowNumber">鍦嗚鍊�</param> + 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(cornerValue); + this.Radius = (uint)Application.GetRealHeight(radius); + } /// <summary> - /// 璁剧疆杈硅窛 + /// 璁剧疆鍐呰竟璺� /// </summary> /// <param name="top">涓婅竟璺�</param> /// <param name="bottom">涓嬭竟璺�</param> @@ -43,51 +61,37 @@ this.rightMargin = right; } - /// <summary> - /// 璁剧疆鍒楄〃鏁版嵁 - /// </summary> - /// <param name="list"></param> - public void SetList(List<int> list) - { - if (list == null) - { - list = new List<int>(); - } - this.mList = list; - } + /// <summary> /// 鑾峰彇娴嬭瘯鍒楄〃鏁版嵁 /// </summary> - public List<int> GetTestList(int count) + public List<KeypadEntity> GetTestList() { - var list = new List<int>(); - for (int i = 1; i <= count; i++) - { - list.Add(i); - } - return list; + return AksCommonMethod.Current.GetTYYKeypadList(); } /// <summary> - /// 鍔犺浇鎸夐敭鐣岄潰 + /// 鍔ㄦ�佸姞杞芥寜閿晫闈� /// </summary> - /// <param name="rowNumber">涓�琛屽嚑涓厓绱�</param> - /// <param name="action">鍥炶皟</param> - public void LoadButtonPage(int rowNumber, Action<int> action) + /// <param name="mList">鍒楄〃</param> + /// <param name="mRowNumber">涓�琛屽灏戜釜鍏冪礌</param> + public void LoadButtonPage(List<KeypadEntity> mList, int mRowNumber) { - if (rowNumber == 0) + if (mRowNumber == 0) { return; } - this.mRowNumber = rowNumber; + this.mRowNumber = mRowNumber; + this.mListCount = mList.Count; int line = 0; int xCount = 0; - for (int i = 1; i <= this.mList.Count; i++) + for (int i = 1; i <= mList.Count; i++) { + var keypad = mList[i - 1]; ButtonFramLayout buttonFram = new ButtonFramLayout(); this.AddChidren(buttonFram); - buttonFram.Tag = i - 1; + buttonFram.Tag = keypad; buttonFram.Y = Application.GetRealHeight(this.topMargin) + Application.GetRealHeight(ButtonFramLayout.heightFrameLayout * line); buttonFram.X = Application.GetRealWidth(this.leftMargin) + Application.GetRealWidth(ButtonFramLayout.widthFrameLayout * xCount); buttonFram.AddImageView(); @@ -100,10 +104,11 @@ { buttonFram.AddBottomLine(); } - buttonFram.GetNameButton().Text = i.ToString(); + buttonFram.GetImageButton().UnSelectedImagePath = keypad.localIconAddress; + buttonFram.GetNameButton().Text = keypad.name; xCount++; - if (i % rowNumber == 0) + if (i % this.mRowNumber == 0) { line++; @@ -111,40 +116,282 @@ } buttonFram.SetClickListener((fl, btnIcon, btnName) => { - action.Invoke((int)buttonFram.Tag); + if (buttonFram.Tag != null) + { + selectAction?.Invoke((KeypadEntity)buttonFram.Tag); + } }); + + //if (CurrnetSelectIndex != -1 && CurrnetSelectIndex == i) + //{ + // selectAction?.Invoke((int)buttonFram.Tag); + //} } - //this.AdjustRealHeight(this.bottomMargin); } /// <summary> + /// 鍔ㄦ�佸姞杞芥寜閿晫闈� + /// </summary> + /// <param name="mList">鍒楄〃</param> + /// <param name="list">鍒楄〃涓储寮�,琛ㄧず鏌愪竴鏉″搴﹀姞瀹�</param> + public void LoadButtonPage(List<KeypadEntity> mList, 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 <= mList.Count; i++) + { + var keypad = 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 = keypad;//鏍囪鏁版嵁 + buttonFram.GetImageButton().UnSelectedImagePath = keypad.localIconAddress; + buttonFram.GetNameButton().Text = keypad.name; + 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((KeypadEntity)buttonFram.Tag); + } + }); + + //if (CurrnetSelectIndex != -1 && CurrnetSelectIndex == i) + //{ + // selectAction?.Invoke((int)buttonFram.Tag); + //} + } + } + + /// <summary> + ///鍔ㄦ�佸姞杞芥暟瀛楁寜閿晫闈� + /// </summary> + public void LoadNumberButtonPage(List<KeypadEntity> mList) + { + + 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 <= mList.Count; i++) + { + var keypad = mList[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 = keypad.name, + TextSize = TextSize.Text20, + TextColor = MusicColor.TextColor, + TextAlignment = TextAlignment.Center, + IsBold = true, + Tag = keypad, + 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 || ((KeypadEntity)button.Tag).keypad == "none") + { + return; + } + button.IsSelected = true; + selectAction?.Invoke((KeypadEntity)button.Tag); + }; + button.MouseUpEventHandler += (sen, e) => + { + button.IsSelected = false; + }; + + //if (CurrnetSelectIndex != -1 && CurrnetSelectIndex == i) + //{ + // selectAction?.Invoke((int)buttonFram.Tag); + //} + } + } + + /// <summary> + /// 鍔ㄦ�佸姞杞藉浘鐗囩晫闈� + /// </summary> + public void LoadImagePage(List<KeypadEntity> mList) + { + 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 <= mList.Count; i++) + { + var keypad = mList[i - 1]; + ImageFramlayout imageFram = new ImageFramlayout(); + imageFram.AddView(this); + imageFram.Tag = keypad; + imageFram.Y = Application.GetRealHeight(this.topMargin) + Application.GetRealHeight(currnetheightValue); + imageFram.X = Application.GetRealWidth(currnetWidthValue); + imageFram.btnName.Text = keypad.name; + currnetWidthValue += (widthMaxValue + 8);//8鏄殧闂村�� + if (widthDimensionValue < Application.GetRealWidth(currnetWidthValue)) + { + currnetheightValue += (heightMaxValue + 20);//20鏄殧闂村�� + currnetWidthValue = 0; + } + + imageFram.SetClickListener((fl) => + { + if (imageFram.Tag != null) + { + selectAction?.Invoke((KeypadEntity)imageFram.Tag); + } + }); + //if (CurrnetSelectIndex != -1 && CurrnetSelectIndex == i) + //{ + // selectAction?.Invoke((int)imageFram.Tag); + //} + } + } + /// <summary> + /// 鍔ㄦ�佸姞杞藉浘鐗囩晫闈� + /// </summary> + /// <param name="mRowNumber">涓�琛屽灏戜釜鍏冪礌</param> + public void LoadImagePage(List<KeypadEntity> mList, int mRowNumber) + { + + if (mRowNumber == 0) + { + return; + } + this.mListCount = mList.Count; + this.mRowNumber = mRowNumber; + int line = 0; + int xCount = 0; + for (int i = 1; i <= mList.Count; i++) + { + var keypad = mList[i - 1]; + ImageFramlayout imageFram = new ImageFramlayout(); + imageFram.AddView(this); + imageFram.Tag = keypad; + imageFram.Y = Application.GetRealHeight(this.topMargin) + Application.GetRealHeight((ImageFramlayout.heightFrameLayout + 20) * line); + imageFram.X = Application.GetRealWidth((ImageFramlayout.widthFrameLayout + 8) * xCount); + imageFram.btnName.Text = keypad.name; + + xCount++; + if (i % this.mRowNumber == 0) + { + + line++; + xCount = 0; + } + imageFram.SetClickListener((fl) => + { + if (imageFram.Tag != null) + { + selectAction?.Invoke((KeypadEntity)imageFram.Tag); + } + }); + + //if (CurrnetSelectIndex != -1 && CurrnetSelectIndex == i) + //{ + // selectAction?.Invoke((int)imageFram.Tag); + //} + + + } + } + /// <summary> + /// 璁剧疆鍒濆閫夋嫨(璇峰湪鍒濆鍖栧畬鎴愪箣鍓嶈皟鐢�) + /// </summary> + /// <param name="index">浠庡垪琛�0寮�濮嬭绠楃涓�涓厓绱�,璁剧疆瓒呰繃鍒楄〃鏈�澶�(new List().count-1)鍊艰涓烘棤鏁�</param> + public void SetIndex(int index = -1) + { + if (index == -1) { return; } + this.CurrnetSelectIndex = index; + + } + /// <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; - int number = this.mList.Count % this.mRowNumber; + if (this.mRowNumber == 0 || mListCount == 0) + { + return false; + } + int lineCount = mListCount / this.mRowNumber;//寰楀嚭琛屾暟 + int number = mListCount % 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> /// 鏈�鍚庡彸杈归偅涓�涓� @@ -153,11 +400,56 @@ /// <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; + } + + + + } } -- Gitblit v1.8.0