using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.UserCenter { /// /// 做成一个简单场景选择的行控件 /// public class SceneSimpleSelectControl : FrameRowControl { #region ■ 变量声明___________________________ /// /// 场景ID /// private int SceneId = 0; /// /// 场景对象 /// public Common.SceneUI Scene { get { return Common.Room.CurrentRoom.GetSceneUIBySceneId(SceneId); } } /// /// 选择控件 /// private MostRightIconControl btnSelect = null; /// /// 选择的状态是否能够取消 /// public bool SelectCancel = true; /// /// 状态 /// private StatuMode Statu = StatuMode.UN_SELECT; /// /// 是否处于选择状态 /// public bool IsSelected { get { return Statu == StatuMode.SELECT; } set { if (value == false) { if (SelectCancel == true) { this.SetUnselectStatu(); } } else { this.SetSelectStatu(); } } } #endregion #region ■ 初始化_____________________________ /// /// 做成一个简单场景选择的行控件 /// /// 场景对象 /// 子控件Y轴偏移量(真实值,有些界面需要这种特殊操作) public SceneSimpleSelectControl(Common.SceneUI i_Scene, int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis) { this.SceneId = i_Scene.Id; this.ButtonClickEvent += (sender, e) => { this.IsSelected = Statu == StatuMode.SELECT ? false : true; }; } /// /// 初始化内部控件 /// public void InitControl() { var SceneTemp = this.Scene; //图标 var btnIcon = this.AddLeftIcon(); btnIcon.UnSelectedImagePath = "Item/Scene.png"; //场景 var btnScene = this.AddLeftCaption(SceneTemp.Name, 850, 60); btnScene.TextSize = 15; //这个坐标有点特殊 btnScene.Y = Application.GetRealHeight(12) + this.chidrenYaxis; this.AddChidren(btnScene, ChidrenBindMode.BindEventOnly); //房间 string roomName = Common.Room.CurrentRoom.GetRoomNameBySceneId(SceneId); var btnRoom = this.AddLeftCaption(roomName, 850, 50, true); //这个坐标有点特殊 btnRoom.Y = Application.GetRealHeight(72) + this.chidrenYaxis; btnRoom.TextSize = 12; btnRoom.TextColor = UserCenterColor.Current.TextGrayColor1; this.AddChidren(btnRoom, ChidrenBindMode.BindEventOnly); 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; //状态变更 Statu = StatuMode.SELECT; } /// /// 设置非选择状态 /// private void SetUnselectStatu() { if (Statu == StatuMode.UN_SELECT) { return; } btnSelect.Visible = false; //状态变更 Statu = StatuMode.UN_SELECT; } #endregion } }