| | |
| | | }; |
| | | var btnAddLightScene = new Button () { |
| | | Width = Application.GetRealWidth (100), |
| | | Height = Application.GetRealHeight (100), |
| | | Height = Application.GetRealWidth (100), |
| | | X = Application.GetRealWidth (640 - 120), |
| | | Y = Application.GetRealHeight (20), |
| | | UnSelectedImagePath = "Light/UserLightAddScene.png", |
| | |
| | | }; |
| | | Button btnSIcon = new Button () { |
| | | Width = Application.GetRealWidth(111), |
| | | Height = Application.GetRealHeight(110), |
| | | Height = Application.GetRealWidth(110), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = scene.SceneIconPath, |
| | | SelectedImagePath = scene.SceneIconPath, |
| | |
| | | |
| | | btnSceneRemark.MouseUpEventHandler += (sender, e) => { |
| | | try { |
| | | if (CommonPage.IsRemote) { |
| | | if (!SmartHome.MqttCommon.IsGatewayOnline) { |
| | | new Alert ("", "Gateway offline" + ErrorCode.ControlFailure, "Close").Show (); |
| | | return; |
| | | } |
| | | } |
| | | btnLastClickScene.RemoveFromParent (); |
| | | lightSceneView.AddChidren (btnLastClickScene); |
| | | MainPage.Loading.Start (); |
| | | //MainPage.Loading.Start (); |
| | | MainPage.Loading.Start ("Sending..."); |
| | | int controlDeviceIndex = 0; |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | foreach (var deviceFilePath in scene.DeviceFilePathList) { |
| | | 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) { |
| | |
| | | } |
| | | } |
| | | } |
| | | Control.ControlBytesSendHasReturn (Command.SetSingleLight, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, device.CurrentBrightness, 0, delayTime }); |
| | | byte [] returnBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, device.CurrentBrightness, 0, delayTime }); |
| | | ShowErrorTip (returnBytes, device, "..." + controlDeviceIndex.ToString () + @"/" + scene.DeviceFilePathList.Count.ToString ()); |
| | | } 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; |
| | | } |
| | | Control.ControlBytesSendHasReturn (Command.SetSingleLight, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, device.CurrentBrightness, 0, 0 }); |
| | | byte [] returnBytes = Control.ControlBytesSendHasReturn (Command.SetSingleLight, device.SubnetID, device.DeviceID, new byte [] { device.LoopID, device.CurrentBrightness, 0, 0 }); |
| | | ShowErrorTip (returnBytes, device, "..." + controlDeviceIndex.ToString () + @"/" + scene.DeviceFilePathList.Count.ToString ()); |
| | | } else if (deviceFilePath.Split ('_') [1] == DeviceType.LightLogic.ToString ()) { |
| | | var device = Newtonsoft.Json.JsonConvert.DeserializeObject<LightLogic> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath))); |
| | | if (device != null) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | | }); |
| | | }); |
| | | } catch { } finally { |
| | | } catch { |
| | | MainPage.Loading.Hide (); |
| | | } finally { |
| | | //MainPage.Loading.Hide (); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | | |
| | | void ShowErrorTip (byte[] replyBytes, Common mCommon, string mes) |
| | | { |
| | | try { |
| | | |
| | | if (replyBytes == null) { |
| | | Application.RunOnMainThread (() => { |
| | | string tipString = Language.StringByID (R.MyInternationalizationString.ControlFailure); |
| | | var btnTip = new Button () { |
| | | Height = Application.GetRealHeight (140), |
| | | Text = mCommon.Name + tipString + mes, |
| | | BackgroundColor = SkinStyle.Current.TitileView, |
| | | }; |
| | | MainPage.MainFrameLayout.AddChidren (btnTip); |
| | | btnTip.MouseUpEventHandler += (sender, e) => { |
| | | btnTip.RemoveFromParent (); |
| | | }; |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | System.Threading.Thread.Sleep (3000); |
| | | Application.RunOnMainThread (() => { |
| | | btnTip.RemoveFromParent (); |
| | | }); |
| | | }); |
| | | |
| | | }); |
| | | } |
| | | } catch { } |
| | | |
| | | } |
| | | |
| | | void LightSceneDialog (Scene scene = null) |
| | |
| | | }; |
| | | lightView.AddTag ("UpdataKey", common.CommonLoopID); |
| | | lightListView.AddChidren (lightView); |
| | | Button BtnLightViewNull = new Button () { |
| | | Y = Application.GetRealHeight(127), |
| | | Height = Application.GetRealHeight(3), |
| | | Button BtnLightViewNull = new Button () { |
| | | Y = Application.GetRealHeight (127), |
| | | Height = Application.GetRealHeight (3), |
| | | BackgroundColor = SkinStyle.Current.MainColor, |
| | | SelectedBackgroundColor = SkinStyle.Current.MainColor, |
| | | }; |
| | |
| | | lightView.AddChidren (tempLightName); |
| | | |
| | | var tempSiwtch = new Button () { |
| | | Width = Application.GetRealWidth (85), |
| | | Height = Application.GetRealHeight (53), |
| | | Width = Application.GetMinRealAverage (85), |
| | | Height = Application.GetMinRealAverage (53), |
| | | X = Application.GetRealWidth (640 - 90 - 20), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "Item/SwitchClose.png", |
| | |
| | | }; |
| | | lightView.AddChidren (tempSiwtch); |
| | | tempSiwtch.MouseUpEventHandler += (sender3, e3) => { |
| | | tempSiwtch.IsSelected = !tempSiwtch.IsSelected; |
| | | if (tempSiwtch.IsSelected) { |
| | | lightSwitch.CurrentBrightness = 100; |
| | | } else { |
| | | lightSwitch.CurrentBrightness = 0; |
| | | } |
| | | //tempSiwtch.IsSelected = !tempSiwtch.IsSelected; |
| | | //if (tempSiwtch.IsSelected) { |
| | | // lightSwitch.CurrentBrightness = 100; |
| | | //} else { |
| | | // lightSwitch.CurrentBrightness = 0; |
| | | //} |
| | | int mSetBrightness = tempSiwtch.IsSelected ? 0 : 100; |
| | | if (lightSwitch.Type == DeviceType.LightMixSwitch) { |
| | | Control.ControlBytesSend (Command.SetSingleLight, lightSwitch.SubnetID, lightSwitch.DeviceID, new byte [] { (lightSwitch as LightMixSwitch).PhysicsLoopID, (byte)lightSwitch.CurrentBrightness, lightSwitch.DelayTimeHeight, lightSwitch.DelayTimeLow }); |
| | | } else |
| | | Control.ControlBytesSend (Command.SetSingleLight, lightSwitch.SubnetID, lightSwitch.DeviceID, new byte [] { lightSwitch.LoopID, lightSwitch.CurrentBrightness, lightSwitch.DelayTimeHeight, lightSwitch.DelayTimeLow }); |
| | | SendControl.SendControlSetSingleLight (lightSwitch, new byte [] { (lightSwitch as LightMixSwitch).PhysicsLoopID, (byte)mSetBrightness, lightSwitch.DelayTimeHeight, lightSwitch.DelayTimeLow }); |
| | | //Control.ControlBytesSend (Command.SetSingleLight, lightSwitch.SubnetID, lightSwitch.DeviceID, new byte [] { (lightSwitch as LightMixSwitch).PhysicsLoopID, (byte)lightSwitch.CurrentBrightness, lightSwitch.DelayTimeHeight, lightSwitch.DelayTimeLow }); |
| | | } else { |
| | | //Control.ControlBytesSend (Command.SetSingleLight, lightSwitch.SubnetID, lightSwitch.DeviceID, new byte [] { lightSwitch.LoopID, lightSwitch.CurrentBrightness, lightSwitch.DelayTimeHeight, lightSwitch.DelayTimeLow }); |
| | | SendControl.SendControlSetSingleLight (lightSwitch, new byte [] { lightSwitch.LoopID, (byte)mSetBrightness, lightSwitch.DelayTimeHeight, lightSwitch.DelayTimeLow }); |
| | | |
| | | } |
| | | }; |
| | | |
| | | if (lightSwitch.CurrentBrightness == 100) { |
| | |
| | | }; |
| | | //开关按键 |
| | | var tempSwitch = new Button () { |
| | | Width = Application.GetRealWidth (90), |
| | | Height = Application.GetRealHeight (53), |
| | | Width = Application.GetMinRealAverage (90), |
| | | Height = Application.GetMinRealAverage (53), |
| | | X = Application.GetRealWidth (640 - 90 - 20), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "Item/SwitchClose.png", |
| | |
| | | tempLightSeekBar.AddTag ("UpdataKey", lightDimming.CommonLoopID); |
| | | |
| | | tempSwitch.MouseUpEventHandler += (sender3, e3) => { |
| | | tempSwitch.IsSelected = !tempSwitch.IsSelected; |
| | | //tempSwitch.IsSelected = !tempSwitch.IsSelected; |
| | | if (lightDimming.LastOpenBrightness == 0) { |
| | | lightDimming.LastOpenBrightness = 100; |
| | | } |
| | | if (tempSwitch.IsSelected) { |
| | | tempLightSeekBar.Progress = lightDimming.LastOpenBrightness; |
| | | IO.FileUtils.WriteFileByBytes ("Equipment_" + typeof (LightDimming).Name + "_" + lightDimming.SubnetID.ToString () + "_" + lightDimming.DeviceID.ToString () + "_" + (lightDimming.LoopID < 10 ? "0" + lightDimming.LoopID.ToString () : lightDimming.LoopID.ToString ()), |
| | | CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (lightDimming))); |
| | | } else { |
| | | tempLightSeekBar.Progress = 0; |
| | | } |
| | | lightDimming.CurrentBrightness = (byte)tempLightSeekBar.Progress; |
| | | //if (!tempSwitch.IsSelected) { |
| | | // lightDimming.CurrentBrightness = lightDimming.LastOpenBrightness; |
| | | // //tempLightSeekBar.Progress = lightDimming.LastOpenBrightness; |
| | | // IO.FileUtils.WriteFileByBytes ("Equipment_" + typeof (LightDimming).Name + "_" + lightDimming.SubnetID.ToString () + "_" + lightDimming.DeviceID.ToString () + "_" + (lightDimming.LoopID < 10 ? "0" + lightDimming.LoopID.ToString () : lightDimming.LoopID.ToString ()), |
| | | // CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (lightDimming))); |
| | | //} else { |
| | | // //tempLightSeekBar.Progress = 0; |
| | | // lightDimming.CurrentBrightness = 0; |
| | | //} |
| | | //lightDimming.CurrentBrightness = (byte)tempLightSeekBar.Progress; |
| | | |
| | | int mSetBrightness = tempSwitch.IsSelected ? 0 : lightDimming.LastOpenBrightness; |
| | | byte delayHeight = 0; |
| | | byte delayLow = 0; |
| | | if (lightDimming.CurrentBrightness == 0) { |
| | | if (mSetBrightness == 0) { |
| | | delayHeight = Convert.ToByte (lightDimming.CustomDelayTimeClose / 256); |
| | | delayLow = Convert.ToByte (lightDimming.CustomDelayTimeClose % 256); |
| | | } else { |
| | |
| | | delayLow = Convert.ToByte (lightDimming.CustomDelayTimeOpen % 256); |
| | | } |
| | | if (lightDimming.Type == DeviceType.LightMixDimming) { |
| | | Control.ControlBytesSend (Command.SetSingleLight, lightDimming.SubnetID, lightDimming.DeviceID, new byte [] { (lightDimming as LightMixDimming).PhysicsLoopID, (byte)tempLightSeekBar.Progress, delayHeight, delayLow }, SendCount.Zero); |
| | | } else |
| | | Control.ControlBytesSend (Command.SetSingleLight, lightDimming.SubnetID, lightDimming.DeviceID, new byte [] { lightDimming.LoopID, (byte)tempLightSeekBar.Progress, delayHeight, delayLow }, SendCount.Zero); |
| | | tempLightSeekBar.Progress = lightDimming.CurrentBrightness; |
| | | SendControl.SendControlSetSingleLight (lightDimming, new byte [] { (lightDimming as LightMixDimming).PhysicsLoopID, (byte)mSetBrightness, delayHeight, delayLow }); |
| | | //Control.ControlBytesSend (Command.SetSingleLight, lightDimming.SubnetID, lightDimming.DeviceID, new byte [] { (lightDimming as LightMixDimming).PhysicsLoopID, (byte)tempLightSeekBar.Progress, delayHeight, delayLow }, SendCount.Zero); |
| | | } else { |
| | | //Control.ControlBytesSend (Command.SetSingleLight, lightDimming.SubnetID, lightDimming.DeviceID, new byte [] { lightDimming.LoopID, (byte)tempLightSeekBar.Progress, delayHeight, delayLow }, SendCount.Zero); |
| | | SendControl.SendControlSetSingleLight (lightDimming, new byte [] { lightDimming.LoopID, (byte)mSetBrightness, delayHeight, delayLow }); |
| | | |
| | | } |
| | | //tempLightSeekBar.Progress = lightDimming.CurrentBrightness; |
| | | }; |
| | | |
| | | if (lightDimming.CurrentBrightness > 0) { |
| | |
| | | lightView.AddChidren (btnLightSetting); |
| | | Button btnRGBSetting = new Button () { |
| | | Width = Application.GetRealWidth (60), |
| | | Height = Application.GetRealHeight (60), |
| | | Height = Application.GetRealWidth (60), |
| | | Radius = (uint)Application.GetRealHeight (30), |
| | | X = tempLightSeekBar.Right + Application.GetRealWidth (20), |
| | | Gravity = Gravity.CenterVertical, |
| | |
| | | #endregion |
| | | //开关按键 |
| | | var tempSwitch = new Button () { |
| | | Width = Application.GetRealWidth (90), |
| | | Height = Application.GetRealHeight (53), |
| | | Width = Application.GetMinRealAverage (90), |
| | | Height = Application.GetMinRealAverage (53), |
| | | X = Application.GetRealWidth (640 - 90 - 20), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "Item/SwitchClose.png", |