using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.UserCenter { /// /// 做成一个简单的选择控件 /// public class NormalSelectControl : FrameRowControl { #region ■ 变量声明___________________________ /// /// 显示文本 /// private string textValue = string.Empty; /// /// 文本控件 /// private NormalViewControl btnText = null; /// /// 选择控件 /// private MostRightIconControl btnSelect = null; /// /// 状态 /// private StatuMode Statu = StatuMode.UN_SELECT; /// /// 是否处于选择状态 /// public bool IsSelected { get { return Statu == StatuMode.SELECT; } set { if (value == false) { this.SetUnselectStatu(); } else { this.SetSelectStatu(); } } } /// /// 处于非选中状态时,是否把字体变成灰色(默认变成灰色) /// public bool ChangedTextColor = true; #endregion #region ■ 初始化_____________________________ /// /// 做成一个简单的选择控件 /// /// 显示文本 /// 子控件Y轴偏移量(【列表控件的rowSpace/2】即可,不懂默认为0即可) public NormalSelectControl(string i_text, int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis) { this.textValue = i_text; } /// /// 初始化内部控件 /// /// 左侧图标 public void InitControl(string iconParh = "") { //图片 if (iconParh != "") { var btnIcon = this.AddLeftIcon(); btnIcon.UnSelectedImagePath = iconParh; } //显示文本 btnText = this.AddLeftCaption(this.textValue, 600); btnText.TextColor = UserCenterColor.Current.TextGrayColor3; //选择控件 btnSelect = this.AddMostRightEmptyIcon(58, 58); btnSelect.Visible = false; btnSelect.UnSelectedImagePath = "Item/ItemSelected.png"; } #endregion #region ■ 选择状态___________________________ /// /// 设定选择状态 /// private void SetSelectStatu() { if (Statu == StatuMode.SELECT) { return; } btnSelect.Visible = true; if (this.ChangedTextColor == true) { btnText.TextColor = UserCenterColor.Current.TextColor1; } //状态变更 Statu = StatuMode.SELECT; } /// /// 设置非选择状态 /// private void SetUnselectStatu() { if (Statu == StatuMode.UN_SELECT) { return; } btnSelect.Visible = false; if (this.ChangedTextColor == true) { btnText.TextColor = UserCenterColor.Current.TextGrayColor3; } //状态变更 Statu = StatuMode.UN_SELECT; } #endregion } }