using System; 
 | 
using System.Collections.Generic; 
 | 
  
 | 
namespace Shared.SimpleControl.Phone 
 | 
{ 
 | 
    public class UserSensorAutomationPage : FrameLayout 
 | 
    { 
 | 
        SensorAutomationDevice autonmationDevice; 
 | 
        List<Common> SensorDeviceList; 
 | 
        VerticalScrolViewLayout bodyScrolView; 
 | 
  
 | 
        public UserSensorAutomationPage (List<Common> common) 
 | 
        { 
 | 
            autonmationDevice = new SensorAutomationDevice () { SubnetID = common [0].SubnetID, DeviceID = common [0].DeviceID }; 
 | 
            SensorDeviceList = common; 
 | 
        } 
 | 
  
 | 
  
 | 
  
 | 
        public void ShowPage () 
 | 
        { 
 | 
            BackgroundColor = SkinStyle.Current.ViewColor; 
 | 
            this.RemoveAll (); 
 | 
            #region 标题 
 | 
            var topView = new FrameLayout () { 
 | 
                Y = Application.GetRealHeight (36), 
 | 
                Height = Application.GetRealHeight (90), 
 | 
                BackgroundColor = SkinStyle.Current.MainColor 
 | 
            }; 
 | 
            AddChidren (topView); 
 | 
  
 | 
            var title = new Button () { 
 | 
                TextAlignment = TextAlignment.Center, 
 | 
                TextID = R.MyInternationalizationString.AutomationSetting, 
 | 
                TextColor = SkinStyle.Current.TextColor1, 
 | 
                TextSize = 19, 
 | 
            }; 
 | 
            topView.AddChidren (title); 
 | 
  
 | 
            Button ItemButton = new Button () { 
 | 
                Width = Application.GetRealWidth (55), 
 | 
                Height = Application.GetRealHeight (55), 
 | 
                UnSelectedImagePath = "Item/+.png", 
 | 
                SelectedImagePath = "Item/+.png", 
 | 
                Y = Application.GetRealHeight (17), 
 | 
                X = Application.GetRealWidth (640 - 80), 
 | 
            }; 
 | 
            topView.AddChidren (ItemButton); 
 | 
  
 | 
            ItemButton.MouseUpEventHandler += (sender, e) => { 
 | 
                Action<string> refLoad = (obj) => { 
 | 
                    InitAutomation (); 
 | 
                }; 
 | 
  
 | 
                var addSensorAutomation = new SensorAutomation (); 
 | 
                for (int i = 0; i < autonmationDevice.AutomationEnableList.Length; i++) { 
 | 
                    if (autonmationDevice.AutomationEnableList [i] == 255 || autonmationDevice.AutomationEnableList [i] == 0) { 
 | 
                        addSensorAutomation.AutomationId = (byte)i; 
 | 
                        addSensorAutomation.AutomationStatus = 0; 
 | 
                        break; 
 | 
                    } 
 | 
                }                 
 | 
                var uslp = new UserSensorAutomationSettingPage (SensorDeviceList, addSensorAutomation, autonmationDevice); 
 | 
                UserMiddle.DevicePageView.AddChidren (uslp); 
 | 
                uslp.ShowPage (refLoad); 
 | 
                UserMiddle.DevicePageView.PageIndex = UserMiddle.DevicePageView.ChildrenCount - 1; 
 | 
            }; 
 | 
  
 | 
            var back = new Button () { 
 | 
                Height = Application.GetRealHeight (90), 
 | 
                Width = Application.GetRealWidth (85), 
 | 
                UnSelectedImagePath = "Item/Back.png", 
 | 
                SelectedImagePath = "Item/BackSelected.png", 
 | 
            }; 
 | 
            topView.AddChidren (back); 
 | 
            back.MouseUpEventHandler += (sender, e) => { 
 | 
                (Parent as PageLayout).PageIndex -= 1; 
 | 
            }; 
 | 
            #endregion 
 | 
  
 | 
            bodyScrolView = new VerticalScrolViewLayout () { 
 | 
                Y = topView.Bottom, 
 | 
                Height = Application.GetRealHeight (1136 - 126) 
 | 
            }; 
 | 
            AddChidren (bodyScrolView); 
 | 
  
 | 
            InitAutomation (); 
 | 
        } 
 | 
  
 | 
  
 | 
  
 | 
        void InitAutomation () 
 | 
        { 
 | 
            bodyScrolView.RemoveAll (); 
 | 
            MainPage.Loading.Start ("Please wait..."); 
 | 
  
 | 
            System.Threading.Tasks.Task.Run (() => { 
 | 
  
 | 
                    var conditianEnableList = Control.ControlBytesSendHasReturn (Command.ReadSensorAutomationEnableList, autonmationDevice.SubnetID, autonmationDevice.DeviceID, new byte [] { }); 
 | 
                    var conditionIdList = Control.ControlBytesSendHasReturn (Command.ReadSensorAutomationListID, autonmationDevice.SubnetID, autonmationDevice.DeviceID, new byte [] { }); 
 | 
                     
 | 
                try {if (conditianEnableList == null || conditionIdList == null) { 
 | 
                        Application.RunOnMainThread (() => { 
 | 
                            new Alert ("", Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show (); 
 | 
                            MainPage.Loading.Hide (); 
 | 
                            (Parent as PageLayout).PageIndex -= 1; 
 | 
                        }); 
 | 
                        return; 
 | 
                    } 
 | 
                    this.autonmationDevice.ConditionIdList = conditionIdList; 
 | 
                    this.autonmationDevice.AutomationEnableList = conditianEnableList; 
 | 
  
 | 
                    for (int i = 0; i < this.autonmationDevice.sensorAutomationList.Count; i++) { 
 | 
                        var tempAutonmation = this.autonmationDevice.sensorAutomationList [i]; 
 | 
                        var targetNameBytes= Control.ControlBytesSendHasReturn (Command.ReadSensorAutomationName, autonmationDevice.SubnetID, autonmationDevice.DeviceID, new byte [] { tempAutonmation.AutomationId }); 
 | 
                        if(targetNameBytes.Length <21) 
 | 
                            continue; 
 | 
                        Application.RunOnMainThread (() => { 
 | 
                            //if (targetNameBytes == null) { 
 | 
                            //    new Alert ("", Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show (); 
 | 
                            //    return; 
 | 
                            //} 
 | 
                            tempAutonmation.AutomationName = CommonPage.MyEncodingGB2312.GetString (targetNameBytes, 1, 20).Trim ('\0'); 
 | 
                            var rowView = new RowLayout () { 
 | 
                                Height = Application.GetRealHeight (100), 
 | 
                                BackgroundColor = SkinStyle.Current.ViewColor, 
 | 
                            }; 
 | 
                            bodyScrolView.AddChidren (rowView); 
 | 
                            var btnPoint = new Button () { 
 | 
                                Width = Application.GetMinRealAverage (10), 
 | 
                                Height = Application.GetMinRealAverage (10), 
 | 
                                Radius = (uint)Application.GetMinRealAverage (5), 
 | 
                                X = Application.GetRealWidth (50), 
 | 
                                Gravity = Gravity.CenterVertical, 
 | 
                                BackgroundColor = SkinStyle.Current.TextColor1, 
 | 
                                SelectedBackgroundColor = SkinStyle.Current.SelectedColor, 
 | 
                                Tag = i 
 | 
                            }; 
 | 
                            rowView.AddChidren (btnPoint); 
 | 
                            var btnDeviceName = new Button () { 
 | 
                                Width = Application.GetRealWidth (300), 
 | 
                                X = Application.GetRealWidth (80), 
 | 
                                Text = tempAutonmation.AutomationName, 
 | 
                                TextColor = SkinStyle.Current.TextColor1, 
 | 
                                SelectedTextColor = SkinStyle.Current.SelectedColor, 
 | 
                                TextAlignment = TextAlignment.CenterLeft, 
 | 
                                Tag = i 
 | 
                            }; 
 | 
                            rowView.AddChidren (btnDeviceName); 
 | 
  
 | 
  
 | 
                            var tempSwitch = new Button () { 
 | 
                                Width = Application.GetMinRealAverage (90), 
 | 
                                Height = Application.GetMinRealAverage (53), 
 | 
                                X = Application.GetRealWidth (640 - 90 - 30), 
 | 
                                Gravity = Gravity.CenterVertical, 
 | 
                                IsSelected = tempAutonmation.AutomationStatus == 2 ? false : true, 
 | 
                                UnSelectedImagePath = "Item/SwitchClose.png", 
 | 
                                SelectedImagePath = "Item/SwitchOpen.png", 
 | 
                                Tag = tempAutonmation.AutomationId 
 | 
                            }; 
 | 
                            rowView.AddChidren (tempSwitch); 
 | 
  
 | 
                            tempSwitch.MouseUpEventHandler += (ddff, ffdd) => { 
 | 
                                tempSwitch.IsSelected = !tempSwitch.IsSelected; 
 | 
                                byte autoEnalbeByte = tempSwitch.IsSelected == true ? (byte)1 : (byte)2; 
 | 
                                MainPage.Loading.Start ("Please wait..."); 
 | 
                                System.Threading.Tasks.Task.Run (() => { 
 | 
                                    try { 
 | 
                                        var updateId = Convert.ToByte (((Button)ddff).Tag); 
 | 
                                        var delSensorAutomation = autonmationDevice.sensorAutomationList.Find ((obj) => obj.AutomationId == updateId);//根据自动化ID找到需要删除的自动化 
 | 
                                        if (delSensorAutomation == null) 
 | 
                                            return; 
 | 
                                        autonmationDevice.AutomationEnableList [updateId] = 2;//将自动化相应的使能改为无效 
 | 
  
 | 
                                        var conditianStatusListRevice = Control.ControlBytesSendHasReturn (Command.SetSensorAutomationEnableList, autonmationDevice.SubnetID, autonmationDevice.DeviceID, autonmationDevice.AutomationEnableList); 
 | 
                                    } catch (Exception ex) { 
 | 
                                        Utlis.WriteLine (ex.Message); 
 | 
                                    } finally { 
 | 
                                        Application.RunOnMainThread (() => { 
 | 
                                            MainPage.Loading.Hide (); 
 | 
                                            InitAutomation (); 
 | 
                                        }); 
 | 
                                    } 
 | 
                                }); 
 | 
                            }; 
 | 
  
 | 
                            var editor = new Button () { 
 | 
                                UnSelectedImagePath = "Item/EditInRightView.png", 
 | 
                                BackgroundColor = SkinStyle.Current.MainColor, 
 | 
                            }; 
 | 
                            rowView.AddRightView (editor); 
 | 
                            editor.MouseUpEventHandler += (sender, e) => { 
 | 
                                Action<string> refLoad = (obj) => { 
 | 
                                    btnDeviceName.Text = obj; 
 | 
                                }; 
 | 
                                var uslp = new UserSensorAutomationSettingPage (SensorDeviceList, tempAutonmation, autonmationDevice); 
 | 
                                UserMiddle.DevicePageView.AddChidren (uslp); 
 | 
                                uslp.ShowPage (refLoad); 
 | 
                                UserMiddle.DevicePageView.PageIndex = UserMiddle.DevicePageView.ChildrenCount - 1; 
 | 
                            }; 
 | 
  
 | 
                            var btnDel = new Button () { 
 | 
                                UnSelectedImagePath = "Item/DelInRightView.png", 
 | 
                                Tag = tempAutonmation.AutomationId 
 | 
                            }; 
 | 
                            rowView.AddRightView (btnDel); 
 | 
                            btnDel.MouseUpEventHandler += (ddff, ffdd) => { 
 | 
                                var delAlert = new Alert ("", Language.StringByID(R.MyInternationalizationString.ConfirmDelAutomation), Language.StringByID (R.MyInternationalizationString.cancel), Language.StringByID (R.MyInternationalizationString.confirm)); 
 | 
                                delAlert.Show (); 
 | 
                                delAlert.ResultEventHandler+= (ddaa,dde)=>{ 
 | 
                                    if (dde) { 
 | 
                                        MainPage.Loading.Start ("Please wait..."); 
 | 
                                        System.Threading.Tasks.Task.Run (() => { 
 | 
                                            try { 
 | 
                                                var delId = Convert.ToByte (((Button)ddff).Tag); 
 | 
                                                var delSensorAutomation = autonmationDevice.sensorAutomationList.Find ((obj) => obj.AutomationId == delId);//根据自动化ID找到需要删除的自动化 
 | 
                                                if (delSensorAutomation == null) 
 | 
                                                    return; 
 | 
                                                autonmationDevice.AutomationEnableList [delId] = 0;//将自动化相应的使能改为删除 
 | 
                                                for (int delIndex = 0; delIndex < 40; delIndex++) {//循环自动化包含的每一个触发条件 
 | 
                                                    //var delCondition = delSensorAutomation.sensorAutomationConditionList [delIndex]; 
 | 
                                                    ////读取自动化条件触发目标的使能数据 
 | 
                                                    //var automationTargetLevelEnable = Control.ControlBytesSendHasReturn (Command.ReadSensorAutomationLevelTargetEnable, autonmationDevice.SubnetID, autonmationDevice.DeviceID, new byte [] { delCondition.PushId }); 
 | 
                                                    //automationTargetLevelEnable [3 * delCondition.ConditionLevel + 1] = 0;//将对应的自动化条件触发的目标使能改为无效 
 | 
                                                    //automationTargetLevelEnable [3 * delCondition.ConditionLevel + 2] = 0; 
 | 
                                                    //automationTargetLevelEnable [3 * delCondition.ConditionLevel + 3] = 0; 
 | 
                                                    //var setAutomationTargetLevelEnable = Control.ControlBytesSendHasReturn (Command.SetSensorAutomationTargetLevelEnable, autonmationDevice.SubnetID, autonmationDevice.DeviceID, automationTargetLevelEnable); 
 | 
  
 | 
                                                    if(autonmationDevice.ConditionIdList [delIndex] == delId)//将自动化条件绑定的自动化删除 
 | 
                                                    { 
 | 
                                                        autonmationDevice.ConditionIdList [delIndex] = 255; 
 | 
                                                    } 
 | 
                                                } 
 | 
  
 | 
                                                var conditianStatusListRevice = Control.ControlBytesSendHasReturn (Command.SetSensorAutomationEnableList, autonmationDevice.SubnetID, autonmationDevice.DeviceID, autonmationDevice.AutomationEnableList); 
 | 
                                                var conditionIdListRevice = Control.ControlBytesSendHasReturn (Command.SetSensorAutomationListID, autonmationDevice.SubnetID, autonmationDevice.DeviceID, autonmationDevice.ConditionIdList); 
 | 
                                            } catch (Exception ex) { 
 | 
                                                Utlis.WriteLine (ex.Message); 
 | 
                                            } finally { 
 | 
                                                Application.RunOnMainThread (() => { 
 | 
                                                    MainPage.Loading.Hide (); 
 | 
                                                    InitAutomation (); 
 | 
                                                }); 
 | 
                                            } 
 | 
                                        }); 
 | 
                                    } 
 | 
                                }; 
 | 
                            }; 
 | 
                        }); 
 | 
                    } 
 | 
                } catch (Exception ex) { 
 | 
                    Utlis.WriteLine (ex.Message); 
 | 
                } finally { 
 | 
                    Application.RunOnMainThread (() => { 
 | 
                        MainPage.Loading.Hide (); 
 | 
                    }); 
 | 
                } 
 | 
            }); 
 | 
        } 
 | 
  
 | 
  
 | 
  
 | 
        public void ShowSceneListView (Sensor sensorDevice, byte targetLoop, VerticalScrolViewLayout sceneListView) 
 | 
        { 
 | 
            #region sceneList 
 | 
            ////全部类型的场景列表 
 | 
            //var allSceneFilePaths = new List<string> (); 
 | 
            ////全局场景中所有的场景 
 | 
            //var sceneFileList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (Scene.GlobalSceneFilePath))); 
 | 
            //allSceneFilePaths.AddRange (sceneFileList); 
 | 
            ////房间的所有场景 
 | 
            //foreach (var room in Room.Lists) { 
 | 
            //    if (string.IsNullOrEmpty (room.Name)) { 
 | 
            //        continue; 
 | 
            //    } 
 | 
            //    allSceneFilePaths.AddRange (room.SceneFilePathList); 
 | 
            //} 
 | 
  
 | 
            //int i = 0; 
 | 
            //foreach (var sceneFilePath in allSceneFilePaths) { 
 | 
            //    var scene = Scene.GetSceneByFilePath (sceneFilePath); 
 | 
            //    if (scene == null) { 
 | 
            //        continue; 
 | 
            //    } 
 | 
  
 | 
            //    var frameLayout = new RowLayout () { 
 | 
            //        Height = Application.GetRealHeight (115), 
 | 
            //    }; 
 | 
            //    sceneListView.AddChidren (frameLayout); 
 | 
  
 | 
            //    var btnRemarkName = new Button () { 
 | 
            //        Width = Application.GetRealWidth (420), 
 | 
            //        Height = LayoutParams.MatchParent, 
 | 
            //        Text = scene.Name, 
 | 
            //        TextAlignment = TextAlignment.CenterLeft, 
 | 
            //        X = Application.GetRealWidth (80), 
 | 
            //    }; 
 | 
            //    frameLayout.AddChidren (btnRemarkName); 
 | 
  
 | 
            //    int currentIndex = i; 
 | 
  
 | 
            //    EventHandler<MouseEventArgs> hander = (sender, e) => { 
 | 
            //        var tempScene = Newtonsoft.Json.JsonConvert.DeserializeObject<Scene> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (sceneFilePath))); 
 | 
  
 | 
            //        for (int j = 0; j < sceneListView.ChildrenCount; j++) { 
 | 
            //            var rowView = sceneListView.GetChildren (j); 
 | 
            //            if (rowView.GetType () == typeof (RowLayout)) { 
 | 
            //                if (currentIndex == j) { 
 | 
            //                    ((RowLayout)rowView).BackgroundImagePath = "DoorLockPic/door_lock_ scene_on.png"; 
 | 
            //                } else { 
 | 
            //                    ((RowLayout)rowView).BackgroundImagePath = "DoorLockPic/door_lock_ scene.png"; 
 | 
            //                } 
 | 
            //            } 
 | 
            //        } 
 | 
  
 | 
            //        Application.RunOnMainThread (() => { 
 | 
            //            MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.TargetsConfiguring) + "..."); 
 | 
            //        }); 
 | 
            //        System.Threading.Tasks.Task.Run (() => { 
 | 
            //            try { 
 | 
            //                var controlSceneBLL = new ScenePhoneMethod (); 
 | 
            //                int controlDeviceIndex = 0; 
 | 
            //                foreach (var deviceFilePath in tempScene.DeviceFilePathList) { 
 | 
            //                    if (!tempScene.busScene) { 
 | 
            //                        if (controlDeviceIndex > 19) { 
 | 
            //                            break; 
 | 
            //                        } 
 | 
  
 | 
            //                        var sendBytes = new byte [10]; 
 | 
            //                        sendBytes [0] = sensorDevice.DevicePushType;//开锁 
 | 
            //                        sendBytes [1] = targetLoop;//开锁类型   密码开锁 
 | 
            //                        sendBytes [2] = (byte)controlDeviceIndex; 
 | 
  
 | 
            //                        if (deviceFilePath.Split ('_') [1] == DeviceType.LightDimming.ToString ()) { 
 | 
            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightDimming> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath))); 
 | 
            //                            if (device == null) { 
 | 
            //                                continue; 
 | 
            //                            } 
 | 
            //                            sendBytes [3] = 0x59; 
 | 
            //                            sendBytes [4] = device.SubnetID; 
 | 
            //                            sendBytes [5] = device.DeviceID; 
 | 
            //                            sendBytes [6] = device.LoopID; 
 | 
            //                            sendBytes [7] = device.CurrentBrightness; 
 | 
            //                            sendBytes [8] = device.DelayTimeHeight; 
 | 
            //                            sendBytes [9] = device.DelayTimeLow; 
 | 
            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.LightDALI.ToString ()) { 
 | 
            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightDALI> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath))); 
 | 
            //                            if (device == null) { 
 | 
            //                                continue; 
 | 
            //                            } 
 | 
            //                            sendBytes [3] = 0x59; 
 | 
            //                            sendBytes [4] = device.SubnetID; 
 | 
            //                            sendBytes [5] = device.DeviceID; 
 | 
            //                            sendBytes [6] = device.LoopID; 
 | 
            //                            sendBytes [7] = device.CurrentBrightness; 
 | 
            //                            sendBytes [8] = device.DelayTimeHeight; 
 | 
            //                            sendBytes [9] = device.DelayTimeLow; 
 | 
            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.LightMixDimming.ToString ()) { 
 | 
            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightMixDimming> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath))); 
 | 
            //                            if (device == null) { 
 | 
            //                                continue; 
 | 
            //                            } 
 | 
            //                            sendBytes [3] = 0x59; 
 | 
            //                            sendBytes [4] = device.SubnetID; 
 | 
            //                            sendBytes [5] = device.DeviceID; 
 | 
            //                            sendBytes [6] = device.PhysicsLoopID; 
 | 
            //                            sendBytes [7] = device.CurrentBrightness; 
 | 
            //                            sendBytes [8] = device.DelayTimeHeight; 
 | 
            //                            sendBytes [9] = device.DelayTimeLow; 
 | 
            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.LightMixSwitch.ToString ()) { 
 | 
            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightMixSwitch> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath))); 
 | 
            //                            if (device == null) { 
 | 
            //                                continue; 
 | 
            //                            } 
 | 
            //                            sendBytes [3] = 0x59; 
 | 
            //                            sendBytes [4] = device.SubnetID; 
 | 
            //                            sendBytes [5] = device.DeviceID; 
 | 
            //                            sendBytes [6] = device.PhysicsLoopID; 
 | 
            //                            sendBytes [7] = device.CurrentBrightness; 
 | 
            //                            sendBytes [8] = device.DelayTimeHeight; 
 | 
            //                            sendBytes [9] = device.DelayTimeLow; 
 | 
            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.LightSwitch.ToString ()) { 
 | 
            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightSwitch> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath))); 
 | 
            //                            if (device == null) { 
 | 
            //                                continue; 
 | 
            //                            } 
 | 
            //                            sendBytes [3] = 0x59; 
 | 
            //                            sendBytes [4] = device.SubnetID; 
 | 
            //                            sendBytes [5] = device.DeviceID; 
 | 
            //                            sendBytes [6] = device.LoopID; 
 | 
            //                            sendBytes [7] = device.CurrentBrightness; 
 | 
            //                            sendBytes [8] = device.DelayTimeHeight; 
 | 
            //                            sendBytes [9] = device.DelayTimeLow; 
 | 
            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.LightEnergySwitch.ToString ()) { 
 | 
            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightEnergySwitch> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath))); 
 | 
            //                            if (device == null) { 
 | 
            //                                continue; 
 | 
            //                            } 
 | 
            //                            sendBytes [3] = 0x59; 
 | 
            //                            sendBytes [4] = device.SubnetID; 
 | 
            //                            sendBytes [5] = device.DeviceID; 
 | 
            //                            sendBytes [6] = device.LoopID; 
 | 
            //                            sendBytes [7] = device.CurrentBrightness; 
 | 
            //                            sendBytes [8] = device.DelayTimeHeight; 
 | 
            //                            sendBytes [9] = device.DelayTimeLow; 
 | 
            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.FanModule.ToString ()) { 
 | 
            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<FanModule> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath))); 
 | 
            //                            if (device == null) { 
 | 
            //                                continue; 
 | 
            //                            } 
 | 
            //                            sendBytes [3] = 0x59; 
 | 
            //                            sendBytes [4] = device.SubnetID; 
 | 
            //                            sendBytes [5] = device.DeviceID; 
 | 
            //                            sendBytes [6] = device.LoopID; 
 | 
            //                            sendBytes [7] = (byte)device.WindSpeed; 
 | 
            //                            //if (sceneControl (device, sendBytes, btnEditedName, btnRemarkName, sender, sceneFilePath)) { 
 | 
            //                            //    result = true; 
 | 
            //                            //} 
 | 
            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.CurtainModel.ToString ()) { 
 | 
            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainModel> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath))); 
 | 
            //                            if (device == null) { 
 | 
            //                                continue; 
 | 
            //                            } 
 | 
            //                            sendBytes [3] = 0x5C; 
 | 
            //                            sendBytes [4] = device.SubnetID; 
 | 
            //                            sendBytes [5] = device.DeviceID; 
 | 
            //                            sendBytes [6] = device.LoopID; 
 | 
            //                            sendBytes [7] = (byte)device.Status; 
 | 
            //                            //if (sceneControl (device, sendBytes, btnEditedName, btnRemarkName, sender, sceneFilePath)) { 
 | 
            //                            //    result = true; 
 | 
            //                            //} 
 | 
            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.CurtainRoller.ToString ()) { 
 | 
            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainRoller> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath))); 
 | 
            //                            if (device == null) { 
 | 
            //                                continue; 
 | 
            //                            } 
 | 
            //                            sendBytes [3] = 0x5C; 
 | 
            //                            sendBytes [4] = device.SubnetID; 
 | 
            //                            sendBytes [5] = device.DeviceID; 
 | 
            //                            sendBytes [6] = device.LoopID; 
 | 
            //                            sendBytes [7] = (byte)device.Status; 
 | 
            //                            //if (sceneControl (device, sendBytes, btnEditedName, btnRemarkName, sender, sceneFilePath)) { 
 | 
            //                            //    result = true; 
 | 
            //                            //} 
 | 
            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.CurtainTrietex.ToString ()) { 
 | 
            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainTrietex> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath))); 
 | 
            //                            if (device == null) { 
 | 
            //                                continue; 
 | 
            //                            } 
 | 
            //                            sendBytes [3] = 0x5C; 
 | 
            //                            sendBytes [4] = device.SubnetID; 
 | 
            //                            sendBytes [5] = device.DeviceID; 
 | 
            //                            sendBytes [6] = device.LoopID; 
 | 
            //                            sendBytes [7] = (byte)device.Status; 
 | 
            //                            //if (sceneControl (device, sendBytes, btnEditedName, btnRemarkName, sender, sceneFilePath)) { 
 | 
            //                            //    result = true; 
 | 
            //                            //} 
 | 
            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.LogicModule.ToString ()) { 
 | 
            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LogicModule> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath))); 
 | 
            //                            if (device == null) { 
 | 
            //                                continue; 
 | 
            //                            } 
 | 
            //                            sendBytes [3] = 0x55; 
 | 
            //                            sendBytes [4] = device.SubnetID; 
 | 
            //                            sendBytes [5] = device.DeviceID; 
 | 
            //                            sendBytes [6] = device.AreaID; 
 | 
            //                            sendBytes [7] = device.AreaSceneID; 
 | 
            //                        } else if (deviceFilePath.Split ('_') [1] == DeviceType.UniversalDevice.ToString ()) { 
 | 
            //                            var device = Newtonsoft.Json.JsonConvert.DeserializeObject<UniversalDevice> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath))); 
 | 
            //                            if (device == null) { 
 | 
            //                                continue; 
 | 
            //                            } 
 | 
            //                            if (device.UniversalType == 0xE01C) { 
 | 
            //                                sendBytes [3] = 0x58; 
 | 
            //                                sendBytes [4] = device.SubnetID; 
 | 
            //                                sendBytes [5] = device.DeviceID; 
 | 
            //                                sendBytes [6] = 0 < device.SendBytes.Count ? device.SendBytes [0] : (byte)0; 
 | 
            //                                sendBytes [7] = 1 < device.SendBytes.Count ? device.SendBytes [1] : (byte)0; 
 | 
            //                                //if (!sceneControl (device, sendBytes, btnEditedName, btnRemarkName, sender, sceneFilePath)) { 
 | 
            //                                //    result = true; 
 | 
            //                                //} 
 | 
            //                            } 
 | 
            //                        } else { 
 | 
            //                            continue; 
 | 
            //                        } 
 | 
            //                        controlSceneBLL.ControlSceneDevice (deviceFilePath, controlDeviceIndex, 20); 
 | 
            //                    } else { 
 | 
            //                        var device = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath))); 
 | 
            //                        var sendBytes = new byte [10]; 
 | 
            //                        sendBytes [0] = sensorDevice.DevicePushType; 
 | 
            //                        sendBytes [1] = targetLoop; 
 | 
            //                        sendBytes [2] = (byte)controlDeviceIndex; 
 | 
            //                        sendBytes [3] = device.obj1; 
 | 
            //                        sendBytes [4] = device.SubnetID; 
 | 
            //                        sendBytes [5] = device.DeviceID; 
 | 
            //                        sendBytes [6] = device.obj2; 
 | 
            //                        sendBytes [7] = device.obj3; 
 | 
            //                        sendBytes [8] = device.obj4; 
 | 
            //                        sendBytes [9] = device.obj5; 
 | 
            //                        controlSceneBLL.ControlBusSceneDevice (device); 
 | 
            //                    } 
 | 
            //                    controlDeviceIndex++; 
 | 
            //                } 
 | 
            //            } catch { } finally { 
 | 
            //                Application.RunOnMainThread (() => { 
 | 
            //                    MainPage.Loading.Hide (); 
 | 
            //                }); 
 | 
            //            } 
 | 
            //        }); 
 | 
            //    }; 
 | 
  
 | 
            //    frameLayout.MouseUpEventHandler += hander; 
 | 
            //    btnRemarkName.MouseUpEventHandler += hander; 
 | 
            //    i++; 
 | 
            //} 
 | 
            #endregion 
 | 
  
 | 
        } 
 | 
  
 | 
    } 
 | 
} 
 |