using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.UserCenter { /// /// 做成一个场景选择的行控件 /// public class SceneSelectRow : StatuRowLayout { /// /// 场景(由初始化函数的参数指定,有可能为空) /// public Common.SceneRoomUI sceneRoomUI = null; /// /// 场景 /// public Common.SceneUI sceneUI = null; /// /// 图片控件 /// private PicViewControl btnImage = null; /// /// 场景名字控件 /// private ViewNormalControl btnSceneName = null; /// /// 房间控件 /// private ViewNormalControl btnRoom = null; /// /// 选择控件 /// private MostRightEmptyView btnSelect = null; /// /// 模糊背景 /// private ViewNormalControl btnBack = null; /// /// 状态 /// private StatuMode Statu = StatuMode.UN_SELECT; /// /// 是否处于选择状态 /// public bool IsSelected { get { return Statu == StatuMode.SELECT; } set { if (value == false) { this.SetUnselectStatu(); } else { this.SetSelectStatu(); } } } /// /// 行之间的间隔 /// private int rowSpcace = 5; /// /// 做成一个场景选择的行控件 /// /// 列表控件,可以为空 /// 场景 public SceneSelectRow(VerticalScrolViewLayout listView, Common.SceneRoomUI i_SceneRoomUI) { this.sceneRoomUI = i_SceneRoomUI; this.sceneUI = this.sceneRoomUI.sceneUI; this.Height = Application.GetRealHeight(365 + rowSpcace * 2); this.MouseUpEvent += (sender, e) => { this.IsSelected = Statu == StatuMode.SELECT ? false : true; }; if (listView != null) { listView.AddChidren(this); //初始化内部控件 this.InitControl(); } } /// /// 做成一个场景选择的行控件 /// /// 列表控件,可以为空 /// 场景 public SceneSelectRow(VerticalScrolViewLayout listView, Common.SceneUI i_SceneUI) { this.sceneUI = i_SceneUI; this.Height = Application.GetRealHeight(365 + rowSpcace * 2); this.MouseUpEvent += (sender, e) => { this.IsSelected = Statu == StatuMode.SELECT ? false : true; }; if (listView != null) { listView.AddChidren(this); //初始化内部控件 this.InitControl(); } } /// /// 初始化内部控件 /// public void InitControl() { this.LineColor = UserCenterColor.Current.Transparent; //选择 btnSelect = new MostRightEmptyView(); btnSelect.Visible = false; btnSelect.UnSelectedImagePath = "Item/TickSelected.png"; this.AddChidren(btnSelect, ChidrenBindMode.BindEventOnly); //图片 btnImage = new PicViewControl(Application.CurrentWidth - ControlCommonResourse.XXLeft * 2, this.Height - Application.GetRealHeight(rowSpcace * 2), false); btnImage.X = ControlCommonResourse.XXLeft; btnImage.UnSelectedImagePath = this.sceneUI.IconPath; btnImage.Radius = Common.CommonPage.BigFormRadius; btnImage.Gravity = Gravity.CenterVertical; this.AddChidren(btnImage, ChidrenBindMode.NotBind); //模糊背景 this.btnBack = new ViewNormalControl(btnImage.Width, this.Height - Application.GetRealHeight(rowSpcace * 2)); btnBack.Radius = Common.CommonPage.BigFormRadius; btnBack.X = ControlCommonResourse.XXLeft; btnBack.Gravity = Gravity.CenterVertical; btnBack.BackgroundColor = Common.ZigbeeColor.Current.GXCBlack70Color; this.AddChidren(btnBack, ChidrenBindMode.BindEventOnly); //房间 btnRoom = new ViewNormalControl(600, true); btnRoom.X = Application.GetRealWidth(30) + ControlCommonResourse.XXLeft; btnRoom.TextSize = 10; btnRoom.TextColor = UserCenterColor.Current.White; this.AddChidren(btnRoom, ChidrenBindMode.BindEventOnly); if (this.sceneRoomUI != null) { btnRoom.Text = this.sceneRoomUI.room.Name; } //场景名 btnSceneName = new ViewNormalControl(btnImage.Width, false); btnSceneName.TextAlignment = TextAlignment.Center; btnSceneName.Text = sceneUI.Name; btnSceneName.TextSize = 20; btnSceneName.TextColor = UserCenterColor.Current.White; btnSceneName.Gravity = Gravity.CenterVertical; this.AddChidren(btnSceneName, ChidrenBindMode.BindEventOnly); } /// /// 设定选择状态 /// public void SetSelectStatu() { if (Statu == StatuMode.SELECT) { return; } btnSelect.Visible = true; btnSceneName.X = btnSceneName.X - Application.GetRealWidth(130); btnRoom.X = btnRoom.X - Application.GetRealWidth(130); btnBack.X = btnBack.X - Application.GetRealWidth(130); btnImage.X = btnImage.X - Application.GetRealWidth(130); //状态变更 Statu = StatuMode.SELECT; } /// /// 设置非选择状态 /// public void SetUnselectStatu() { if (Statu == StatuMode.UN_SELECT) { return; } btnSelect.Visible = false; btnSceneName.X = btnSceneName.X + Application.GetRealWidth(130); btnRoom.X = btnRoom.X + Application.GetRealWidth(130); btnBack.X = btnBack.X + Application.GetRealWidth(130); btnImage.X = btnImage.X + Application.GetRealWidth(130); //状态变更 Statu = StatuMode.UN_SELECT; } } }