| | |
| | | curtainView.AddChidren (btnCloseCurtain); |
| | | |
| | | btnCloseCurtain.MouseDownEventHandler += (sender3, e3) => { |
| | | Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainmodel.SubnetID, curtainmodel.DeviceID, new byte [] { curtainmodel.LoopID, 2 }); |
| | | |
| | | //Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainmodel.SubnetID, curtainmodel.DeviceID, new byte [] { curtainmodel.LoopID, 2 }); |
| | | (sender3 as Button).IsSelected = true; |
| | | SendControlUpdataCurtain (curtainmodel, new byte [] { curtainmodel.LoopID, 2 }); |
| | | }; |
| | | btnCloseCurtain.MouseUpEventHandler += (sender3, e3) => { |
| | | (sender3 as Button).IsSelected = false; |
| | | }; |
| | | btnOpenCurtain.MouseDownEventHandler += (sender3, e3) => { |
| | | Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainmodel.SubnetID, curtainmodel.DeviceID, new byte [] { curtainmodel.LoopID, 1 }); |
| | | //Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainmodel.SubnetID, curtainmodel.DeviceID, new byte [] { curtainmodel.LoopID, 1 }); |
| | | (sender3 as Button).IsSelected = true; |
| | | SendControlUpdataCurtain (curtainmodel, new byte [] { curtainmodel.LoopID, 1 }); |
| | | }; |
| | | btnOpenCurtain.MouseUpEventHandler += (sender3, e3) => { |
| | | (sender3 as Button).IsSelected = false; |
| | | }; |
| | | btnStopCurtain.MouseDownEventHandler += (sender3, e3) => { |
| | | Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainmodel.SubnetID, curtainmodel.DeviceID, new byte [] { curtainmodel.LoopID, 0 }); |
| | | //Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainmodel.SubnetID, curtainmodel.DeviceID, new byte [] { curtainmodel.LoopID, 0 }); |
| | | (sender3 as Button).IsSelected = true; |
| | | SendControlUpdataCurtain (curtainmodel, new byte [] { curtainmodel.LoopID, 0 }); |
| | | }; |
| | | btnStopCurtain.MouseUpEventHandler += (sender3, e3) => { |
| | | (sender3 as Button).IsSelected = false; |
| | |
| | | curtainView.AddChidren (btnCloseCurtain); |
| | | |
| | | btnCloseCurtain.MouseDownEventHandler += (sender3, e3) => { |
| | | Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainroller.SubnetID, curtainroller.DeviceID, new byte [] { 1, 2 }); |
| | | //Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainroller.SubnetID, curtainroller.DeviceID, new byte [] { 1, 2 }); |
| | | (sender3 as Button).IsSelected = true; |
| | | SendControlUpdataCurtain (curtainroller, new byte [] { 1, 2 }); |
| | | }; |
| | | btnCloseCurtain.MouseUpEventHandler += (sender3, e3) => { |
| | | (sender3 as Button).IsSelected = false; |
| | | }; |
| | | btnOpenCurtain.MouseDownEventHandler += (sender3, e3) => { |
| | | Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainroller.SubnetID, curtainroller.DeviceID, new byte [] { 1, 1 }); |
| | | //Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainroller.SubnetID, curtainroller.DeviceID, new byte [] { 1, 1 }); |
| | | (sender3 as Button).IsSelected = true; |
| | | SendControlUpdataCurtain (curtainroller, new byte [] { 1, 1 }); |
| | | }; |
| | | btnOpenCurtain.MouseUpEventHandler += (sender3, e3) => { |
| | | (sender3 as Button).IsSelected = false; |
| | | }; |
| | | btnStopCurtain.MouseDownEventHandler += (sender3, e3) => { |
| | | Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainroller.SubnetID, curtainroller.DeviceID, new byte [] { 1, 0 }); |
| | | //Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtainroller.SubnetID, curtainroller.DeviceID, new byte [] { 1, 0 }); |
| | | (sender3 as Button).IsSelected = true; |
| | | SendControlUpdataCurtain (curtainroller, new byte [] { 1, 0 }); |
| | | }; |
| | | btnStopCurtain.MouseUpEventHandler += (sender3, e3) => { |
| | | (sender3 as Button).IsSelected = false; |
| | |
| | | curtainView.AddChidren (btnCloseCurtain); |
| | | |
| | | btnCloseCurtain.MouseDownEventHandler += (sender3, e3) => { |
| | | Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtaintrietex.SubnetID, curtaintrietex.DeviceID, new byte [] { 1, 2 }); |
| | | //Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtaintrietex.SubnetID, curtaintrietex.DeviceID, new byte [] { 1, 2 }); |
| | | (sender3 as Button).IsSelected = true; |
| | | SendControlUpdataCurtain (curtaintrietex, new byte [] { 1, 2 }); |
| | | }; |
| | | btnCloseCurtain.MouseUpEventHandler += (sender3, e3) => { |
| | | (sender3 as Button).IsSelected = false; |
| | | }; |
| | | btnOpenCurtain.MouseDownEventHandler += (sender3, e3) => { |
| | | Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtaintrietex.SubnetID, curtaintrietex.DeviceID, new byte [] { 1, 1 }); |
| | | //Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtaintrietex.SubnetID, curtaintrietex.DeviceID, new byte [] { 1, 1 }); |
| | | (sender3 as Button).IsSelected = true; |
| | | SendControlUpdataCurtain (curtaintrietex, new byte [] { 1, 1 }); |
| | | }; |
| | | btnOpenCurtain.MouseUpEventHandler += (sender3, e3) => { |
| | | (sender3 as Button).IsSelected = false; |
| | | }; |
| | | btnStopCurtain.MouseDownEventHandler += (sender3, e3) => { |
| | | Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtaintrietex.SubnetID, curtaintrietex.DeviceID, new byte [] { 1, 0 }); |
| | | //Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtaintrietex.SubnetID, curtaintrietex.DeviceID, new byte [] { 1, 0 }); |
| | | (sender3 as Button).IsSelected = true; |
| | | SendControlUpdataCurtain (curtaintrietex, new byte [] { 1, 0 }); |
| | | }; |
| | | btnStopCurtain.MouseUpEventHandler += (sender3, e3) => { |
| | | (sender3 as Button).IsSelected = false; |
| | |
| | | } |
| | | } |
| | | |
| | | bool showTip = true; |
| | | /// <summary> |
| | | /// 控制所有窗帘 |
| | | /// </summary> |
| | | /// <param name="status">1:开,2:关.</param> |
| | | void controlAllCurtain (byte status) |
| | | { |
| | | if (CommonPage.IsRemote) { |
| | | if (!SmartHome.MqttCommon.IsGatewayOnline) { |
| | | new Alert ("", "Gateway offline" + ErrorCode.ControlFailure, "Close").Show (); |
| | | return; |
| | | } |
| | | } |
| | | showTip = true; |
| | | MainPage.Loading.Start ("Sending..."); |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | foreach (var room in Room.Lists) { |
| | | if (room == null) |
| | |
| | | continue; |
| | | } |
| | | foreach (var common in room.DeviceList) { |
| | | //2020-02-10 |
| | | byte [] returnBytes = null; |
| | | if (common.Type == DeviceType.CurtainModel) { |
| | | var curtainmodel = common as CurtainModel; |
| | | Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtainmodel.SubnetID, curtainmodel.DeviceID, new byte [] { curtainmodel.LoopID, status }); |
| | | returnBytes = Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtainmodel.SubnetID, curtainmodel.DeviceID, new byte [] { curtainmodel.LoopID, status }); |
| | | } else if (common.Type == DeviceType.CurtainRoller) { |
| | | var curtainroller = common as CurtainRoller; |
| | | Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtainroller.SubnetID, curtainroller.DeviceID, new byte [] { curtainroller.LoopID, status }); |
| | | returnBytes = Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtainroller.SubnetID, curtainroller.DeviceID, new byte [] { curtainroller.LoopID, status }); |
| | | } else if (common.Type == DeviceType.CurtainTrietex) { |
| | | var curtaintrietex = common as CurtainTrietex; |
| | | Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtaintrietex.SubnetID, curtaintrietex.DeviceID, new byte [] { curtaintrietex.LoopID, status }); |
| | | returnBytes = Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, curtaintrietex.SubnetID, curtaintrietex.DeviceID, new byte [] { curtaintrietex.LoopID, status }); |
| | | } else { |
| | | continue; |
| | | } |
| | | |
| | | if (showTip) { |
| | | if (returnBytes == null) { |
| | | Application.RunOnMainThread (() => { |
| | | |
| | | string tipString = ErrorCode.ControlFailure; |
| | | var btnTip = new Button () { |
| | | Height = Application.GetRealHeight (140), |
| | | Text = common.Name + tipString,// + "..." + controlDeviceIndex.ToString () + @"/" + sceneDeviceCount.ToString (), |
| | | BackgroundColor = 0xFFD7D7D7, |
| | | }; |
| | | MainPage.MainFrameLayout.AddChidren (btnTip); |
| | | btnTip.MouseUpEventHandler += (sender, e) => { |
| | | btnTip.RemoveFromParent (); |
| | | showTip = false; |
| | | }; |
| | | |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | System.Threading.Thread.Sleep (3000); |
| | | Application.RunOnMainThread (() => { |
| | | btnTip.RemoveFromParent (); |
| | | }); |
| | | }); |
| | | |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// //2020-02-10 带返回结果的修改窗帘状态 |
| | | /// </summary> |
| | | /// <param name="mLightCommon"></param> |
| | | /// <param name="sendBytes"></param> |
| | | public static void SendControlUpdataCurtain (Common mCurtainCommon, byte [] sendBytes) |
| | | { |
| | | MainPage.Loading.Start ("Sending..."); |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | byte [] returnBytes = Control.ControlBytesSendHasReturn (Command.UpdataCurtainModelStutas, mCurtainCommon.SubnetID, mCurtainCommon.DeviceID, sendBytes); |
| | | Application.RunOnMainThread (() => { |
| | | if (returnBytes == null) { |
| | | new Alert ("", mCurtainCommon.Name + ErrorCode.ControlFailure, "Close").Show (); |
| | | } |
| | | MainPage.Loading.Hide (); |
| | | }); |
| | | }); |
| | | } |
| | | |