| | |
| | | #region 显示 |
| | | int devcieCount = 0; |
| | | foreach (var room in Room.Lists) { |
| | | if (string.IsNullOrEmpty(room.Name)) { |
| | | if (string.IsNullOrEmpty (room.Name)) { |
| | | continue; |
| | | } |
| | | foreach (var common in room.DeviceList) { |
| | |
| | | }; |
| | | fanView.AddChidren (tempSiwtch); |
| | | tempSiwtch.MouseUpEventHandler += (sender3, e3) => { |
| | | tempSiwtch.IsSelected = !tempSiwtch.IsSelected; |
| | | if (tempSiwtch.IsSelected) { |
| | | fanModule.Switch = fanModule.WindSpeed; |
| | | } else { |
| | | fanModule.Switch = 0; |
| | | } |
| | | Control.ControlBytesSend (Command.SetSingleLight, fanModule.SubnetID, fanModule.DeviceID, new byte [] { fanModule.LoopID, fanModule.Switch }); |
| | | //tempSiwtch.IsSelected = !tempSiwtch.IsSelected; |
| | | //if (tempSiwtch.IsSelected) { |
| | | // fanModule.Switch = fanModule.WindSpeed; |
| | | //} else { |
| | | // fanModule.Switch = 0; |
| | | //} |
| | | //Control.ControlBytesSend (Command.SetSingleLight, fanModule.SubnetID, fanModule.DeviceID, new byte [] { fanModule.LoopID, fanModule.Switch }); |
| | | |
| | | //2020-02-10 |
| | | MainPage.Loading.Start ("Sending..."); |
| | | //tempSiwtch.IsSelected = !tempSiwtch.IsSelected; |
| | | //if (tempSiwtch.IsSelected) { |
| | | // fanModule.Switch = fanModule.WindSpeed; |
| | | //} else { |
| | | // fanModule.Switch = 0; |
| | | //} |
| | | |
| | | if (fanModule.WindSpeed == 0) fanModule.WindSpeed = 1; |
| | | |
| | | int mSetSwitch = tempSiwtch.IsSelected ? 0 : fanModule.WindSpeed; |
| | | |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | byte [] returnBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, fanModule.SubnetID, fanModule.DeviceID, new byte [] { fanModule.LoopID, (byte)mSetSwitch }); |
| | | Application.RunOnMainThread (() => { |
| | | if (returnBytes == null) { |
| | | //string tipString = Language.StringByID (R.MyInternationalizationString.ControlFailure); |
| | | new Alert ("", fanModule.Name + ErrorCode.ControlFailure, "Close").Show (); |
| | | |
| | | } |
| | | MainPage.Loading.Hide (); |
| | | }); |
| | | }); |
| | | }; |
| | | |
| | | Button btnViewNull = new Button () { |
| | |
| | | Application.RunOnMainThread (() => { |
| | | int brighingCount = 0; |
| | | foreach (var room in Room.Lists) { |
| | | if (string.IsNullOrEmpty(room.Name)) { |
| | | if (string.IsNullOrEmpty (room.Name)) { |
| | | continue; |
| | | } |
| | | foreach (var light in room.DeviceList) { |
| | |
| | | }); |
| | | #endregion |
| | | |
| | | if (curView == null || curView.bodyScrolView.Decelerating) { |
| | | return; |
| | | } |
| | | //if (curView == null || curView.bodyScrolView.Decelerating) { |
| | | // return; |
| | | //} |
| | | Application.RunOnMainThread (() => { |
| | | if (curView == null || curView.bodyScrolView.Decelerating) { |
| | | return; |
| | | } |
| | | for (int i = 0; i < curView.bodyScrolView.ChildrenCount; i++) { |
| | | if (curView.bodyScrolView.GetChildren (i).GetType () == typeof (FrameLayout)) { |
| | | var lightRow = (FrameLayout)curView.bodyScrolView.GetChildren (i); |
| | |
| | | |
| | | void ControlAllFan (bool open) |
| | | { |
| | | if (CommonPage.IsRemote) { |
| | | if (!SmartHome.MqttCommon.IsGatewayOnline) { |
| | | new Alert ("", "Gateway offline" + ErrorCode.ControlFailure, "Close").Show (); |
| | | return; |
| | | } |
| | | } |
| | | MainPage.Loading.Start ("Sending..."); |
| | | |
| | | bool showTip = true; |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | foreach (var room in Room.Lists) { |
| | | if (room == null) |
| | |
| | | if (string.IsNullOrEmpty (room.Name)) { |
| | | continue; |
| | | } |
| | | |
| | | foreach (var fanD in room.DeviceList) { |
| | | //2020-02-10 |
| | | byte [] returnBytes = null; |
| | | if (fanD.Type == DeviceType.FanModule) { |
| | | if (open) { |
| | | Control.ControlBytesSend (Command.SetSingleLight, fanD.SubnetID, fanD.DeviceID, new byte [] { fanD.LoopID, (fanD as FanModule).WindSpeed }); |
| | | |
| | | if ((fanD as FanModule).WindSpeed == 0) (fanD as FanModule).WindSpeed = 1; |
| | | |
| | | returnBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, fanD.SubnetID, fanD.DeviceID, new byte [] { fanD.LoopID, (fanD as FanModule).WindSpeed }); |
| | | } else { |
| | | Control.ControlBytesSend (Command.SetSingleLight, fanD.SubnetID, fanD.DeviceID, new byte [] { fanD.LoopID, 0 }); |
| | | returnBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, fanD.SubnetID, fanD.DeviceID, new byte [] { fanD.LoopID, 0 }); |
| | | } |
| | | |
| | | |
| | | if (showTip) { |
| | | if (returnBytes == null) { |
| | | Application.RunOnMainThread (() => { |
| | | |
| | | string tipString = Language.StringByID (R.MyInternationalizationString.ControlFailure); |
| | | var btnTip = new Button () { |
| | | Height = Application.GetRealHeight (140), |
| | | Text = fanD.Name + tipString,// + "..." + controlDeviceIndex.ToString () + @"/" + sceneDeviceCount.ToString (), |
| | | BackgroundColor = 0xFFD7D7D7, |
| | | }; |
| | | MainPage.MainFrameLayout.AddChidren (btnTip); |
| | | btnTip.MouseUpEventHandler += (sender, e) => { |
| | | btnTip.RemoveFromParent (); |
| | | //MainPage.MainFrameLayout.Remove (btnTip); |
| | | showTip = false; |
| | | }; |
| | | |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | System.Threading.Thread.Sleep (3000); |
| | | Application.RunOnMainThread (() => { |
| | | btnTip.RemoveFromParent (); |
| | | //MainPage.MainFrameLayout.Remove (btnTip); |
| | | }); |
| | | }); |
| | | |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | void ControlAllFanNew (bool open) |
| | | { |
| | | if (CommonPage.IsRemote) { |
| | | if (!SmartHome.MqttCommon.IsGatewayOnline) { |
| | | new Alert ("", "Gateway offline" + ErrorCode.ControlFailure, "Close").Show (); |
| | | return; |
| | | } |
| | | } |
| | | MainPage.Loading.Start ("Sending..."); |
| | | bool showTip = true; |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | int mSendCount = 0; |
| | | |
| | | foreach (var room in Room.Lists) { |
| | | if (room == null) |
| | | continue; |
| | | if (string.IsNullOrEmpty (room.Name)) { |
| | | continue; |
| | | } |
| | | |
| | | foreach (var fanD in room.DeviceList) { |
| | | //2020-02-10 |
| | | byte [] returnBytes = null; |
| | | if (fanD.Type == DeviceType.FanModule) { |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | mSendCount++; |
| | | if (open) { |
| | | returnBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, fanD.SubnetID, fanD.DeviceID, new byte [] { fanD.LoopID, (fanD as FanModule).WindSpeed }); |
| | | } else { |
| | | returnBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, fanD.SubnetID, fanD.DeviceID, new byte [] { fanD.LoopID, 0 }); |
| | | } |
| | | |
| | | |
| | | if (showTip) { |
| | | if (returnBytes == null) { |
| | | Application.RunOnMainThread (() => { |
| | | |
| | | string tipString = Language.StringByID (R.MyInternationalizationString.ControlFailure); |
| | | var btnTip = new Button () { |
| | | Height = Application.GetRealHeight (140), |
| | | Text = fanD.Name + tipString,// + "..." + controlDeviceIndex.ToString () + @"/" + sceneDeviceCount.ToString (), |
| | | BackgroundColor = 0xFFD7D7D7, |
| | | }; |
| | | MainPage.MainFrameLayout.AddChidren (btnTip); |
| | | btnTip.MouseUpEventHandler += (sender, e) => { |
| | | btnTip.RemoveFromParent (); |
| | | //MainPage.MainFrameLayout.Remove (btnTip); |
| | | showTip = false; |
| | | }; |
| | | |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | System.Threading.Thread.Sleep (3000); |
| | | Application.RunOnMainThread (() => { |
| | | btnTip.RemoveFromParent (); |
| | | //MainPage.MainFrameLayout.Remove (btnTip); |
| | | }); |
| | | }); |
| | | |
| | | }); |
| | | } |
| | | } |
| | | mSendCount--; |
| | | }); |
| | | |
| | | //等待100ms再发送第二个设备数据 |
| | | System.Threading.Thread.Sleep (100); |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | while (mSendCount > 0) { |
| | | System.Threading.Thread.Sleep (100); |
| | | } |
| | | |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | | }); |
| | | }); |
| | | } |
| | | } |
| | | } |