//using System; //using System.Collections.Generic; //using System.Threading; //namespace Shared.SimpleControl.Phone //{ // public class GuideSettingGateway : FrameLayout // { // static GuideSettingGateway curView; // static GatewayBase gatewayDeicve; // static VerticalScrolViewLayout bodyView; // static Button btnCloseLoading; // static Loading myLoading; // bool isReBind = false; // static List addedCommon; // public GuideSettingGateway(GatewayBase gd) // { // gatewayDeicve = gd as GatewayBase; // addedCommon = new List (); // BackgroundColor = SkinStyle.Current.MainColor; // curView = this; // myLoading = new Loading (); ////#if __IOS__ // myLoading.LodingBackgroundColor = 0x00999999; ////#else //// myLoading.LodingBackgroundColor = SkinStyle.Current.ViewColor; ////#endif // btnCloseLoading = new Button (); // btnCloseLoading.MouseUpEventHandler += (sender, e) => { // Application.RunOnMainThread(()=>{ // myLoading.Hide (); // btnCloseLoading.RemoveFromParent (); // WirelessConfig (new byte [] { 1 });//close // if (CommonPage.newDevice > 0) { // CommonPage.newDevice = 0; // SearchDeviceList (); // } // }); // }; // } // public override void RemoveFromParent () // { // curView = null; // addedCommon.Clear (); // BackgroundColor = SkinStyle.Current.MainColor; // base.RemoveFromParent (); // } // public void ShowPage () // { // #region 标题 // var topView = new FrameLayout () { // Y = Application.GetRealHeight (36), // Height = Application.GetRealHeight (90), // Width = Application.GetRealWidth (640), // }; // AddChidren (topView); // var title = new Button () { // TextAlignment = TextAlignment.Center, // Text = gatewayDeicve.Name, // TextColor = SkinStyle.Current.TextColor1, // TextSize = 19, // }; // topView.AddChidren (title); // var back = new Button () { // Height = Application.GetRealHeight (90), // Width = Application.GetRealWidth (85), // UnSelectedImagePath = "Item/Back.png", // SelectedImagePath = "Item/BackSelected.png", // }; // topView.AddChidren (back); // //Refresh.png // back.MouseUpEventHandler += (sender, e) => { // (Parent as PageLayout).PageIndex -= 1; // if (gatewayDeicve.MAC.Replace (".", "") == UserConfig.Instance.GatewayMAC || MainPage.LoginUser.AccountString == "464027401@qq.com") { // var delFile = IO.FileUtils.ReadFiles ().FindAll ((w) => { // return (w.Split ('_') [0] == "Equipment") && (w.Split ('_') [2] == gatewayDeicve.SubnetID.ToString ()); // }); // for (int k = 0; k < delFile.Count; k++) { // IO.FileUtils.DeleteFile (delFile [k]); // } // } // }; // var btnSearch = new Button () { // Width = Application.GetRealWidth (75), // Height = Application.GetRealHeight (75), // X = Application.GetRealWidth (520), // Y = Application.GetRealHeight(10), // UnSelectedImagePath = "Item/Refresh.png", // }; // topView.AddChidren (btnSearch); // btnSearch.MouseUpEventHandler += (sd, fs) => { // bodyView.RemoveAll (); // addedCommon.Clear (); // SearchDeviceList (); // }; //#endregion // bodyView = new VerticalScrolViewLayout () { // Y = topView.Bottom, // Height = Application.GetRealHeight(1136- 126 - 95), // BackgroundColor = SkinStyle.Current.ViewColor, // }; // AddChidren (bodyView); // var bottomView = new FrameLayout () { // BackgroundColor = SkinStyle.Current.Black50Transparent, // Y = bodyView.Bottom, // Height = Application.GetRealHeight(100), // }; // AddChidren (bottomView); // var btnAssignRoom = new Button () { // Y = 1, // BackgroundColor = SkinStyle.Current.ButtonColor, // Text = "Assign Room", // TextSize = 16, // TextAlignment = TextAlignment.Center, // TextColor = SkinStyle.Current.TextColor1 // }; // bottomView.AddChidren (btnAssignRoom); // btnAssignRoom.MouseUpEventHandler += (sender, e) => { // //bodyView.RemoveAll (); // RemoteSetting (); // }; // SearchDeviceList (); // } // /// // /// 远程配置 // /// // void RemoteSetting () // { // byte [] gatewayBytes = null; // byte [] serverIPBytes = null; // string [] strServerIP = (MainPage.SeviceIP).Split ('.'); // string [] strServerIP1 = (MainPage.SeviceIP).Split ('.'); // MainPage.Loading.Start ("Configuring device..."); // System.Threading.Tasks.Task.Run (() => { // try { // //2022-01-12 修复计算溢出问题 // byte regionID1 = (byte)((UserConfig.Instance.CurrentRegion.RegionID >> (6 * 4)) & 0xFF); // byte regionID2 = (byte)((UserConfig.Instance.CurrentRegion.RegionID >> (4 * 4)) & 0xFF); // byte regionID3 = (byte)((UserConfig.Instance.CurrentRegion.RegionID >> (2 * 4)) & 0xFF); // byte regionID4 = (byte)((UserConfig.Instance.CurrentRegion.RegionID) & 0xFF); // var currentRegionIdBytes = new byte [] {regionID1, regionID2, regionID3, regionID4}; // //var currentRegionIdBytes = new byte [] { // // (byte)(UserConfig.Instance.CurrentRegion.RegionID / 256 / 256 / 256), // // (byte)(UserConfig.Instance.CurrentRegion.RegionID / 256 / 256), // // (byte)(UserConfig.Instance.CurrentRegion.RegionID / 256), // // (byte)(UserConfig.Instance.CurrentRegion.RegionID%256), // //}; // gatewayBytes = Control.ControlBytesSendHasReturn (Command.ReadGateWayModelInfo, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, new byte [] { }); // serverIPBytes = Control.ControlBytesSendHasReturn (Command.ReadGatewayServerIP, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, new byte [] { }); // gatewayDeicve.Remote_GroupName = MainPage.LoginUser.AccountString;//UserConfig.Instance.CurrentRegion.RegionName; // gatewayDeicve.Remote_ProjectName = gatewayDeicve.MAC.Replace (".", "");//UserConfig.Instance.CurrentRegion.RegionName; // gatewayDeicve.Remote_UserName = "Admin"; // gatewayDeicve.Remote_Password = "c" + MainPage.LoginUser.MasterID; // byte [] ggn = new byte [20]; // byte [] b1 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_GroupName); // gatewayDeicve.Remote_GroupName = CommonPage.MyEncodingGB2312.GetString (b1); // Array.Copy (b1, 0, ggn, 0, 20 < b1.Length ? 20 : b1.Length); // byte [] gpn = new byte [20]; // byte [] b2 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_ProjectName); // Array.Copy (b2, 0, gpn, 0, 20 < b2.Length ? 20 : b2.Length); // byte [] gun = new byte [8]; // byte [] b3 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_UserName); // Array.Copy (b3, 0, gun, 0, 8 < b3.Length ? 8 : b3.Length); // byte [] gpw = new byte [8]; // byte [] b4 = CommonPage.MyEncodingGB2312.GetBytes (gatewayDeicve.Remote_Password); // Array.Copy (b4, 0, gpw, 0, 8 < b4.Length ? 8 : b4.Length); // byte [] macAddress = Control.ControlBytesSendHasReturn (Command.ReadDeviceMac, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, new byte [] { }); // gatewayBytes [0] = 2;//远程标示 // Array.Copy (ggn, 0, gatewayBytes, 1, 20 < ggn.Length ? 20 : ggn.Length); // Array.Copy (gpn, 0, gatewayBytes, 21, 20 < gpn.Length ? 20 : gpn.Length); // Array.Copy (gun, 0, gatewayBytes, 41, 8 < gun.Length ? 8 : gun.Length); // Array.Copy (gpw, 0, gatewayBytes, 49, 8 < gpw.Length ? 8 : gpw.Length); // Control.ControlBytesSend (Command.SetGateWayModelInfo, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, gatewayBytes); // serverIPBytes [0] = Convert.ToByte (strServerIP [0]); // serverIPBytes [1] = Convert.ToByte (strServerIP [1]); // serverIPBytes [2] = Convert.ToByte (strServerIP [2]); // serverIPBytes [3] = Convert.ToByte (strServerIP [3]); // int point1 = 9999; // serverIPBytes [4] = Convert.ToByte (point1 / 256); // serverIPBytes [5] = Convert.ToByte (point1 % 256); // serverIPBytes [6] = Convert.ToByte (strServerIP1 [0]); // serverIPBytes [7] = Convert.ToByte (strServerIP1 [1]); // serverIPBytes [8] = Convert.ToByte (strServerIP1 [2]); // serverIPBytes [9] = Convert.ToByte (strServerIP1 [3]); // int point2 = 9999; // serverIPBytes [10] = Convert.ToByte (point2 / 256); // serverIPBytes [11] = Convert.ToByte (point2 % 256); // //远程ip地址的设置 // var mobytes = Control.ControlBytesSendHasReturn (Command.SetGateWayModelInternetInfo, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, serverIPBytes); // if (mobytes == null) { // Application.RunOnMainThread (() => { // new Alert ("", Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), // Language.StringByID (R.MyInternationalizationString.Close)).Show (); // }); // } else if (mobytes [0] == 0xF5) { // Application.RunOnMainThread (() => { // new Alert ("", Language.StringByID (R.MyInternationalizationString.OperationFailed), // Language.StringByID (R.MyInternationalizationString.Close)).Show (); // }); // } else { // if (gatewayDeicve.Type == DeviceType.OnePortWirelessFR) { // var bindReginIdStatus = Control.ControlBytesSendHasReturn (Command.Write_APP_Data_STORE_1D5E_CMD, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, currentRegionIdBytes); // if (bindReginIdStatus == null) { // Application.RunOnMainThread (() => { // new Alert ("", Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show (); // }); // return; // } else if (bindReginIdStatus [0] != 0xF8) { // //new Alert ("", "网关绑定住宅失败!", Language.StringByID (R.MyInternationalizationString.Close)).Show (); // Application.RunOnMainThread (() => { // new Alert ("", "Gateway failed to bind residence!", Language.StringByID (R.MyInternationalizationString.Close)).Show (); // }); // return; // } // } // Application.RunOnMainThread (() => { // MainPage.Loading.Start ("Gateway setting succeeded,data up.Please wait..."); // }); // IO.FileUtils.SaveEquipmentMessage (gatewayDeicve); // var gatewayMAC = gatewayDeicve.MAC.Replace (".", ""); // var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (new EditMACByHomeId { RegionID = UserConfig.Instance.CurrentRegion.RegionID, MAC = gatewayMAC, IsReBind = true }); // var respone = MainPage.RequestHttps ("EditMACByHomeId", requestJson); // if (respone.StateCode != "SUCCESS") { // Application.RunOnMainThread (() => { // new Alert ("", "Communication abnormality,gateway failed to bind residence!", Language.StringByID (R.MyInternationalizationString.Close)).Show (); // if (MainPage.LoginUser.AccountString == "464027401@qq.com") { // new Alert (respone.StateCode, respone.ErrorInfo, Language.StringByID (R.MyInternationalizationString.Close)).Show (); // } // }); // return; // } // var gatewayListObj = new GatewayListObj (); // var gatewayListJson = Newtonsoft.Json.JsonConvert.SerializeObject (gatewayListObj); // var gatewayListRevertObj = MainPage.RequestHttps ("GatewayList", gatewayListJson); // if (gatewayListRevertObj.StateCode == "SUCCESS") { // var responseGatewayDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject> (gatewayListRevertObj.ResponseData.ToString ()); // if (responseGatewayDataObj.Count > 0) { // UserConfig.Instance.GatewayList.Clear (); // UserConfig.Instance.GatewayList.AddRange (responseGatewayDataObj); // UserConfig.Instance.GatewayMAC = gatewayDeicve.MAC; // UserConfig.Instance.SaveUserConfig (); // MainPage.LoginUser.LastTime = DateTime.Now; // } else { // Application.RunOnMainThread (() => { // new Alert ("", "Communication abnormality,gateway failed to bind residence.Please try again.", Language.StringByID (R.MyInternationalizationString.Close)).Show (); // if (MainPage.LoginUser.AccountString == "464027401@qq.com") { // new Alert ("22:" + respone.StateCode, respone.ErrorInfo, Language.StringByID (R.MyInternationalizationString.Close)).Show (); // } // }); // } // } // } // } catch (Exception ex) { // Console.WriteLine (ex.Message); // Application.RunOnMainThread (() => { // new Alert ("", Language.StringByID (R.MyInternationalizationString.OperationFailed), Language.StringByID (R.MyInternationalizationString.Close)).Show (); // }); // bool canRemove = false; // } finally { // Application.RunOnMainThread (() => { // MainPage.Loading.Hide (); // //this.RemoveAll (); // }); // } // }); // //Room.InitAllRoom (); // } // /// // /// 开关无线配置 // /// // void WirelessConfig (byte [] switchStatus) // { // Control.ControlBytesSend (Command.CheckConfigSuccess, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, switchStatus); // } // /// // /// 搜索功能模块设备 // /// // void SearchDeviceList () // { // //var delFile = IO.FileUtils.ReadFiles ().FindAll ((w) => { // // return (w.Split ('_') [0] == "Equipment") && (w.Split ('_') [2] == gatewayDeicve.SubnetID.ToString ()); // //}); // //for (int k = 0; k < delFile.Count; k++) { // // IO.FileUtils.DeleteFile (delFile [k]); // //} // //MainPage.Loading.Start ("正在搜索设备列表。。。"); // MainPage.Loading.Start ("Searching for existing Devices..."); // CommonPage.DeviceList.Clear (); // int countDevcie = 0; // //全部重新更新设备下面所有的回路信息 // if (th != null) { // th.Abort (); // th = null; // } // ReadDevices (() => { // MainPage.Loading.Hide (); // for (int i = 0; i < CommonPage.DeviceList.Count; i++) { // Common common = CommonPage.DeviceList [i]; // if (common.Type == DeviceType.MusicModel) // continue; // if (common.isMixBox) { // Console.WriteLine ("IsMixBox"); // continue; // } // countDevcie++; // } // notLoopCommons.Clear (); // notLoopCommons.AddRange (CommonPage.DeviceList); // th = new Thread ((obj) => { // Waiting = false; // CommonPage.DeviceLoopList.Clear (); // var listCommonEquipment = new List (); // listCommonEquipment.AddRange (notLoopCommons); // int progress = 0; // for (int i = 0; i < listCommonEquipment.Count; i++) { // var common = listCommonEquipment [i]; // if (common == null) // continue; // Application.RunOnMainThread (() => { // if(!common.isMixBox){ // progress++; // } // MainPage.Loading.Start ("Loading:" + common.Name + " ,Progress " + progress.ToString () + "/" + CommonPage.searchTotal.ToString ()); // }); // byte bigClass = common.BigClass; // byte minClass = common.MinClass; // int count = common.LoopCount; // for (int k = 1, j = 0; k <= count; k++) { // while (Waiting) { // Thread.Sleep (100); // } // if (Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, common.SubnetID, common.DeviceID, new byte [] { bigClass, minClass, (byte)k }) == null) { // j++; // //连续两次读取不到数据则跳出该循环 // if (j == 2 && k == 2) // break; // } else { // notLoopCommons.Remove (common); // } // } // } // th = null; // Application.RunOnMainThread (() => { // MainPage.Loading.Hide (); // if (gatewayDeicve.Type == DeviceType.OnePortWirelessFR && CommonPage.newDevice==0) { // CommonPage.newDevice = 0; // Control.ControlBytesSend (Command.GotoConfigMode, gatewayDeicve.SubnetID, gatewayDeicve.DeviceID, new byte [] { }); // //new Alert ("", "网关已经进入配频模式,请手动新设备进入配频模式。", "Close").Show (); // new Alert ("", "Searching for new devices, Please make sure all new devices are in configuration mode.", "OK").Show (); // this.AddChidren (myLoading); // //myLoading.Start ("点击屏幕关闭配频模式"); // myLoading.Start ("Searching, Please touch the here to exit the searching mode."); // this.AddChidren (btnCloseLoading); // } // }); // }); // th.Start (); // }); // } // static List notLoopCommons = new List (); // public static void InitSearchDeviceList (Common common, bool config = false) // { // if (curView == null || addedCommon == null) // return; // lock (addedCommon) { // if (addedCommon.Find ((obj)=>obj.Type == common.Type&& obj.CommonLoopID == common.CommonLoopID)!=null) // return; // addedCommon.Add (common); // if (common.SubnetID == gatewayDeicve.SubnetID) { // var deviceView = new RowLayout () { // Height = Application.GetRealHeight (110), // }; // bodyView.AddChidren (deviceView); // #region Show Device // var btnIndex = new Button () { // Width = Application.GetRealWidth (120), // TextColor = SkinStyle.Current.TextColor1, // TextAlignment = TextAlignment.Center, // Text = bodyView.ChildrenCount.ToString () // }; // deviceView.AddChidren (btnIndex); // var btnDeviceName = new Button () { // X = btnIndex.Right, // Text = common.Name, // TextAlignment = TextAlignment.CenterLeft, // Width = Application.GetRealWidth (342), // TextColor = SkinStyle.Current.TextColor1, // }; // deviceView.AddChidren (btnDeviceName); // //var btnDeviceOnline = new Button () { // // X = Application.GetRealWidth(500), // // Y = Application.GetRealHeight(70), // // Width = Application.GetRealWidth(100), // // Height = Application.GetRealHeight(40), // // TextSize = 12, // // Text = "Online", // // TextColor = 0xFF5DBA46, // // TextAlignment = TextAlignment.CenterLeft // //}; // //deviceView.AddChidren (btnDeviceOnline); // //if (!common.Online) { // // btnDeviceOnline.Text = "Offline"; // // btnDeviceOnline.TextColor = SkinStyle.Current.DelColor; // //} // EventHandler eHandler = (sender, e) => { // Dialog dialog = new Dialog (); // FrameLayout dialogBodyView = new FrameLayout () { // BackgroundColor = SkinStyle.Current.DialogColor, // Width = Application.GetRealWidth (494), // Height = Application.GetRealHeight (488), // Radius = 5, // BorderColor = SkinStyle.Current.Transparent, // BorderWidth = 0, // Gravity = Gravity.Center // }; // dialog.AddChidren (dialogBodyView); // Button btnEquipmentTitle = new Button () { // Height = Application.GetRealHeight (70), // TextAlignment = TextAlignment.Center, // Text = "Device Setting", // BackgroundColor = SkinStyle.Current.DialogTitle, // TextColor = SkinStyle.Current.TextColor1, // }; // dialogBodyView.AddChidren (btnEquipmentTitle); // Button lblChangeName = new Button () { // X = Application.GetRealWidth (40), // Y = btnEquipmentTitle.Bottom + Application.GetRealHeight (10), // Width = dialog.Width - 2 * btnEquipmentTitle.X, // Height = btnEquipmentTitle.Height, // TextID = R.MyInternationalizationString.EquipmentName, // TextAlignment = TextAlignment.CenterLeft, // TextColor = SkinStyle.Current.TextColor // }; // dialogBodyView.AddChidren (lblChangeName); // EditText btnChangeName = new EditText () { // X = lblChangeName.X, // Y = lblChangeName.Bottom + Application.GetRealHeight (10), // Width = Application.GetRealWidth (425), // Height = Application.GetRealHeight (50), // TextAlignment = TextAlignment.CenterLeft, // Text = " " + common.Name, // BorderColor = SkinStyle.Current.BorderColor, // BorderWidth = 1, // Radius = 5, // TextColor = SkinStyle.Current.TextColor, // }; // dialogBodyView.AddChidren (btnChangeName); // Button btnFindDevcie = new Button () { // Y = btnChangeName.Bottom + Application.GetRealHeight (50), // Gravity = Gravity.CenterHorizontal, // Width = Application.GetRealWidth (300), // Height = Application.GetRealHeight (70), // TextID = R.MyInternationalizationString.PositioningEquipment, // TextAlignment = TextAlignment.Center, // Radius = (uint)Application.GetRealHeight (5), // BackgroundColor = SkinStyle.Current.ButtonColor, // SelectedBackgroundColor = SkinStyle.Current.SelectedColor, // TextColor = SkinStyle.Current.TextColor1 // }; // dialogBodyView.AddChidren (btnFindDevcie); // btnFindDevcie.MouseDownEventHandler += (sender1, e1) => { // btnFindDevcie.IsSelected = true; // }; // btnFindDevcie.MouseUpEventHandler += (sender1, e1) => { // btnFindDevcie.IsSelected = false; // //查找设备,发送命令让设备闪烁,面板设备与其他设备发送的数据不一样,多了一个byte,固定为:0 // Control.ControlBytesSend (Command.PositioningEquipment, common.SubnetID, common.DeviceID, new byte [] { 5 }); // }; // //---bottom-- // Button btnBack = new Button () { // Width = Application.GetRealWidth (250), // Height = Application.GetRealHeight (85), // Y = Application.GetRealHeight (490 - 85), // BackgroundColor = SkinStyle.Current.DialogTitle, // TextID = R.MyInternationalizationString.Close, // TextColor = SkinStyle.Current.TextColor1 // }; // btnBack.MouseUpEventHandler += (s, e1) => { // dialog.Close (); // }; // dialogBodyView.AddChidren (btnBack); // Button btnLineV = new Button () { // Width = 1, // Height = btnBack.Height, // BackgroundColor = SkinStyle.Current.White20Transparent, // X = btnBack.Right, // Y = btnBack.Y, // }; // dialogBodyView.AddChidren (btnLineV); // Button btnSave = new Button () { // Width = Application.GetRealWidth (250), // Height = Application.GetRealHeight (85), // X = btnLineV.Right, // Y = btnBack.Y, // TextID = R.MyInternationalizationString.SAVE, // TextColor = SkinStyle.Current.TextColor1, // BackgroundColor = SkinStyle.Current.DialogTitle, // }; // dialogBodyView.AddChidren (btnSave); // btnSave.MouseUpEventHandler += (sender2, e2) => { // //CommonPage.UpdateRemark (common.SubnetID, common.DeviceID, btnChangeName.Text.Trim ()); // byte [] updateBytes = new byte [20]; // byte [] remakeBytes = CommonPage.MyEncodingGB2312.GetBytes (btnChangeName.Text.Trim ()); // Array.Copy (remakeBytes, 0, updateBytes, 0, remakeBytes.Length < 20 ? remakeBytes.Length : 20); // Control.ControlBytesSend (Command.Write_DeviceRamarkCMD, common.SubnetID, common.DeviceID, updateBytes); // btnDeviceName.Text = btnChangeName.Text; // dialog.Close (); // common.Name = btnChangeName.Text.Trim (); // IO.FileUtils.SaveEquipmentMessage (common); // }; // dialog.Show (); // }; // if (common.Type != DeviceType.InfraredMode) { // btnDeviceName.MouseUpEventHandler += eHandler; // } // var btnDelDevice = new Button () { // TextID = R.MyInternationalizationString.Del, // BackgroundColor = SkinStyle.Current.DelColor, // }; // deviceView.AddRightView (btnDelDevice); // btnDelDevice.MouseUpEventHandler += (sender, e) => { // Alert alert = new Alert ("", Language.StringByID (R.MyInternationalizationString.TipDeleteEquipmentMessage) // , Language.StringByID (R.MyInternationalizationString.Cancel), Language.StringByID (R.MyInternationalizationString.Confrim)); // alert.Show (); // alert.ResultEventHandler += ( sender1, e1) => { // if (e1) { // MainPage.Loading.Start ("Please wait..."); // System.Threading.Tasks.Task.Run (() => { // try { // var delRev = Control.ControlBytesSendHasReturn (Command.DelDeviceCMD, common.SubnetID, 0, new byte [] { 1, 0, 0, 0, 0, 0, 0, 0, 0, common.SubnetID, common.DeviceID }); // string delFlag = "_" + common.SubnetID + "_" + common.DeviceID; // var delFile = IO.FileUtils.ReadFiles ().FindAll ((w) => { // return w.Contains (delFlag); // }); // foreach (var roomToDelDevice in Room.Lists) { // var dett = roomToDelDevice.DeviceFilePathList.FindAll ((xxs) => { // return xxs.Contains (delFlag); // }); // if (dett != null) { // foreach (var delT in dett) { // roomToDelDevice.DeviceFilePathList.Remove (delT); // } // roomToDelDevice.Save (roomToDelDevice.RoomFilePath); // } // } // for (int i = 0; i < delFile.Count; i++) { // IO.FileUtils.DeleteFile (delFile [i]); // } // Application.RunOnMainThread (() => { // btnDelDevice.Parent.RemoveFromParent (); // }); // } catch (Exception ex) { // Console.WriteLine (ex.Message); // } finally { // Application.RunOnMainThread (() => { // MainPage.Loading.Hide (); // }); // } // }); // } // }; // }; // //if (common.Type == DeviceType.InfraredMode) { // // notLoopCommons = new List (); // // EventHandler mouseEvent = (sender, e) => { // // //new SystemEquipmentBase ().EquipmentBaseViewShow (common); // // var systemEquipmentBase = new GuideSettingInfraredModule (); // // systemEquipmentBase.Show (); // // systemEquipmentBase.EquipmentBaseViewShow (common); // // }; // // deviceView.MouseUpEventHandler += mouseEvent; // //} // if (config) { // CommonPage.newDevice++; // //System.Threading.Tasks.Task.Factory.StartNew (() => { // // try { // // byte bigClass = common.BigClass; // // byte minClass = common.MinClass; // // int count = common.LoopCount; // // for (int k = 1, j = 0; k <= count; k++) { // // if (Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, common.SubnetID, common.DeviceID, new byte [] { bigClass, minClass, (byte)k }) == null) { // // j++; // // //连续两次读取不到数据则跳出该循环 // // if (j == 2 && k == 2) // // break; // // } // // } // // } catch (Exception ex) { // // Console.WriteLine ("Cinfig Read Device Loop Info " + ex.Message); // // } // //}); // } // #endregion // } else { // CommonPage.searchTotal--; // } // } // } // Thread th; // //等待红外读取红外类型 // bool Waiting; // void ReadDevices (Action action) // { // new System.Threading.Thread (() => { // try { // //这里搜索设备,直到完成就退出 // readDevice (); // } catch (Exception ex) { // Console.WriteLine (ex.Message); // } // Application.RunOnMainThread (action); // }) { IsBackground = true }.Start (); // } // /// // /// 读取设备 // /// // void readDevice () // { // CommonPage.FindGateway = false; // CommonPage.FindGatewayChilren = true; // CommonPage.LocalPhoneFindDevice = true; // CommonPage.RandomHigh = (byte)new Random ().Next (255); // CommonPage.RandomLow = (byte)new Random ().Next (255); // CommonPage.DeviceList.Clear (); // CommonPage.searchTotal = 0; // //如果两次都没有数据反馈,就不读取 // int readCount = 4; // while (0 < readCount) { // readCount--; // var ms = new System.IO.MemoryStream (); // ms.WriteByte (CommonPage.RandomHigh); // ms.WriteByte (CommonPage.RandomLow); // var list = CommonPage.DeviceList; // int tempCount = list.Count; // string s = ";"; // for (int i = 0; i < list.Count; i++) { // Common common = list [i]; // if (common.SubnetID != gatewayDeicve.SubnetID) // continue; // if (s.Contains (";" + common.SubnetID.ToString () + ":" + common.DeviceID.ToString ())) // continue; // s += common.SubnetID.ToString () + ":" + common.DeviceID.ToString () + ";"; // ms.WriteByte (common.SubnetID); // ms.WriteByte (common.DeviceID); // } // Console.WriteLine ("搜索非网关设备,网络地址是:" + CommonPage.EndPoint.ToString ()); // var control = new Control (); // control.Send (new Target () { // IPEndPoint = CommonPage.EndPoint, // Command = Command.ReadDeviceModul, // SubnetID = gatewayDeicve.SubnetID, // DeviceID = 0xFF, // AddData = ms.ToArray () // }, SendCount.Zero, false); // ms.Close (); // System.Threading.Thread.Sleep (1000); // //如果数量不相等,就重置次数 // if (tempCount != CommonPage.DeviceList.Count) { // readCount = 4; // } // } // CommonPage.DeviceList = CommonPage.DeviceList.FindAll ((obj) => { return obj != null && obj.SubnetID == gatewayDeicve.SubnetID; }); // CommonPage.LocalPhoneFindDevice = false; // CommonPage.FindGatewayChilren = false; // } // } //}