using Shared; using HDL_ON.UI.CSS; using System; using System.Collections.Generic; using System.Text; namespace HDL_ON.Stan { /// <summary> /// æœ‰æ ‡é¢˜çš„å¼¹çª—åž‹èœå•选择控件(Yè½´æœ€å¥½å‡æŽ‰12) /// </summary> public class DialogTitleMenuControl : NormalFrameLayout { #region â– å˜é‡å£°æ˜Ž___________________________ /// <summary> /// 列表控件 /// </summary> private VerticalListControl listView = null; /// <summary> /// 列表控件是å¦èƒ½æ»šåЍ /// </summary> private bool listViewScroll = false; /// <summary> /// æ ‡é¢˜(åˆå§‹åŒ–之åŽä¼šç½®ç©º) /// </summary> private string StrTitle = null; /// <summary> /// 行高度 /// </summary> private int RowHeight = HdlControlResourse.ListViewRowHeight; /// <summary> /// 行数 /// </summary> private int RowCount = 0; #endregion #region â– åˆå§‹åŒ–_____________________________ /// <summary> /// æœ‰æ ‡é¢˜çš„å¼¹çª—åž‹èœå•选择控件(Yè½´æœ€å¥½å‡æŽ‰12) /// </summary> /// <param name="i_RowCount">èœå•行数(ä¸å«æ ‡é¢˜)</param> /// <param name="i_title">æ ‡é¢˜</param> public DialogTitleMenuControl(int i_RowCount, string i_title) { //最大显示5个zzy //4个。。没有5个的背景图wxr this.RowCount = i_RowCount > 4 ? 4 : i_RowCount; this.listViewScroll = i_RowCount > 4; this.StrTitle = i_title; this.Height = Application.GetRealHeight(64 + 45 * this.RowCount); } /// <summary> /// åˆå§‹åŒ–控件 /// </summary> private void InitControl() { //å·²ç»åˆå§‹åŒ–过,ä¸éœ€è¦å†æ¬¡åˆå§‹åŒ– if (this.StrTitle == null) { return; } this.BackgroundImagePath = "FunctionIcon/Electrical/Fan/DialogTitleMenuGroud" + this.RowCount + ".png"; //æ ‡é¢˜è¡Œ var rowTitle = new FrameRowControl(); rowTitle.LeftOffset = Application.GetRealWidth(24) - HdlControlResourse.XXLeft; rowTitle.Y = Application.GetRealHeight(8); rowTitle.Width = this.Width; rowTitle.Height = this.RowHeight; this.AddChidren(rowTitle); //æ ‡é¢˜ var btnTitle = rowTitle.AddLeftCaption(this.StrTitle, 100); //从X轴开始,铺满整一行 btnTitle.Width = rowTitle.Width - btnTitle.X; btnTitle.TextColor = CSS_Color.FirstLevelTitleColor; btnTitle.TextSize = CSS_FontSize.SubheadingFontSize; //线 var btnLine = rowTitle.AddBottomLine(); btnLine.Width = rowTitle.Width - Application.GetRealWidth(24) * 2; btnLine.Gravity = Gravity.CenterHorizontal; btnLine.BackgroundColor = CSS_Color.BackgroundColor; this.StrTitle = null; //列表控件 this.listView = new VerticalListControl(); listView.Y = rowTitle.Bottom; listView.Height = this.RowCount * this.RowHeight; listView.ScrollEnabled = this.listViewScroll; this.AddChidren(listView); } #endregion #region â– æ·»åŠ èœå•___________________________ /// <summary> /// æ·»åŠ èœå•行(å®ƒæœ€ç»ˆçš„çˆ¶æŽ§ä»¶éœ€è¦æ‰‹åЍ关é—) /// </summary> /// <param name="i_textValue">显示的文å—</param> /// <param name="i_iconPath">图片(</param> /// <param name="i_select">æ˜¯å¦æ˜¯é€‰æ‹©çжæ€</param> /// <param name="clickEvent">å•击èœå•执行的事件</param> public void AddRowMenu(string i_textValue, string i_iconPath, bool i_select, Action clickEvent) { //å…ˆåˆå§‹åŒ–控件 this.InitControl(); uint fontColor = i_select == true ? CSS_Color.MainColor : CSS_Color.FirstLevelTitleColor; //生æˆè¡ŒæŽ§ä»¶ var frameRow = this.CreatRowControl(i_iconPath, i_textValue, fontColor); frameRow.ButtonClickEvent += (sender, e) => { //调用回调函数 clickEvent?.Invoke(); clickEvent = null; }; } /// <summary> /// 生æˆè¡ŒæŽ§ä»¶ /// </summary> /// <param name="i_iconPath">å›¾æ ‡</param> /// <param name="i_text">显示的文å—</param> /// <param name="i_fontColor">å—体颜色</param> /// <returns></returns> private FrameRowControl CreatRowControl(string i_iconPath, string i_text, uint i_fontColor) { //它的上一行 var rowBefor = this.listView.GetChildren(this.listView.ChildrenCount - 1) as FrameRowControl; if (rowBefor != null) { //画底线 var btnLine = rowBefor.AddBottomLine(); btnLine.Width = rowBefor.Width - Application.GetRealWidth(24) * 2; btnLine.Gravity = Gravity.CenterHorizontal; btnLine.BackgroundColor = CSS_Color.BackgroundColor; } //行 var rowContr = new FrameRowControl(); rowContr.LeftOffset = Application.GetRealWidth(24) - HdlControlResourse.XXLeft; rowContr.Width = this.Width; rowContr.Height = this.RowHeight; this.listView.AddChidren(rowContr); //å›¾æ ‡ rowContr.AddLeftIcon(24, i_iconPath); //显示文本 var btnView = rowContr.AddLeftCaption(i_text, 92); //从X轴开始,铺满整一行 btnView.Width = rowContr.Width - btnView.X; btnView.TextColor = i_fontColor; return rowContr; } #endregion } }