using System; using System.Collections.Generic; namespace Shared.SimpleControl.Phone { public class SystemEquipmentBase : FrameLayout { VerticalScrolViewLayout EquipmentScrolView; void SaveAndReadDevices (Common device) { MainPage.Loading.Start (); System.Threading.Tasks.Task.Run (() => { if (SysMiddle.hideListCommon != null && SysMiddle.hideListCommon.Count != 0) { foreach (Common c in SysMiddle.hideListCommon) { if (c.SubnetID == device.SubnetID && c.DeviceID == device.DeviceID) { LoadDevice (c); Application.RunOnMainThread (() => { try { string ReadStr1 = "_" + c.SubnetID.ToString () + "_" + c.DeviceID.ToString () + "_"; List localEquipmentList1 = new List (); List files = IO.FileUtils.ReadFiles ().FindAll ((obj) => obj.Split ('_') [0] == "Equipment" && obj.Split('_').Length ==5); foreach (string equipment in files) { if (equipment.Contains (ReadStr1) && c.Type.ToString() == equipment.Split('_')[1]){ localEquipmentList1.Add (equipment); } } if (localEquipmentList1.Count > 0) InitDevicesList (localEquipmentList1, device); } catch { } }); Console.WriteLine ("loadChildren"); } } } LoadDevice (device); Application.RunOnMainThread (() => { try { string ReadStr = "_" + device.SubnetID.ToString () + "_" + device.DeviceID.ToString () + "_"; List localEquipmentList = new List (); List localFileList = IO.FileUtils.ReadFiles (); foreach (string equipment in localFileList) { if (equipment.Contains (ReadStr) && equipment.Split ('_').Length == 5) { if (device.Type.ToString () == typeof (LightLogic).Name || equipment.Contains (device.Type.ToString ())) { if (equipment.Split ('_') [0] == "Equipment") localEquipmentList.Add (equipment); } } } if (localEquipmentList.Count == 0 && device.Type != DeviceType.InfraredMode) { if (device.Type != DeviceType.RCU) { //new Alert (Language.StringByID (R.MyInternationalizationString.Tip), "asdfadsdfasfas", Language.StringByID (R.MyInternationalizationString.Close)).Show (); new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show (); return; } } InitDevicesList (localEquipmentList, device); } catch { } finally { MainPage.Loading.Hide (); } }); }); } public void EquipmentBaseViewShow (Common device) { RemoveAll (); // top AddTopLayout (device); EquipmentScrolView = new VerticalScrolViewLayout () { Y = Application.GetRealHeight(91), Height = Application.GetRealHeight (844 - 91), }; AddChidren (EquipmentScrolView); SaveAndReadDevices (device); #region bottom EventHandler eHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { System.Threading.Tasks.Task.Run (() => { Application.RunOnMainThread (() => { MainPage.Loading.Start (); }); string delFlag = "_" + device.SubnetID.ToString () + "_" + device.DeviceID.ToString () + "_"; var delFiles = IO.FileUtils.ReadFiles ().FindAll ((w) => { return w.Contains (delFlag); }); for (int i = 0; i < delFiles.Count; i++) { if (delFiles [i].Split ('_').Length == 5) { if (delFiles [i].Split ('_') [0] == "Equipment") IO.FileUtils.DeleteFile (delFiles [i]); } } Random ran = new Random (); CommonPage.RandomHigh = (byte)ran.Next (0, 255); CommonPage.RandomLow = (byte)ran.Next (0, 255); CommonPage.LocalPhoneFindDevice = true; CommonPage.DeviceList.Clear (); var sss= Control.ControlBytesSendHasReturn (Command.ReadDeviceModul, device.SubnetID, device.DeviceID, new byte [] { (byte)CommonPage.RandomHigh, (byte)CommonPage.RandomLow }); CommonPage.LocalPhoneFindDevice = false; Application.RunOnMainThread (() => { EquipmentBaseViewShow (device); }); }); }); var sysBottomView = new FrameLayout () { Height = Application.GetRealHeight (90), Y = Application.GetRealHeight (844) }; AddChidren (sysBottomView); Button AddSystemEquipmentButton = new Button () { Width = LayoutParams.MatchParent, Height = LayoutParams.MatchParent, TextID = R.MyInternationalizationString.ReFresh, TextAlignment = TextAlignment.Center, TextColor = SkinStyle.Current.TextColor1, BackgroundColor = SkinStyle.Current.MainColor }; sysBottomView.AddChidren (AddSystemEquipmentButton); AddSystemEquipmentButton.MouseUpEventHandler += eHandler; sysBottomView.AddChidren (new Button () { Height = 1, BackgroundColor = SkinStyle.Current.White20Transparent }); #endregion } /// /// 加载顶部设备标题栏 /// /// The top layout. /// Device. void AddTopLayout (Common device) { RowLayout frameLayout = new RowLayout () { Height = Application.GetRealHeight (90), BackgroundColor = SkinStyle.Current.MainColor }; AddChidren (frameLayout); Button backButton = new Button () { X = Application.GetRealWidth (0), Height = Application.GetRealHeight (90), Width = Application.GetRealWidth (85), UnSelectedImagePath = "Item/Back.png", SelectedImagePath = "Item/BackSelected.png", Gravity = Gravity.CenterVertical, }; backButton.MouseUpEventHandler += (sender, e) => { (Parent as PageLayout).PageIndex -= 1; }; frameLayout.AddChidren (backButton); EditText textButton = new EditText () { X = Application.GetRealWidth (30) + backButton.Right, Height = Application.GetRealHeight (50), Width = Application.GetRealWidth (400), Text = device.Name, Gravity = Gravity.CenterVertical, TextAlignment = TextAlignment.CenterLeft, SelectedBackgroundColor = SkinStyle.Current.SubtitleView, TextSize = 15, Enable = false, TextColor = SkinStyle.Current.TextColor1 }; frameLayout.AddChidren (textButton); Button editor = new Button () { X = Application.GetRealWidth(520), Height = Application.GetRealHeight (90), Width = Application.GetRealWidth (70), UnSelectedImagePath = "Item/Editor.png", SelectedImagePath="Item/EditorSelected.png", Gravity = Gravity.CenterVertical, }; frameLayout.AddChidren (editor); editor.MouseUpEventHandler += (sender, e) => { if (editor.IsSelected == true) { textButton.IsSelected = editor.IsSelected = textButton.Enable = false; device.Name = textButton.Text.Trim (); CommonPage.UpdateRemark (device.SubnetID, device.DeviceID, textButton.Text.Trim ()); IO.FileUtils.SaveEquipmentMessage(device); } else { textButton.Enable = textButton.IsSelected = editor.IsSelected = true; } }; } /// /// 读取设备信息 /// /// Device. void LoadDevice (Common device) { CommonPage.LocalPhoneFindDevice = true; string ReadStr = "_" + device.SubnetID.ToString () + "_" + device.DeviceID.ToString () + "_"; List localEquipmentList = new List (); foreach (string equipment in IO.FileUtils.ReadFiles ().FindAll ((obj) => obj.Split ('_') [0] == "Equipment")) { if (equipment.Contains (ReadStr) && equipment.Split ('_').Length == 5) { if (device.Type.ToString () == DeviceType.LightLogic.ToString () || (equipment.Contains (device.Type.ToString ()))) localEquipmentList.Add (equipment); } } if (localEquipmentList.Count != 0) { return; } byte bigClass = device.BigClass; byte minClass = device.MinClass; int count = device.LoopCount; if (bigClass == 254) return; CommonPage.DeviceLoopList.Clear (); for (int i = 1, j = 0; i <= count; i++) { var loopBytes = Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, device.SubnetID, device.DeviceID,new byte [] { bigClass, minClass, (byte)i }); if (loopBytes == null) { while (SystemWirelessGateway.Waiting) { System.Threading.Thread.Sleep (200); } j++; //连续两次读取不到数据则跳出该循环 if (j == 2 && i == 2) break; } } CommonPage.LocalPhoneFindDevice = false; } /// /// 显示设备列表 /// void LoadInterface (EventHandler eHandler,string textName,Button btn = null) { RowLayout frameLayout1 = new RowLayout () { Width = LayoutParams.MatchParent, Height = Application.GetRealHeight (93), }; frameLayout1.MouseUpEventHandler += eHandler; EquipmentScrolView.AddChidren (frameLayout1); Button pointButton = new Button () { Width = Application.GetRealHeight (13), Height = Application.GetRealHeight (13), X = Application.GetRealWidth (86), UnSelectedImagePath = "Item/Point.png", SelectedImagePath = "Item/PointSelected.png", Gravity = Gravity.CenterVertical, }; frameLayout1.AddChidren (pointButton); Button nameButton = new Button () { Width = Application.GetRealWidth (242), Height = LayoutParams.MatchParent, Text = textName, TextAlignment = TextAlignment.CenterLeft, X =Application.GetRealWidth (135), TextColor = SkinStyle.Current.TextColor1 }; nameButton.MouseUpEventHandler += eHandler; frameLayout1.AddChidren (nameButton); if (eHandler != null) { Button rightButton = new Button () { Width = Application.GetRealWidth (28), Height = Application.GetRealHeight (40), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "Item/Right.png", SelectedImagePath = "Item/RightSelected.png", }; rightButton.X = frameLayout1.Width - rightButton.Width - Application.GetRealWidth (30); rightButton.MouseUpEventHandler += eHandler; frameLayout1.AddChidren (rightButton); } if (btn != null) { frameLayout1.AddChidren (btn); } } /// /// 加载设备数据 /// void InitDevicesList (List listDevice,Common device )//,bool isMixBox=false) { if (listDevice.Count == 0) return; RowLayout fl = new RowLayout () { Height = Application.GetRealHeight (93), BackgroundColor = SkinStyle.Current.MainColor }; //if (isMixBox == false) EquipmentScrolView.AddChidren (fl); Button btnDeviceName =new Button(){ Width = Application.GetRealWidth (303), Height = Application.GetRealHeight (55), X = Application.GetRealWidth (86), Y = Application.GetRealHeight(20), TextAlignment = TextAlignment.CenterLeft, TextColor = SkinStyle.Current.TextColor1 }; fl.AddChidren (btnDeviceName); try { //设备界面要显示的设备,必须在这里添加显示 for (int i = 0; i < listDevice.Count; i++) { if (listDevice [i].Split ('_').Length == 5) { //listDevice [i].Remove (listDevice [i].Length - 3); if (listDevice [i].Split ('_') [1].Contains (DeviceType.Thermostat.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.Thermostat; Thermostat capillaryAC = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { }); LoadInterface (null, capillaryAC.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.LightDimming.ToString ()) ) { btnDeviceName.TextID = R.MyInternationalizationString.DimmingLights; LightDimming lightDimming = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { var systemLightDimming = new SystemLightDimming (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemLightDimming); systemLightDimming.SystemLightDimmingShow (lightDimming, device); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; }); LoadInterface (clickEventHandler, lightDimming.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.LightDALI.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.DimmingLights; LightDALI lightDALI = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { var systemLightDimming = new SystemLightDALI (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemLightDimming); systemLightDimming.SystemLightDimmingShow (lightDALI, device); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; }); LoadInterface (clickEventHandler, lightDALI.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.LightMixDimming.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.DimmingLights; LightMixDimming lightMixDimming = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { //new SystemLightMixDimming ().SystemLightMixDimmingShow (lightMixDimming, device); var systemLightMixDimming = new SystemLightMixDimming (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemLightMixDimming); systemLightMixDimming.SystemLightMixDimmingShow (lightMixDimming, device); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; }); LoadInterface (clickEventHandler, lightMixDimming.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.LightRGB.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.DimmingLights; LightLogic lightRGB = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { //new SystemLightLogic ().SystemLightLogicShow (lightRGB, device); var systemLightLogic = new SystemLightLogic (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemLightLogic); systemLightLogic.SystemLightLogicShow (lightRGB, device); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; }); LoadInterface (clickEventHandler, lightRGB.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.LightSwitch.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.SwitchLights; LightSwitch lightSwitch = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { //new SystemLightSwitch ().SystemLightSwitchShow (lightSwitch, device); var systemLightSwitch = new SystemLightSwitch (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemLightSwitch); systemLightSwitch.SystemLightSwitchShow (lightSwitch, device); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; }); LoadInterface (clickEventHandler, lightSwitch.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.LightMixSwitch.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.SwitchLights; LightMixSwitch lightMixSwitch = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { //new SystemLightMixSwitch ().SystemLightSwitchShow (lightMixSwitch, device); var systemLightMixSwitch = new SystemLightMixSwitch (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemLightMixSwitch); systemLightMixSwitch.SystemLightSwitchShow (lightMixSwitch, device); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; }); LoadInterface (clickEventHandler, lightMixSwitch.Name);//, btnSwitchLight); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.LightEnergySwitch.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.SwitchLights; LightEnergySwitch lightEnergySwitch = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { //new SystemLightEnergySwitch ().SystemLightEnergySwitchShow (lightEnergySwitch, device); var systemLightEnergySwitch = new SystemLightEnergySwitch (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemLightEnergySwitch); systemLightEnergySwitch.SystemLightEnergySwitchShow (lightEnergySwitch, device); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; }); LoadInterface (clickEventHandler, lightEnergySwitch.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.LightCCT.ToString ()) || listDevice [i].Split ('_') [1].Contains (DeviceType.LightRGBW.ToString ()) || listDevice [i].Split ('_') [1].Contains (DeviceType.LightRGBandCCT.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.DimmingLights; LightLogic lightLogic = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { //new SystemLightDimming ().SystemLightDimmingShow (lightDimming, device); }); LoadInterface (clickEventHandler, lightLogic.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.ButtonPanel.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.ButtonKey; ButtonPanel wpButtonKey = Newtonsoft.Json.JsonConvert.DeserializeObject ( System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { MainPage.Loading.Start (Language.StringByID(R.MyInternationalizationString.load)); System.Threading.Tasks.Task.Run (() => { byte [] loopdData = Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, wpButtonKey.SubnetID, wpButtonKey.DeviceID, new byte [] { wpButtonKey.BigClass, wpButtonKey.MinClass, wpButtonKey.LoopID }); wpButtonKey.Mode = loopdData [23]; Application.RunOnMainThread (() => { MainPage.Loading.Hide (); //new SystemPanel ().SystemWirelessPanelButtonKeyShow (wpButtonKey, device); var systemPanel = new SystemPanel (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemPanel); systemPanel.SystemWirelessPanelButtonKeyShow (wpButtonKey, device); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; }); }); }); LoadInterface (clickEventHandler, wpButtonKey.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.CurtainModel.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.CurtainModel; CurtainModel curtainModel = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { //new SystemCurtainModel ().SystemCurtainModelShow (curtainModel, device); var systemCurtainModel = new SystemCurtainModel (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemCurtainModel); systemCurtainModel.SystemCurtainModelShow (curtainModel, device); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; }); LoadInterface (clickEventHandler, curtainModel.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.CurtainTrietex.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.CurtainTrietex; CurtainTrietex curtainTrietex = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { //new SystemCurtainTrietex ().SystemCurtainTrietexShow (curtainTrietex, device); var systemCurtainTrietex = new SystemCurtainTrietex (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemCurtainTrietex); systemCurtainTrietex.SystemCurtainTrietexShow (curtainTrietex, device); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; }); LoadInterface (clickEventHandler, curtainTrietex.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.CurtainRoller.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.CurtainRoller; CurtainRoller curtainRoller = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { //new SystemCurtainRoller ().SystemCurtainRollerShow (curtainRoller, device); var systemCurtainRoller = new SystemCurtainRoller (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemCurtainRoller); systemCurtainRoller.SystemCurtainRollerShow (curtainRoller, device); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; }); LoadInterface (clickEventHandler, curtainRoller.Name); } else if (listDevice [i].Split ('_') [1] == DeviceType.HVAC.ToString ()) { btnDeviceName.TextID = R.MyInternationalizationString.ACHost; btnDeviceName.Text += ":"; HVAC acHost = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { //new SystemACHost ().ShowACHost (acHost, device); var systemACHost = new SystemACHost (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemACHost); systemACHost.ShowACHost (acHost, device); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; }); LoadInterface (clickEventHandler, acHost.Name); } else if (listDevice [i].Split ('_') [1] == DeviceType.ACPanel.ToString ()) { btnDeviceName.TextID = R.MyInternationalizationString.ACPanel; ACPanel acHost = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { byte [] deviceBytes = IO.FileUtils.ReadFile ("Equipment_ButtonPanel_" + device.SubnetID + "_" + device.DeviceID); string deviceString = CommonPage.MyEncodingUTF8.GetString (deviceBytes); ButtonPanel bp = Newtonsoft.Json.JsonConvert.DeserializeObject (deviceString); //new SystemACPanel ().ShowSystemACPanel (acHost, bp); var systemACPanel = new SystemACPanel (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemACPanel); systemACPanel.ShowSystemACPanel (acHost, bp); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; }); LoadInterface (clickEventHandler, acHost.Name); btnDeviceName.Text += ":"; } else if (listDevice [i].Split ('_') [1] == DeviceType.FoolHeat.ToString ()) { FoolHeat terrestrialHeat = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); btnDeviceName.TextID = R.MyInternationalizationString.FoolHeat; EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { //new SystemFoolHeat ().SystemTerrestrialHeatShow (terrestrialHeat, device); var systemFoolHeat = new SystemFoolHeat (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemFoolHeat); systemFoolHeat.SystemTerrestrialHeatShow (terrestrialHeat, device); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; }); LoadInterface (clickEventHandler, terrestrialHeat.Name); } else if (listDevice [i].Split ('_') [1] == (DeviceType.FoolHeatPanel.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.TerrestrialHeatPanel; FoolHeatPanel terrestrialHeat = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { byte [] deviceBytes = IO.FileUtils.ReadFile ("Equipment_ButtonPanel_" + device.SubnetID + "_" + device.DeviceID); string deviceString = CommonPage.MyEncodingUTF8.GetString (deviceBytes); ButtonPanel bp = Newtonsoft.Json.JsonConvert.DeserializeObject (deviceString); //new SystemFloorHeatingPanel ().ShowSystemFloorHeatingPanel (terrestrialHeat, bp); var systemFloorHeatingPanel = new SystemFloorHeatingPanel (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemFloorHeatingPanel); systemFloorHeatingPanel.ShowSystemFloorHeatingPanel (terrestrialHeat, bp); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; }); LoadInterface (clickEventHandler, terrestrialHeat.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.DryContact.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.DryContactPanel; DryContact dcp = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { return; MainPage.Loading.Start (Language.StringByID(R.MyInternationalizationString.load)); System.Threading.Tasks.Task.Run (() => { byte [] loopdData = Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, dcp.SubnetID, dcp.DeviceID, new byte [] { dcp.BigClass, dcp.MinClass, dcp.LoopID }); dcp.Mode = loopdData [23]; Application.RunOnMainThread (() => { MainPage.Loading.Hide (); //new SystemPanel ().SystemWirelessPanelButtonKeyShow (dcp, device); var systemPanel = new SystemPanel (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemPanel); systemPanel.SystemWirelessPanelButtonKeyShow (dcp, device); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; }); }); }); Button btnSwitchLight = new Button () { Width = Application.GetRealWidth (142), Height = Application.GetRealHeight (50), Text = dcp.Status == 0 ? "state:OFF" : "state:ON", TextAlignment = TextAlignment.Center, X = Application.GetRealWidth (385), Y = Application.GetRealHeight (16), BorderWidth = 2, Radius = 5, BorderColor = SkinStyle.Current.ButtonColor, }; System.Threading.Tasks.Task.Run (() => { byte [] bbb = Control.ControlBytesSendHasReturn (Command.ReadDryContactStatus, dcp.SubnetID, dcp.DeviceID, new byte [] { 1, dcp.LoopID }); if (bbb != null) { Application.RunOnMainThread (() => { if (bbb [2] == 0) { dcp.Status = 100; } else { dcp.Status = 0; } btnSwitchLight.Text = dcp.Status == 0 ? "state:OFF" : "state:ON"; }); } }); LoadInterface (null, dcp.Name, btnSwitchLight); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.InfraredMode.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.InfraredEquipments; InfraredMode infrared = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { //new SystemInfrared ().ShowSystemInfrared (infrared, device); var systemInfrared = new SystemInfrared (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemInfrared); systemInfrared.ShowSystemInfrared (infrared, device); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; //Animate = Animate.LeftToRight; }); LoadInterface (clickEventHandler, infrared.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.ACInfrared.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.ACIfrared; InfraredMode acInfrared = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { byte [] deviceBytes = IO.FileUtils.ReadFile ("Equipment_InfraredMode_" + device.SubnetID + "_" + device.DeviceID); string deviceString = CommonPage.MyEncodingUTF8.GetString (deviceBytes); InfraredMode im = Newtonsoft.Json.JsonConvert.DeserializeObject (deviceString); //new SystemInfrared ().ShowSystemInfrared (acInfrared, im, true); var systemInfrared = new SystemInfrared (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemInfrared); systemInfrared.ShowSystemInfrared (acInfrared, im, true); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; //Animate = Animate.LeftToRight; }); LoadInterface (clickEventHandler, acInfrared.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.MusicModel.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.MusicModel; MusicModel acInfrared = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { byte [] deviceBytes = IO.FileUtils.ReadFile ("Equipment_" + DeviceType.MusicModel.ToString () + device.SubnetID + "_" + device.DeviceID); string deviceString = CommonPage.MyEncodingUTF8.GetString (deviceBytes); //MusicModel im = Newtonsoft.Json.JsonConvert.DeserializeObject (deviceString); //new SystemInfrared ().ShowSystemInfrared (acInfrared, im, true); //Animate = Animate.LeftToRight; }); LoadInterface (clickEventHandler, acInfrared.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.FanModule.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.Fan; FanModule fanModule = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { byte [] deviceBytes = IO.FileUtils.ReadFile ("Equipment_" + DeviceType.FanModule.ToString () + device.SubnetID + "_" + device.DeviceID); string deviceString = CommonPage.MyEncodingUTF8.GetString (deviceBytes); //new SystemFan ().SystemFanShow (fanModule, device); var systemFan = new SystemFan (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemFan); systemFan.SystemFanShow (fanModule, device); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; }); LoadInterface (clickEventHandler, fanModule.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.MusicPanel.ToString ())) { //btnDeviceName.TextID = R.MyInternationalizationString.MusicPanel; //MusicPanel musicPanel = Newtonsoft.Json.JsonConvert.DeserializeObject ( // CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); //EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { // byte [] deviceBytes = IO.FileUtils.ReadFile ("Equipment_" + DeviceType.MusicPanel.ToString () + device.SubnetID + "_" + device.DeviceID); // string deviceString = CommonPage.MyEncodingUTF8.GetString (deviceBytes); // new SystemMusicPanel ().ShowSystemMusicPanel (musicPanel, device); //}); //LoadInterface (clickEventHandler, musicPanel.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.LogicModule.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.LogicModule; LogicModule logicModule = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); LoadInterface (null, logicModule.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.DoorLock.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.DoorLock;//门锁111 DoorLock doorLock = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); LoadInterface (null, doorLock.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.Sensor.ToString ())) { Sensor sensor = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { //new SystemSensor ().SystemSensorShow (sensor, device); var systemSensor = new SystemSensor (); SystemHomePage.sysMiddleDevicePageView.AddChidren (systemSensor); systemSensor.SystemSensorShow (sensor, device); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; }); btnDeviceName.TextID = sensor.SensorTypeTestID; LoadInterface (clickEventHandler, sensor.Name); } else if (listDevice [i].Split ('_') [1].Contains (DeviceType.FreshAir.ToString ())) { btnDeviceName.TextID = R.MyInternationalizationString.FreshAir; FreshAir sensor = Newtonsoft.Json.JsonConvert.DeserializeObject ( CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (listDevice [i]))); EventHandler clickEventHandler = new EventHandler (delegate (object sender, MouseEventArgs e) { //new SysFresAir ().SysFresAirShow (sensor, device); var sysFresAir = new SysFresAir (); SystemHomePage.sysMiddleDevicePageView.AddChidren (sysFresAir); sysFresAir.SysFresAirShow (sensor, device); SystemHomePage.sysMiddleDevicePageView.PageIndex = SystemHomePage.sysMiddleDevicePageView.ChildrenCount - 1; }); LoadInterface (clickEventHandler, sensor.Name); } } } } catch (Exception ex){ Console.WriteLine ("SystemEquipmentBase,AddDevicesList" + ex.ToString ()); } } } }