using System; using System.Collections.Generic; using Shared.SimpleControl.Phone.Music; namespace Shared.SimpleControl.Phone { public static class UserDeviceView { public static int LightingCount = 0; public static int CurtainCount = 0; public static int SwitchSocketBrightingCount = 0; public static List allLocationFiles = IO.FileUtils.ReadFiles (false); public static void DeviceMode () { allLocationFiles = IO.FileUtils.ReadFiles (); FrameLayout topView = new FrameLayout () { Y = Application.GetRealHeight (36), Height = Application.GetRealHeight (90), Width = Application.GetRealWidth (640), BackgroundColor = SkinStyle.Current.MainColor, }; UserMiddle.DeviceBodyView.AddChidren (topView); Button LogoButton = new Button () { Width = Application.GetRealWidth (154), Height = Application.GetRealHeight (90), UnSelectedImagePath = MainPage.LogoString, }; topView.AddChidren (LogoButton); LogoButton.MouseUpEventHandler += (sender, s) => { }; Button NameButton = new Button () { Width = Application.GetRealWidth (400), Height = Application.GetMinReal (90), TextID = R.MyInternationalizationString.Category, TextColor = SkinStyle.Current.TextColor1, Gravity = Gravity.CenterHorizontal, TextAlignment = TextAlignment.Center, TextSize = 20, //FontName = "TitilliumText25L" }; topView.AddChidren (NameButton); UserMiddle.DeviceView.RemoveAll (); Button btnRowLine = new Button () { Height = Application.GetRealHeight (5), BackgroundColor = SkinStyle.Current.UserMenuItemButton }; UserMiddle.DeviceView.AddChidren (btnRowLine); FrameLayout rowLayout = null; int index = 0; //for (int i = 0; i < UserConfig.Instance.DeviceTypes.Count - UserConfig.Instance.HideDeviceTypes.Count-1; i++) { foreach(var deviceType in UserConfig.Instance.DeviceTypes) { if (UserConfig.Instance.HideDeviceTypes.Contains (deviceType)) { continue; } var hostSavePaths = allLocationFiles.FindAll ((obj) => obj.Split ('_').Length == 4 && obj.Split ('_') [0] == "Equipment" && obj.Split ('_') [1] == DeviceType.Thermostat.ToString ()); if (deviceType == (int)DeviceType.Thermostat && hostSavePaths.Count < 1) { continue; } if (index % 2 == 0) { rowLayout = new FrameLayout () { Height = Application.GetRealWidth (232), Width = Application.GetRealWidth (640), BackgroundColor = SkinStyle.Current.UserMenuItemButton }; UserMiddle.DeviceView.AddChidren (rowLayout); } FrameLayout equipmentLayout = new FrameLayout () { Width = Application.GetRealWidth (318), Height = Application.GetRealWidth (227), }; equipmentLayout.AddTag ("DeviceType", deviceType); rowLayout.AddChidren (equipmentLayout); if (index % 2 == 1) { equipmentLayout.Width = Application.GetRealWidth (318); equipmentLayout.X = Application.GetRealWidth (323); } Button btnEquipmentIcon = new Button () { Width = Application.GetMinRealAverage (128), Height = Application.GetMinRealAverage (136), Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight (20), }; equipmentLayout.AddChidren (btnEquipmentIcon); Button btnEquipmentName = new Button () { Width = Application.GetRealWidth (232), Height = Application.GetRealHeight (45), Gravity = Gravity.CenterHorizontal, Y = btnEquipmentIcon.Bottom, Text = Language.StringByID(deviceType), Enable = false, TextColor = SkinStyle.Current.TextColor1 }; equipmentLayout.AddChidren (btnEquipmentName); Button btnOpenNumber = new Button () { Width = Application.GetRealWidth (55), Height = Application.GetRealHeight (35), X = Application.GetRealWidth (248), Y = Application.GetRealHeight (30), UnSelectedImagePath = "Item/LightingCount.png", SelectedImagePath = "Item/LightingCountSelected.png", Enable = false, Text = "0", TextAlignment = TextAlignment.Center, TextColor = SkinStyle.Current.TextColor1 }; btnOpenNumber.AddTag ("DeviceType", deviceType); equipmentLayout.AddChidren (btnOpenNumber); setEquipmentsBackGroud (Language.StringByID (deviceType), btnEquipmentIcon, equipmentLayout, btnOpenNumber, equipmentLayout); ++index; } System.Threading.Tasks.Task.Run (() => { UserDeviceToCurtains.readAllStatus (); UserDeviceToLight.readAllStatus (); UserDeviceToSocket.readAllStatus (); UserDeviceToAC.readAllStatus (); UserDeviceToFH.readAllStatus (); UserFresAirList.readAllStatus (); }); } public static void UpdataDeviceCountNumber (int count, int tagFalg) { try { Application.RunOnMainThread (() => { for (int i = 0; i < UserMiddle.DeviceView.ChildrenCount; i++) { if (UserMiddle.DeviceView.GetChildren (i).GetType () == typeof (FrameLayout)) { FrameLayout rowView = (FrameLayout)UserMiddle.DeviceView.GetChildren (i); for (int j = 0; j < rowView.ChildrenCount; j++) { if (rowView.GetChildren (j).GetType () == typeof (FrameLayout)) { FrameLayout frameView = (FrameLayout)rowView.GetChildren (j); if (frameView.GetTagByKey ("DeviceType").ToString () == tagFalg.ToString()) { for (int k = 0; k < frameView.ChildrenCount; k++) { if (frameView.GetChildren (k).GetType () == typeof (Button)) { Button btn = (Button)frameView.GetChildren (k); if (btn.GetTagByKey ("DeviceType") != null && btn.GetTagByKey ("DeviceType").ToString () == tagFalg.ToString()) { if (count > 0) { btn.Text = count.ToString (); btn.IsSelected = true; switch (tagFalg) { case 43: CurtainCount = count; break; case 3: LightingCount = count; break; case 265: SwitchSocketBrightingCount = count; break; } } else if ( count == 0) { //Application.RunOnMainThread (() => { try { int eCount = 0; foreach (var room in Room.Lists) { if (string.IsNullOrEmpty (room.Name)) { continue; } if (tagFalg == R.MyInternationalizationString.Lights) { var devices = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.LightDimming || obj.Type == DeviceType.LightSwitch || obj.Type == DeviceType.LightRGB || obj.Type == DeviceType.LightMixSwitch || obj.Type == DeviceType.LightMixDimming || obj.Type == DeviceType.LightDALI; }); eCount += devices.Count; } else if (tagFalg == R.MyInternationalizationString.ElectricalControl) { var devices = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.LightSwitchSocket || obj.Type == DeviceType.LightEnergySwitch; }); eCount += devices.Count; } else if (tagFalg == R.MyInternationalizationString.AC) { var devices = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.HVAC || obj.Type == DeviceType.ACInfrared || obj.Type == DeviceType.ACPanel; }); eCount += devices.Count; } else if (tagFalg == R.MyInternationalizationString.ElectricalControl) { var devices = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.LightSwitchSocket; }); eCount += devices.Count; } else if (tagFalg == R.MyInternationalizationString.Fan) { var devices = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.FanModule; }); eCount += devices.Count; } else if (tagFalg == R.MyInternationalizationString.FreshAir) { var devices = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.FreshAir; }); eCount += devices.Count; } else if (tagFalg == R.MyInternationalizationString.Curtain) { var devices = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.CurtainModel || obj.Type == DeviceType.CurtainRoller || obj.Type == DeviceType.CurtainTrietex; }); eCount += devices.Count; } } btn.Text = eCount.ToString (); btn.IsSelected = false; } catch { } } } } } } } } } } }); } catch { } } static void DelUserEquipmentView (int deviceCount, int deviceType) { if (deviceCount == 0) { Alert alert = new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.DeleteDeviceCategories), Language.StringByID (R.MyInternationalizationString.Cancel), Language.StringByID (R.MyInternationalizationString.Confrim)); alert.Show (); alert.ResultEventHandler += (sender2, e2) => { if (e2) { UserConfig.Instance.HideDeviceTypes.Add (deviceType); UserConfig.Instance.SaveUserConfig (); DeviceMode (); } }; } } /// /// 设备到房间模式显示用户主界面的 /// static void setEquipmentsBackGroud (string equipmentType, Button btnEquipment, FrameLayout fl, Button btnOpenNumber, FrameLayout equipmentLayout) { if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.Lights)) { btnEquipment.UnSelectedImagePath = "Item/Light.png"; btnEquipment.SelectedImagePath = "Item/LightSelected.png"; int eCount = 0; int brighingCount = 0; System.Threading.Tasks.Task.Run (() => { foreach (var room in Room.Lists) { if (string.IsNullOrEmpty (room.Name)) { continue; } var devices = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.LightDimming || obj.Type == DeviceType.LightSwitch || obj.Type == DeviceType.LightRGB || obj.Type == DeviceType.LightMixSwitch || obj.Type == DeviceType.LightMixDimming || obj.Type == DeviceType.LightDALI; }); eCount += devices.Count; foreach (var updataCommon in room.DeviceList) { if (updataCommon.Type == DeviceType.LightDimming || updataCommon.Type == DeviceType.LightMixDimming || updataCommon.Type == DeviceType.LightDALI) { if ((updataCommon as LightDimming).CurrentBrightness > 0) brighingCount++; } else if (updataCommon.Type == DeviceType.LightSwitch || updataCommon.Type == DeviceType.LightMixSwitch) { if ((updataCommon as LightSwitch).CurrentBrightness == 100) { brighingCount++; } } else if (updataCommon.Type == DeviceType.LightRGB) { if ((updataCommon as LightLogic).CurrentBrightness > 0) { brighingCount++; } } } } Application.RunOnMainThread (() => { if (brighingCount > 0) { eCount = brighingCount; btnOpenNumber.IsSelected = true; } btnOpenNumber.Text = eCount.ToString (); }); }); btnEquipment.MouseUpEventHandler += (sender, e) => { var lightView = new UserDeviceToLight (); UserMiddle.DevicePageView.AddChidren (lightView); lightView.showAllRoomLights (); UserMiddle.DevicePageView.PageIndex = 1; UserMiddle.DevicePageView.ScrollEnabled = false; }; fl.MouseUpEventHandler += (sender, e) => { var lightView = new UserDeviceToLight (); UserMiddle.DevicePageView.AddChidren (lightView); lightView.showAllRoomLights (); UserMiddle.DevicePageView.PageIndex = 1; UserMiddle.DevicePageView.ScrollEnabled = false; }; btnEquipment.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.Lights); }; fl.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.Lights); }; equipmentLayout.BackgroundImagePath = "Item/LightBackground.png"; } else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.AC)) { btnEquipment.UnSelectedImagePath = "AC/AC.png"; btnEquipment.SelectedImagePath = "AC/ACSelected.png"; int eCount = 0; int acOponeCount = 0; System.Threading.Tasks.Task.Run (() => { foreach (var room in Room.Lists) { if (string.IsNullOrEmpty (room.Name)) { continue; } var devices = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.HVAC || obj.Type == DeviceType.ACInfrared || obj.Type == DeviceType.ACPanel; }); eCount += devices.Count; foreach (var acTemp in room.DeviceList) { if (acTemp.Type == DeviceType.HVAC || acTemp.Type == DeviceType.ACInfrared || acTemp.Type == DeviceType.ACPanel) if ((acTemp as AC).Power == 1) { acOponeCount++; } } } Application.RunOnMainThread (() => { if (acOponeCount > 0) { eCount = acOponeCount; btnOpenNumber.IsSelected = true; } btnOpenNumber.Text = eCount.ToString (); }); }); btnEquipment.MouseUpEventHandler += (sender, e) => { var acView = new UserDeviceToAC (); UserMiddle.DevicePageView.AddChidren (acView); acView.showAllRoomAC (); UserMiddle.DevicePageView.PageIndex = 1; }; fl.MouseUpEventHandler += (sender, e) => { var acView = new UserDeviceToAC (); UserMiddle.DevicePageView.AddChidren (acView); acView.showAllRoomAC (); UserMiddle.DevicePageView.PageIndex = 1; }; btnEquipment.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.AC); }; fl.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.AC); }; equipmentLayout.BackgroundImagePath = "AC/ACBackground.png"; } else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.TV)) { btnEquipment.UnSelectedImagePath = "Item/TV.png"; btnEquipment.SelectedImagePath = "Item/TVSelected.png"; int eCount = 0; System.Threading.Tasks.Task.Run (() => { foreach (var room in Room.Lists) { if (string.IsNullOrEmpty (room.Name)) { continue; } var devices = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.InfraredMode; }); eCount += devices.Count; } Application.RunOnMainThread (() => { btnOpenNumber.Text = eCount.ToString (); }); }); btnEquipment.MouseUpEventHandler += (sender, e) => { UserDeviceToTV tvView = new UserDeviceToTV (); UserMiddle.DevicePageView.AddChidren (tvView); tvView.ShowAllRoomTV (); UserMiddle.DevicePageView.PageIndex = 1; }; fl.MouseUpEventHandler += (sender, e) => { UserDeviceToTV tvView = new UserDeviceToTV (); UserMiddle.DevicePageView.AddChidren (tvView); tvView.ShowAllRoomTV (); UserMiddle.DevicePageView.PageIndex = 1; }; btnEquipment.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.TV); }; fl.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.TV); }; equipmentLayout.BackgroundImagePath = "Item/TVBackground.png"; } else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.UniversalDevice)) { btnEquipment.UnSelectedImagePath = "UniversalDevice/UniversalDevice.png"; btnEquipment.SelectedImagePath = "UniversalDevice/UniversalDevice.png"; int eCount = 0; System.Threading.Tasks.Task.Run (() => { foreach (var room in Room.Lists) { if (string.IsNullOrEmpty (room.Name)) { continue; } var devices = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.UniversalDevice; }); eCount += devices.Count; } Application.RunOnMainThread (() => { btnOpenNumber.Text = eCount.ToString (); }); }); btnEquipment.MouseUpEventHandler += (sender, e) => { UserDeviceToUniversalDevice tvView = new UserDeviceToUniversalDevice (); UserMiddle.DevicePageView.AddChidren (tvView); tvView.ShowUniversalDevice (); UserMiddle.DevicePageView.PageIndex = 1; }; fl.MouseUpEventHandler += (sender, e) => { UserDeviceToUniversalDevice tvView = new UserDeviceToUniversalDevice (); UserMiddle.DevicePageView.AddChidren (tvView); tvView.ShowUniversalDevice (); UserMiddle.DevicePageView.PageIndex = 1; }; btnEquipment.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.UniversalDevice); }; fl.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.UniversalDevice); }; equipmentLayout.BackgroundImagePath = "UniversalDevice/UniversalDeviceBackground.png"; } else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.Curtain)) { btnEquipment.UnSelectedImagePath = "Curtain/Curtain.png"; //btnEquipment.SelectedImagePath = "Item/CurtainSelected.png"; int eCount = 0; if (CurtainCount > 0) { btnOpenNumber.Text = CurtainCount.ToString (); btnOpenNumber.IsSelected = true; } else { new System.Threading.Thread (() => { foreach (var room in Room.Lists) { if (string.IsNullOrEmpty (room.Name)) { continue; } var devices = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.CurtainModel || obj.Type == DeviceType.CurtainRoller || obj.Type == DeviceType.CurtainTrietex; }); eCount += devices.Count; } Application.RunOnMainThread (() => { btnOpenNumber.Text = eCount.ToString (); }); }) { IsBackground = true }.Start (); } btnEquipment.MouseUpEventHandler += (sender, e) => { var curtainView = new UserDeviceToCurtains (); UserMiddle.DevicePageView.AddChidren (curtainView); curtainView.showAllRoomCurtain (); UserMiddle.DevicePageView.PageIndex = 1; }; fl.MouseUpEventHandler += (sender, e) => { var curtainView = new UserDeviceToCurtains (); UserMiddle.DevicePageView.AddChidren (curtainView); curtainView.showAllRoomCurtain (); UserMiddle.DevicePageView.PageIndex = 1; }; btnEquipment.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.Curtain); }; fl.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.Curtain); }; equipmentLayout.BackgroundImagePath = "Curtain/CurtainBackground.png"; } else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.Scenes)) { btnEquipment.UnSelectedImagePath = "Scene/Scene.png"; int eCount = 0; System.Threading.Tasks.Task.Run (() => { foreach (var room in Room.Lists) { if (string.IsNullOrEmpty (room.Name)) { continue; } if (room != null) { foreach (var sceneFilePath in room.SceneFilePathList) { var scene = Scene.GetSceneByFilePath (sceneFilePath); if (scene != null) eCount += scene.LoopCount; } } } var globalSceneList = Newtonsoft.Json.JsonConvert.DeserializeObject> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (Scene.GlobalSceneFilePath))); if (globalSceneList != null) { foreach (var sceneFilePath in globalSceneList) { var scene = Scene.GetSceneByFilePath (sceneFilePath); if (scene == null) continue; eCount += scene.LoopCount; } } Application.RunOnMainThread (() => { btnOpenNumber.Text = eCount.ToString (); }); }); btnEquipment.MouseUpEventHandler += (sender, e) => { var userDeviceToSceneView = new UserDeviceToScene (); UserMiddle.DevicePageView.AddChidren (userDeviceToSceneView); userDeviceToSceneView.ShowAllScene (); UserMiddle.DevicePageView.PageIndex = 1; }; fl.MouseUpEventHandler += (sender, e) => { var userDeviceToSceneView = new UserDeviceToScene (); UserMiddle.DevicePageView.AddChidren (userDeviceToSceneView); userDeviceToSceneView.ShowAllScene (); UserMiddle.DevicePageView.PageIndex = 1; }; equipmentLayout.BackgroundImagePath = "Item/SceneBackground.png"; btnEquipment.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.Scenes); }; fl.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.Scenes); }; } else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.Music) || equipmentType == Language.StringByID (R.MyInternationalizationString.Sonos)) { btnEquipment.UnSelectedImagePath = "Item/Music.png"; btnEquipment.SelectedImagePath = "Item/MusicSelected.png"; int eCount = 0; int brighingCount = 0; if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.Music)) { System.Threading.Tasks.Task.Run (() => { foreach (var room in Room.Lists) { if (string.IsNullOrEmpty (room.Name)) { continue; } var devices = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.MusicModel; }); eCount += devices.Count; brighingCount += devices.FindAll ((obj) => ((MusicModel)obj).PlayStatus == MusicModel.Status.Play).Count; } var a31List = A31MusicModel.A31MusicModelList.FindAll ((obj) => obj.IsCanShow); eCount += a31List.Count; brighingCount += a31List.FindAll ((obj) => obj.A31PlayStatus.status == "play").Count; Application.RunOnMainThread (() => { if (brighingCount > 0) { eCount = brighingCount; btnOpenNumber.IsSelected = true; } btnOpenNumber.Text = eCount.ToString (); }); }); //if (eCount > 0) { // btnOpenNumber.Text = "1"; //} btnEquipment.MouseUpEventHandler += (sender, e) => { MyMusic myMusic = new MyMusic (); UserMiddle.DevicePageView.AddChidren (myMusic); myMusic.Show (false); UserMiddle.DevicePageView.PageIndex = 1; }; fl.MouseUpEventHandler += (sender, e) => { MyMusic myMusic = new MyMusic (); UserMiddle.DevicePageView.AddChidren (myMusic); myMusic.Show (false); UserMiddle.DevicePageView.PageIndex = 1; }; btnEquipment.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.Music); }; fl.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.Music); }; } equipmentLayout.BackgroundImagePath = "Item/MusicBackground.png"; } else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.Security)) { btnEquipment.UnSelectedImagePath = "Item/Security.png"; btnEquipment.SelectedImagePath = "Item/SecuritySelected.png"; equipmentLayout.BackgroundImagePath = "Item/SecurityBackground.png"; int eCount = 0; System.Threading.Tasks.Task.Run (() => { eCount = allLocationFiles.FindAll ((obj) => obj.Split ('_').Length == 5 && obj.Split ('_') [0] == "Equipment" && obj.Split ('_') [1] == DeviceType.SecurityModule.ToString ()).Count; Application.RunOnMainThread (() => { btnOpenNumber.Text = eCount.ToString (); }); }); btnEquipment.MouseUpEventHandler += (sender, e) => { UserDeviceToSecurity securityView = new UserDeviceToSecurity (); UserMiddle.DevicePageView.AddChidren (securityView); securityView.ShowSecurityView (); UserMiddle.DevicePageView.PageIndex = 1; }; btnEquipment.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.Security); }; fl.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.Security); }; } else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.Projector)) { btnEquipment.UnSelectedImagePath = "Item/Projector.png"; btnEquipment.SelectedImagePath = "Item/ProjectorSelected.png"; } else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.FoolHeat)) { btnEquipment.UnSelectedImagePath = "Item/FloorHeating.png"; btnEquipment.SelectedImagePath = "Item/FloorHeatingSelected.png"; int eCount = 0; int fhOponeCount = 0; System.Threading.Tasks.Task.Run (() => { foreach (var room in Room.Lists) { if (string.IsNullOrEmpty (room.Name)) { continue; } var devices = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.FoolHeat || obj.Type == DeviceType.FoolHeatPanel; }); eCount += devices.Count; foreach (var acTemp in room.DeviceList) { if (acTemp.Type == DeviceType.FoolHeat || acTemp.Type == DeviceType.FoolHeatPanel) if ((acTemp as FoolHeat).Status == 1) { fhOponeCount++; } } } Application.RunOnMainThread (() => { if (fhOponeCount > 0) { eCount = fhOponeCount; btnOpenNumber.IsSelected = true; } btnOpenNumber.Text = eCount.ToString (); }); }); btnEquipment.MouseUpEventHandler += (sender, e) => { UserDeviceToFH userDeviceToFHView = new UserDeviceToFH (); UserMiddle.DevicePageView.AddChidren (userDeviceToFHView); userDeviceToFHView.showAllRoomFH (); UserMiddle.DevicePageView.PageIndex = 1; }; fl.MouseUpEventHandler += (sender, e) => { UserDeviceToFH userDeviceToFHView = new UserDeviceToFH (); UserMiddle.DevicePageView.AddChidren (userDeviceToFHView); userDeviceToFHView.showAllRoomFH (); UserMiddle.DevicePageView.PageIndex = 1; }; btnEquipment.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.FoolHeat); }; fl.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.FoolHeat); }; equipmentLayout.BackgroundImagePath = "Item/FloorHeatingBackground.png"; } else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.ElectricalControl)) { btnEquipment.UnSelectedImagePath = "Light/Socket.png"; btnEquipment.SelectedImagePath = "Light/SocketOn.png"; equipmentLayout.BackgroundImagePath = "Light/SocketBackground.png"; int eCount = 0; int brighingCount = 0; System.Threading.Tasks.Task.Run (() => { foreach (var room in Room.Lists) { if (string.IsNullOrEmpty (room.Name)) { continue; } var devices = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.LightEnergySwitch || obj.Type == DeviceType.LightSwitchSocket; }); eCount += devices.Count; brighingCount += devices.FindAll ((obj) => { return ((LightSwitch)obj).CurrentBrightness == 100; }).Count; } Application.RunOnMainThread (() => { if (brighingCount > 0) { eCount = brighingCount; btnOpenNumber.IsSelected = true; } btnOpenNumber.Text = eCount.ToString (); }); }); btnEquipment.MouseUpEventHandler += (sender, e) => { UserDeviceToSocket userDeviceToSocketView = new UserDeviceToSocket (); UserMiddle.DevicePageView.AddChidren (userDeviceToSocketView); userDeviceToSocketView.ShowAllRoomLights (); UserMiddle.DevicePageView.PageIndex = 1; }; fl.MouseUpEventHandler += (sender, e) => { UserDeviceToSocket userDeviceToSocketView = new UserDeviceToSocket (); UserMiddle.DevicePageView.AddChidren (userDeviceToSocketView); userDeviceToSocketView.ShowAllRoomLights (); UserMiddle.DevicePageView.PageIndex = 1; }; btnEquipment.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.ElectricalControl); }; fl.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.ElectricalControl); }; } else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.Fan)) { btnEquipment.UnSelectedImagePath = "Fan/Fan.png"; btnEquipment.SelectedImagePath = "Fan/FanOn.png"; equipmentLayout.BackgroundImagePath = "Fan/FanBackground.png"; int eCount = 0; int brighingCount = 0; System.Threading.Tasks.Task.Run (() => { foreach (var room in Room.Lists) { if (string.IsNullOrEmpty (room.Name)) { continue; } var devices = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.FanModule; }); brighingCount = devices.FindAll ((obj) => { return ((FanModule)obj).WindSpeed > 0; }).Count; eCount += devices.Count; } Application.RunOnMainThread (() => { if (brighingCount > 0) { eCount = brighingCount; btnOpenNumber.IsSelected = true; } btnOpenNumber.Text = eCount.ToString (); }); }); btnEquipment.MouseUpEventHandler += (sender, e) => { UserDeviceToFan fanView = new UserDeviceToFan (); UserMiddle.DevicePageView.AddChidren (fanView); fanView.ShowAllRoomCurtain (); UserMiddle.DevicePageView.PageIndex = 1; }; fl.MouseUpEventHandler += (sender, e) => { UserDeviceToFan fanView = new UserDeviceToFan (); UserMiddle.DevicePageView.AddChidren (fanView); fanView.ShowAllRoomCurtain (); UserMiddle.DevicePageView.PageIndex = 1; }; btnEquipment.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.Fan); }; fl.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.Fan); }; } else if (equipmentType == Shared.Language.StringByID (R.MyInternationalizationString.Environmental)) { btnEquipment.SelectedImagePath = "Sensor/Sensor.png"; btnEquipment.UnSelectedImagePath = "Sensor/Sensor.png"; equipmentLayout.BackgroundImagePath = "Sensor/SensorBackground.png"; int eCount = 0; foreach (var room in Room.Lists) { if (string.IsNullOrEmpty (room.Name)) { continue; } var devices = room.DeviceList.FindAll ((common) => { return (common.isMixBox = true && (common.Type == DeviceType.SensorTemperature || common.Type == DeviceType.SensorHumidity || common.Type == DeviceType.SensorTVOC || common.Type == DeviceType.SensorPM25 || common.Type == DeviceType.SensorCO2 // || common.Type == DeviceType.SensorLPG || common.Type == DeviceType.SensorCH4 || common.Type == DeviceType.SensorCOH2 //|| common.Type == DeviceType.SensorWater || common.Type == DeviceType.SensorSmoke || common.Type == DeviceType.SensorMobileDetection //|| common.Type == DeviceType.SensorWindSpeed || common.Type == DeviceType.SensorWindPressure || common.Type == DeviceType.SensorLiquidFlow //|| common.Type == DeviceType.SensorLiquidPressure || common.Type == DeviceType.SensorLiquidDepth || common.Type == DeviceType.SensorRainfall //|| common.Type == DeviceType.SensorWeight || common.Type == DeviceType.SensorHeightLength || common.Type == DeviceType.SensorVelocity //|| common.Type == DeviceType.SensorVibration || common.Type == DeviceType.SensorVoltage || common.Type == DeviceType.SensorCurrent || common.Type == DeviceType.SensorPower //|| common.Type == DeviceType.SensorMenciAndwindowMagnetic || common.Type == DeviceType.SensorIllumination )); }); eCount += devices.Count; } btnOpenNumber.Text = eCount.ToString (); btnEquipment.MouseUpEventHandler += (sender, e) => { UserDeviceToSensor doorLockView = new UserDeviceToSensor (); UserMiddle.DevicePageView.AddChidren (doorLockView); doorLockView.ShowAllSensor (); UserMiddle.DevicePageView.PageIndex = 1; }; fl.MouseUpEventHandler += (sender, e) => { UserDeviceToSensor doorLockView = new UserDeviceToSensor (); UserMiddle.DevicePageView.AddChidren (doorLockView); doorLockView.ShowAllSensor (); UserMiddle.DevicePageView.PageIndex = 1; }; btnEquipment.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.Environmental); }; fl.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.Environmental); }; } else if (equipmentType == Language.StringByID (R.MyInternationalizationString.FreshAir)) { btnEquipment.SelectedImagePath = "FreshAir/FreshAir.png"; btnEquipment.UnSelectedImagePath = "FreshAir/FreshAir.png"; equipmentLayout.BackgroundImagePath = "FreshAir/FreshAirBackground.png"; int eCount = 0; int brighingCount = 0; System.Threading.Tasks.Task.Run (() => { foreach (var room in Room.Lists) { if (string.IsNullOrEmpty (room.Name)) { continue; } var devices = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.FreshAir; }); eCount += devices.Count; brighingCount += devices.FindAll ((obj) => { return ((FreshAir)obj).SwitchStatus == 1; }).Count; } Application.RunOnMainThread (() => { if (brighingCount > 0) { eCount = brighingCount; btnOpenNumber.IsSelected = true; } btnOpenNumber.Text = eCount.ToString (); }); }); btnEquipment.MouseUpEventHandler += (sender, e) => { UserFresAirList freshAirListView = new UserFresAirList (); UserMiddle.DevicePageView.AddChidren (freshAirListView); freshAirListView.ShowAllRoomFreshAir (); UserMiddle.DevicePageView.PageIndex = 1; }; fl.MouseUpEventHandler += (sender, e) => { UserFresAirList freshAirListView = new UserFresAirList (); UserMiddle.DevicePageView.AddChidren (freshAirListView); freshAirListView.ShowAllRoomFreshAir (); UserMiddle.DevicePageView.PageIndex = 1; }; btnEquipment.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.FreshAir); }; fl.MouseLongEventHandler += (sender, e) => { DelUserEquipmentView (eCount, R.MyInternationalizationString.FreshAir); }; } } } }