using System; using System.Collections.Generic; using Shared.Common; namespace Shared.Phone.Device.Category { public class CategorySceneSelectDevice:FrameLayout { public CategorySceneSelectDevice() { BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor; Tag = "categoryAddScene"; } public override void RemoveFromParent() { base.RemoveFromParent(); } public void Show(List sceneTargetDevicesList, bool isFromRoom = false) { #region topview var topBGView = new FrameLayout() { Height = Application.GetRealHeight(CommonPage.Navigation_Height), BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor }; AddChidren(topBGView); var topView = new FrameLayout() { Y = Application.GetRealHeight(CommonPage.NavigationTitle_Y), Height = Application.GetRealHeight(CommonPage.Navigation_Height - CommonPage.NavigationTitle_Y), BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor, }; AddChidren(topView); var title = new Button() { TextAlignment = TextAlignment.Center, TextID=R.MyInternationalizationString.SelectDevice, TextSize = 20, TextColor = ZigbeeColor.Current.GXCTextBlackColor, Width = Application.GetRealWidth(CommonPage.AppRealWidth - 500), Gravity = Gravity.CenterHorizontal }; topView.AddChidren(title); var back = new Device.CommonForm.BackButton() { }; topView.AddChidren(back); back.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); }; #endregion #region 获取设备 //设备类型去重分类 var dList = new List(); var devices = new List { }; devices = LocalDevice.Current.listAllDevice; foreach (var device in devices) { if (device.Type == ZigBee.Device.DeviceType.AirSwitch || device.Type == ZigBee.Device.DeviceType.OnOffOutput || device.Type == ZigBee.Device.DeviceType.DimmableLight || device.Type == ZigBee.Device.DeviceType.WindowCoveringDevice) { if (dList.Contains(device.Type)) { continue; } dList.Add(device.Type); } } #endregion #region midFL var midFL = new VerticalScrolViewLayout() { Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.Navigation_Height), Y = topView.Bottom, BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor }; this.AddChidren(midFL); var r = new R.MyInternationalizationString(); foreach (var deviceType in dList) { var deviceItemFL = new FrameLayout() { Height = Application.GetRealHeight(170) }; midFL.AddChidren(deviceItemFL); var deviceIMG = new Button() { X = Application.GetRealWidth(50), Width = Application.GetMinRealAverage(110), Height = Application.GetMinRealAverage(110), UnSelectedImagePath = DeviceUI.GetDeviceTypeUnSelectedImagePath(deviceType), SelectedImagePath = DeviceUI.GetDeviceTypeSelectedImagePath(deviceType), Gravity = Gravity.CenterVertical }; deviceItemFL.AddChidren(deviceIMG); var deviceName = new Button() { X = deviceIMG.Right + Application.GetRealWidth(50), Width = Application.GetRealWidth(700), Height = Application.GetRealHeight(110), TextColor = ZigbeeColor.Current.GXCTextBlackColor, SelectedTextColor = ZigbeeColor.Current.GXCButtonBlueColor, TextAlignment = TextAlignment.CenterLeft, TextSize = 16, Text = DeviceUI.GetDeviceTypeName(deviceType) , Gravity = Gravity.CenterVertical }; deviceItemFL.AddChidren(deviceName); var deviceRight = new Device.CommonForm.SelectedStatuButton() { X = Application.GetRealWidth(CommonPage.AppRealWidth - 150), Width = Application.GetMinRealAverage(110), Height = Application.GetMinRealAverage(110), UnSelectedImagePath = "Item/Next.png", SelectedImagePath="Item/NextSelected.png", Gravity = Gravity.CenterVertical }; deviceItemFL.AddChidren(deviceRight); var line = new Button() { Y = Application.GetRealHeight(170) - 1, Height = 1, BackgroundColor = ZigbeeColor.Current.GXCLineColor, Tag = deviceType }; deviceItemFL.AddChidren(line); //设备详细类列表 EventHandler deviceHandler = (sender, e) => { var sameByRoom = new CategorySceneSelectDeviceByRoom(); UserView.HomePage.Instance.AddChidren(sameByRoom); UserView.HomePage.Instance.PageIndex += 1; sameByRoom.Show(sceneTargetDevicesList,deviceType,isFromRoom); }; deviceRight.MouseUpEventHandler += deviceHandler; deviceIMG.MouseUpEventHandler += deviceHandler; deviceName.MouseUpEventHandler += deviceHandler; } #endregion } } }