using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.UserCenter { /// /// 做成一个房间选择的行控件 /// public class RoomSelectRow : StatuRowLayout { /// /// 是否处于选择状态 /// public bool IsSelected { get { return Statu == StatuMode.SELECT; } set { if (value == true) { this.SetSelectStatu(); } else { if (SelectCancel == true) { this.SetUnselectStatu(); } } } } /// /// 房间名 /// public string RoomName = string.Empty; /// /// 选择的状态是否能够取消 /// public bool SelectCancel = true; /// /// 点图标控件 /// private RowLeftIconView btnPoint = null; /// /// 房间控件 /// private RowCenterView btnRoom = null; /// /// 选择控件 /// private MostRightEmptyView btnSelect = null; /// /// 状态 /// private StatuMode Statu = StatuMode.UN_SELECT; /// /// 做成一个房间选择的行控件 /// /// 列表控件,可以为空 /// 房间对象 public RoomSelectRow(VerticalScrolViewLayout listView, Common.Room room) { this.RoomName = room.Name; this.MouseUpEvent += (sender, e) => { this.IsSelected = Statu == StatuMode.SELECT ? false : true; }; if (listView != null) { listView.AddChidren(this); //初始化内部控件 this.InitControl(); } } /// /// 初始化内部控件 /// public void InitControl() { //图标 btnPoint = new RowLeftIconView(); btnPoint.ChangedControlInPointMode(); this.AddChidren(btnPoint, ChidrenBindMode.BindEventOnly); //房间 btnRoom = new RowCenterView(); btnRoom.Text = this.RoomName; this.AddChidren(btnRoom, ChidrenBindMode.BindEventOnly); //点号图片有点特殊,需要调整偏移量 btnRoom.X -= ControlCommonResourse.PointXXLeft; //选择 btnSelect = new MostRightEmptyView(); btnSelect.Visible = false; btnSelect.UnSelectedImagePath = "Item/TickSelected.png"; this.AddChidren(btnSelect, ChidrenBindMode.BindEventOnly); } /// /// 设定选择状态 /// private void SetSelectStatu() { if (Statu == StatuMode.SELECT) { return; } btnPoint.IsSelected = true; btnRoom.TextColor = UserCenterColor.Current.SelectTextColor; btnSelect.Visible = true; //状态变更 Statu = StatuMode.SELECT; } /// /// 设置非选择状态 /// private void SetUnselectStatu() { if (Statu == StatuMode.UN_SELECT) { return; } btnPoint.IsSelected = false; btnRoom.TextColor = UserCenterColor.Current.TextColor; btnSelect.Visible = false; //状态变更 Statu = StatuMode.UN_SELECT; } } }