From 5a5a2b696866f947b6025d26c3302e8ffef46435 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期一, 11 一月 2021 16:11:20 +0800 Subject: [PATCH] 2021-01-11 1.更新MQTT连接和本地搜索网关方法。2.子账号相关接口完善 --- Crabtree/SmartHome/UI/SimpleControl/Phone/Alexa/AlexaSettingPage.cs | 198 ++++++++++++++++-------------------------------- 1 files changed, 67 insertions(+), 131 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Alexa/AlexaSettingPage.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Alexa/AlexaSettingPage.cs index 02ed091..f36fde0 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Alexa/AlexaSettingPage.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Alexa/AlexaSettingPage.cs @@ -84,8 +84,8 @@ chooseTypeView.AddChidren (btnEquipmentIcon); Button btnDrodIcon = new Button () { X = Application.GetRealWidth (540), - Height = Application.GetRealHeight (46), - Width = Application.GetRealWidth (47), + Height = Application.GetMinRealAverage (46), + Width = Application.GetMinRealAverage (47), UnSelectedImagePath = "Item/Down.png", SelectedImagePath = "Item/DownSelected.png", Gravity = Gravity.CenterVertical, @@ -187,16 +187,16 @@ || typeString.ToString () == DeviceType.CurtainTrietex.ToString () #endregion #region ac - || typeString.ToString () == DeviceType.ACPanel.ToString () - || typeString.ToString () == DeviceType.ACDevice.ToString () - || typeString.ToString () == DeviceType.ACInfrared.ToString () - || typeString.ToString () == DeviceType.ACCoolmaster.ToString () - || typeString.ToString () == DeviceType.CustomAC.ToString () - || typeString.ToString () == DeviceType.HVAC.ToString () + //|| typeString.ToString () == DeviceType.ACPanel.ToString () + //|| typeString.ToString () == DeviceType.ACDevice.ToString () + //|| typeString.ToString () == DeviceType.ACInfrared.ToString () + //|| typeString.ToString () == DeviceType.ACCoolmaster.ToString () + //|| typeString.ToString () == DeviceType.CustomAC.ToString () + //|| typeString.ToString () == DeviceType.HVAC.ToString () #endregion #region || typeString.ToString () == DeviceType.FanModule.ToString () - || typeString.ToString () == DeviceType.UniversalDevice.ToString () + //|| typeString.ToString () == DeviceType.UniversalDevice.ToString () #endregion ); }); @@ -261,11 +261,11 @@ } var commonBytes = IO.FileUtils.ReadFile (filePath); if (commonBytes.Length == 0) { - Console.WriteLine ("length loss"); + Utlis.WriteLine ("length loss"); continue; } if (commonBytes.Length == 1) { - Console.WriteLine ("length loss 1"); + Utlis.WriteLine ("length loss 1"); continue; } if (str [1] == DeviceType.InfraredMode.ToString ()) { @@ -283,6 +283,8 @@ deviceFilePath = deviceFilePath.Replace ("LightSwitchSocket", "LightSwitch"); } else if(deviceFilePath.Contains("ACInfrared")) { deviceFilePath = deviceFilePath.Replace ("ACInfrared", "HVAC"); + } else if (deviceFilePath.Contains ("CurtainModel")) { + deviceFilePath = deviceFilePath.Replace ("CurtainModel", "CurtainModule"); } Common commonDevice = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (System.Text.Encoding.UTF8.GetString (commonBytes)); if (commonDevice.Type == DeviceType.OnePortBus || commonDevice.Type == DeviceType.OnePortWirelessFR || commonDevice.Type == DeviceType.OnePortMqttFR || commonDevice.Type == DeviceType.RCU @@ -318,139 +320,56 @@ }; deviceRow.AddChidren (btnEquipment); - Button btnFindDevcie = new Button () { - X = btnEquipment.Right, - Width = Application.GetRealWidth (75), - Height = Application.GetRealHeight (72), - Gravity = Gravity.CenterVertical, - UnSelectedImagePath = "CrabtreeAdd/Position.png", - SelectedImagePath = "CrabtreeAdd/PositionOn.png", - }; - deviceRow.AddChidren (btnFindDevcie); + //2020-01-10 闅愯棌瀹氫綅鎸夐挳 + //Button btnFindDevcie = new Button () { + // X = btnEquipment.Right, + // Width = Application.GetRealWidth (75), + // Height = Application.GetRealHeight (72), + // Gravity = Gravity.CenterVertical, + // UnSelectedImagePath = "CrabtreeAdd/Position.png", + // SelectedImagePath = "CrabtreeAdd/PositionOn.png", + //}; + //deviceRow.AddChidren (btnFindDevcie); - btnFindDevcie.MouseUpEventHandler += (sdd, dds) => { - btnFindDevcie.IsSelected = true; - Control.ControlBytesSend (Command.PositioningEquipment, commonDevice.SubnetID, commonDevice.DeviceID, new byte [] { 5 }); - System.Threading.Tasks.Task.Run (() => { - System.Threading.Thread.Sleep (3000); - Application.RunOnMainThread (() => { - btnFindDevcie.IsSelected = false; - }); - }); - }; + //btnFindDevcie.MouseUpEventHandler += (sdd, dds) => { + // btnFindDevcie.IsSelected = true; + // Control.ControlBytesSend (Command.PositioningEquipment, commonDevice.SubnetID, commonDevice.DeviceID, new byte [] { 5 }); + // System.Threading.Tasks.Task.Run (() => { + // System.Threading.Thread.Sleep (3000); + // Application.RunOnMainThread (() => { + // btnFindDevcie.IsSelected = false; + // }); + // }); + //}; if (selectedDeviceType != "Scene") { + //2020-01-10 闅愯棌淇敼鎸夐挳 + //return; var btnEdit = new Button () { X = btnEquipment.Right + Application.GetRealWidth (80), - Width = Application.GetRealWidth (75), - Height = Application.GetRealHeight (72), + Width = Application.GetMinRealAverage (75), + Height = Application.GetMinRealAverage (72), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "CrabtreeAdd/Edit.png", SelectedImagePath = "CrabtreeAdd/EditOn.png", }; deviceRow.AddChidren (btnEdit); + btnEdit.MouseUpEventHandler += (sd, ds) => { - Dialog dialog = new Dialog (); - - var dialogView = new FrameLayout () { - Gravity = Gravity.Center, - Width = Application.GetRealWidth (500), - Height = Application.GetRealHeight (300), - BackgroundColor = SkinStyle.Current.DialogColor, - Radius = 5, - BorderColor = SkinStyle.Current.Transparent, - BorderWidth = 1, + Action successAction = () => { + GenericDialog.Current.RefreshRemark (commonDevice); + if (!roomDeviceFilePathList.Contains (filePath)) { + roomDeviceFilePathList.Add (filePath); + } }; - dialog.AddChidren (dialogView); - - var etDeviceName = new EditText () { - Y = Application.GetRealHeight (80), - Gravity = Gravity.CenterHorizontal, - Width = Application.GetRealWidth (350), - Height = Application.GetRealHeight (70), - Text = commonDevice.Name, - TextAlignment = TextAlignment.Center, - TextColor = SkinStyle.Current.TextColor, - Radius = 1, - BorderWidth = 1, - BorderColor = SkinStyle.Current.BorderColor, - }; - dialogView.AddChidren (etDeviceName); - - etDeviceName.EditorEnterAction += (obj2) => { - Application.HideSoftInput (); - }; - - var dialogBottomView = new FrameLayout () { - Y = Application.GetRealHeight (213), - Height = Application.GetRealHeight (90), - BackgroundColor = SkinStyle.Current.Black50Transparent, - }; - dialogView.AddChidren (dialogBottomView); - - var btnClose = new Button () { - Width = Application.GetRealWidth (250), - TextAlignment = TextAlignment.Center, - TextID = R.MyInternationalizationString.cancel, - TextColor = SkinStyle.Current.TextColor, - BackgroundColor = SkinStyle.Current.ButtonColor, - }; - dialogBottomView.AddChidren (btnClose); - btnClose.MouseUpEventHandler += (ddss, dddsss) => { - dialog.Close (); - }; - - var editor = new Button () { - X = btnClose.Right + 1, - Width = Application.GetRealWidth (250), - TextAlignment = TextAlignment.Center, - TextID = R.MyInternationalizationString.SAVE, - TextColor = SkinStyle.Current.TextColor, - BackgroundColor = SkinStyle.Current.ButtonColor, - }; - dialogBottomView.AddChidren (editor); - - editor.MouseUpEventHandler += (dff, ffd) => { - MainPage.Loading.Start (); - byte [] remakeBytes = CommonPage.MyEncodingGB2312.GetBytes (etDeviceName.Text.Trim ()); - System.Threading.Tasks.Task.Run (() => { - byte [] updateBytes = Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, commonDevice.SubnetID, commonDevice.DeviceID, new byte [] { commonDevice.BigClass, commonDevice.MinClass, commonDevice.LoopID }); - if (updateBytes == null) { - Application.RunOnMainThread (() => { - new Alert ("", Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show (); - MainPage.Loading.Hide (); - dialog.Close (); - }); - return; - } - byte [] uBytes = new byte [20]; - Array.Copy (remakeBytes, 0, uBytes, 0, remakeBytes.Length < 20 ? remakeBytes.Length : 20); - Array.Copy (uBytes, 0, updateBytes, 3, 20 < uBytes.Length ? 20 : uBytes.Length); - var reBytes = Control.ControlBytesSendHasReturn (Command.SetDeviceLoopInfo, commonDevice.SubnetID, commonDevice.DeviceID, updateBytes); - if (reBytes != null) { - Application.RunOnMainThread (() => { - btnEquipment.Text = commonDevice.Name = etDeviceName.Text.Trim (); - IO.FileUtils.SaveEquipmentMessage (commonDevice, commonDevice.LoopID.ToString ()); - MainPage.Loading.Hide (); - dialog.Close (); - }); - } else { - Application.RunOnMainThread (() => { - new Alert ("", Language.StringByID (R.MyInternationalizationString.FailureToModify), Language.StringByID (R.MyInternationalizationString.Close)).Show (); - MainPage.Loading.Hide (); - dialog.Close (); - }); - } - }); - }; - - dialog.Show (); + GenericDialog.Current.ShowModifyRemarksDialog (commonDevice, commonBytes, btnEquipment, successAction); }; } + var btnChoose = new Button () { X = Application.GetRealWidth (472 + 80), - Width = Application.GetRealWidth (75), - Height = Application.GetRealHeight (72), + Width = Application.GetMinRealAverage (75), + Height = Application.GetMinRealAverage (72), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "CrabtreeAdd/Choose.png", SelectedImagePath = "CrabtreeAdd/ChooseOn.png", @@ -459,6 +378,8 @@ }; btnChoose.AddTag ("DeviceFilePath", deviceFilePath); deviceRow.AddChidren (btnChoose); + + btnChoose.MouseUpEventHandler += (sendere, ee) => { btnChoose.IsSelected = !btnChoose.IsSelected; @@ -479,9 +400,24 @@ showList.Remove (((Button)sendere).Tag.ToString ()); } }; + + if (selectedDeviceType == "Scene") { + //string [] str = filePath.Split ('_'); + var sceneName = str [str.Length - 2];//鍊掓暟绗竴浣嶄负鍦烘櫙鍚� + btnChoose.IsSelected = showList.Contains (sceneName); + btnChoose.Enable = !btnChoose.IsSelected; + } else { + //2020-07-23 濡傛灉鍖归厤鍒欏垽鏂槸鍚︽坊鍔犵湡姝g殑璺緞 + if (btnChoose.IsSelected) { + if (!roomDeviceFilePathList.Contains (filePath)) { + roomDeviceFilePathList.Add (filePath); + } + } + } + }); } catch (Exception ex) { - Console.WriteLine (ex.Message); + Utlis.WriteLine (ex.Message); } } }); @@ -496,7 +432,7 @@ Language.StringByID(R.MyInternationalizationString.All), Language.StringByID(R.MyInternationalizationString.Scenes), Language.StringByID(R.MyInternationalizationString.Lights), - Language.StringByID(R.MyInternationalizationString.AC), + //Language.StringByID(R.MyInternationalizationString.AC), Language.StringByID(R.MyInternationalizationString.Curtains), //Language.StringByID(R.MyInternationalizationString.FoolHeat), //Language.StringByID(R.MyInternationalizationString.FreshAir), @@ -506,7 +442,7 @@ //Language.StringByID (R.MyInternationalizationString.LogicModule), //Language.StringByID(R.MyInternationalizationString.ElectricalControl), //Language.StringByID (R.MyInternationalizationString.MusicModel), - Language.StringByID (R.MyInternationalizationString.UniversalDevice), + //Language.StringByID (R.MyInternationalizationString.UniversalDevice), //Language.StringByID (R.MyInternationalizationString.Sensor), }; -- Gitblit v1.8.0