using System; using System.Collections.Generic; using System.Threading.Tasks; using ZigBee.Device; namespace Shared.Phone.UserCenter.Device { /// /// 配置设备列表的画面 /// public class ConfigureDeviceListForm : UserCenterCommonForm { /// /// 列表控件 /// private VerticalScrolViewLayout listview = null; /// /// 新上报的设备(注意:这个东西是个地址引用) /// private List listNewDevice = null; /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// /// 设备列表 public void ShowForm(List listdevices) { this.listNewDevice = listdevices; //设置标题信息 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uConfigureDevice)); //初始化中部控件 this.InitMiddleFrame(); //添加所有的行 this.AddAllRowLayout(); } /// /// 初始化中部控件 /// private void InitMiddleFrame() { //输出回路列表 var btnText = new TitleViewControl(); btnText.Y = Application.GetRealHeight(40); btnText.TextColor = UserCenterColor.Current.TextGrayColor; btnText.TextID = R.MyInternationalizationString.uOutputCircuitList; bodyFrameLayout.AddChidren(btnText); listview = new VerticalScrolViewLayout(); listview.Y = btnText.Bottom; listview.Height = bodyFrameLayout.Height - btnText.Bottom; bodyFrameLayout.AddChidren(listview); } /// /// 添加所有的行 /// private void AddAllRowLayout() { foreach (CommonDevice device in this.listNewDevice) { this.AddRowLayout(device); } } /// /// 添加行 /// /// Device. private void AddRowLayout(CommonDevice device) { //设备控件 var deviceRow = new DeviceRoomViewRow(listview, device); //向右图标 deviceRow.AddRightIconControl(); //检测设备是否拥有测试的功能 if (Common.LocalDevice.Current.DeviceIsCanTest(device) == true) { //测试 var btnTest = new RowSecondRightIconView(); btnTest.UnSelectedImagePath = "Item/Test.png"; btnTest.SelectedImagePath = "Item/TestSelected.png"; deviceRow.AddChidren(btnTest, ChidrenBindMode.NotBind); btnTest.MouseUpEventHandler += (sender, e) => { //测试 Common.LocalDevice.Current.SetTestCommand(device); }; } deviceRow.MouseUpEvent += (sender, e) => { var form = new DeviceEpointInfoForm(); this.AddForm(form, device); form.ActionNameChangedEvent += (deviceName, listName) => { //变更房间 Common.Room.CurrentRoom.ChangedRoom(device, listName); //刷新全部信息信息 deviceRow.listRoom = listName; deviceRow.RefreshControlInfo(device); }; }; } /// /// 画面关闭 /// /// 是否关闭界面,false的时候,只会调用关闭函数里面的附加功能 public override void CloseForm(bool isCloseForm = true) { //画面关闭时,不管之后怎么处理,先添加到主界面的列表及缓存中 this.LoadFormMethodByName("DeviceManagementMainForm", "AddDeviceToFormTable", listNewDevice); base.CloseForm(isCloseForm); } } }