From 1d1cad99a27c9f644c84eb3d376c70bd30a55879 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期三, 10 三月 2021 18:02:13 +0800 Subject: [PATCH] 2021-3-10-1 --- HDL-ON_Android/Assets/Language.ini | 5 HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/TipView.cs | 180 +++++++++++++ HDL_ON/DAL/Mqtt/MqttClient.cs | 12 HDL_ON/HDL_ON.projitems | 2 HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/FrameLayout50.cs | 91 +++++++ HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs | 132 +++++++-- HDL-ON_iOS/Resources/Language.ini | 4 HDL_ON/DAL/Server/NewAPI.cs | 17 HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs | 2 HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControlComplete.cs | 75 +++++ HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/EditControl.cs | 110 ++++++++ HDL_ON/Common/R.cs | 2 .vs/HDL_APP_Project/xs/UserPrefs.xml | 49 +-- HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs | 11 HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs | 35 ++ 15 files changed, 617 insertions(+), 110 deletions(-) diff --git a/.vs/HDL_APP_Project/xs/UserPrefs.xml b/.vs/HDL_APP_Project/xs/UserPrefs.xml index ead20b4..2633a2b 100644 --- a/.vs/HDL_APP_Project/xs/UserPrefs.xml +++ b/.vs/HDL_APP_Project/xs/UserPrefs.xml @@ -1,19 +1,14 @@ 锘�<Properties StartupConfiguration="{09712674-2A38-407B-B1E2-560B2C352F9A}|Default"> <MonoDevelop.Ide.ItemProperties.HDL-ON__iOS automaticSigning="False" PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneDeviceTarget.00008020-001674E61438002E" /> - <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/DAL/Server/NewAPI.cs"> + <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs"> <Files> - <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs" Line="66" Column="58" /> - <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs" Line="68" Column="88" /> - <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Pir.cs" /> - <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs" /> - <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs" Line="191" Column="28" /> - <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs" Line="135" Column="46" /> - <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs" Line="1" Column="1" /> - <File FileName="HDL_ON/DAL/Mqtt/MqttClient.cs" Line="310" Column="1" /> - <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControlComplete.cs" Line="116" Column="21" /> - <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/BrandList.cs" /> - <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddButton.cs" Line="136" Column="54" /> - <File FileName="HDL_ON/DAL/Server/NewAPI.cs" Line="327" Column="6" /> + <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs" Line="77" Column="36" /> + <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs" Line="305" Column="66" /> + <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs" Line="205" Column="8" /> + <File FileName="HDL-ON_Android/Assets/Language.ini" Line="1326" Column="5" /> + <File FileName="HDL_ON/Common/R.cs" Line="812" Column="33" /> + <File FileName="HDL_ON/DAL/Mqtt/MqttClient.cs" Line="301" Column="35" /> + <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs" Line="103" Column="40" /> </Files> <Pads> <Pad Id="ProjectPad"> @@ -22,40 +17,22 @@ <Node name="HDL_ON" expanded="True"> <Node name="Common" expanded="True" /> <Node name="DAL" expanded="True"> - <Node name="DriverLayer" expanded="True" /> <Node name="Mqtt" expanded="True" /> - <Node name="Server" expanded="True"> - <Node name="NewAPI.cs" selected="True" /> - </Node> + <Node name="Server" expanded="True" /> </Node> - <Node name="Entity" expanded="True"> - <Node name="Function" expanded="True" /> - </Node> + <Node name="Entity" expanded="True" /> <Node name="UI" expanded="True"> - <Node name="UI0-Public" expanded="True" /> <Node name="UI2" expanded="True"> - <Node name="3-Intelligence" expanded="True"> - <Node name="Automation" expanded="True"> - <Node name="LogicView" expanded="True" /> - </Node> - </Node> <Node name="4-PersonalCenter" expanded="True"> <Node name="PirDevice" expanded="True"> - <Node name="View" expanded="True" /> + <Node name="Method.cs" selected="True" /> </Node> </Node> </Node> </Node> </Node> <Node name="HDL-ON_Android" expanded="True"> - <Node name="Assets" expanded="True"> - <Node name="Phone" expanded="True"> - <Node name="PirIcon" expanded="True" /> - </Node> - </Node> - </Node> - <Node name="HDL-ON_iOS" expanded="True"> - <Node name="Resources" expanded="True" /> + <Node name="Assets" expanded="True" /> </Node> </Node> </State> @@ -73,6 +50,8 @@ <MonoDevelop.Ide.DebuggingService.Breakpoints> <BreakpointStore> <Breakpoint file="/Users/hdl/Desktop/wjc/HDL_APP_Project/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs" relfile="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs" line="323" column="1" /> + <Breakpoint file="/Users/hdl/Desktop/wjc/HDL_APP_Project/HDL_ON/DAL/Mqtt/MqttClient.cs" relfile="HDL_ON/DAL/Mqtt/MqttClient.cs" line="310" column="1" /> + <Breakpoint file="/Users/hdl/Desktop/wjc/HDL_APP_Project/HDL_ON/DAL/Mqtt/MqttClient.cs" relfile="HDL_ON/DAL/Mqtt/MqttClient.cs" line="301" column="1" /> </BreakpointStore> </MonoDevelop.Ide.DebuggingService.Breakpoints> <MultiItemStartupConfigurations /> diff --git a/HDL-ON_Android/Assets/Language.ini b/HDL-ON_Android/Assets/Language.ini index 0fe8100..5d5d311 100644 --- a/HDL-ON_Android/Assets/Language.ini +++ b/HDL-ON_Android/Assets/Language.ini @@ -1265,6 +1265,9 @@ 6072=纭鍒犻櫎 6073=鍙栨秷 6074=閬ユ帶鍣ㄤ笉鑳借秴杩�10涓紵 +6075=閬ユ帶鍣ㄦ墍灞炲尯鍩�: +6076=缂栬緫淇℃伅 + 7000=鏂板缓鑷姩鍖� @@ -1315,7 +1318,7 @@ 7045=璁剧疆 7046=鍚嶇О 7047=淇敼鍚嶇О -7048=鑷姩鍖栧悕绉板凡瀛樺湪 +7048=鍚嶇О宸插瓨鍦� 7049=鏄惁瑕佸垹闄よ嚜鍔ㄥ寲锛� 7050=娣诲姞鍦烘櫙 7051=寤舵椂 diff --git a/HDL-ON_iOS/Resources/Language.ini b/HDL-ON_iOS/Resources/Language.ini index d55156e..b52d360 100644 --- a/HDL-ON_iOS/Resources/Language.ini +++ b/HDL-ON_iOS/Resources/Language.ini @@ -1269,6 +1269,8 @@ 6072=纭鍒犻櫎 6073=鍙栨秷 6074=閬ユ帶鍣ㄤ笉鑳借秴杩�10涓紵 +6075=閬ユ帶鍣ㄦ墍灞炲尯鍩�: +6076=缂栬緫淇℃伅 @@ -1320,7 +1322,7 @@ 7045=璁剧疆 7046=鍚嶇О 7047=淇敼鍚嶇О -7048=鑷姩鍖栧悕绉板凡瀛樺湪 +7048=鍚嶇О宸插瓨鍦� 7049=鏄惁瑕佸垹闄よ嚜鍔ㄥ寲锛� 7050=娣诲姞鍦烘櫙 7051=寤舵椂 diff --git a/HDL_ON/Common/R.cs b/HDL_ON/Common/R.cs index 49d4bfa..ab3559c 100644 --- a/HDL_ON/Common/R.cs +++ b/HDL_ON/Common/R.cs @@ -749,6 +749,8 @@ public const int querenshanchu = 6072; public const int quxiao = 6073; public const int bunengchaoguo10 = 6074; + public const int yaokongqiquyu = 6075; + public const int bianjixinxi = 6076; diff --git a/HDL_ON/DAL/Mqtt/MqttClient.cs b/HDL_ON/DAL/Mqtt/MqttClient.cs index b0ba2a9..1074361 100644 --- a/HDL_ON/DAL/Mqtt/MqttClient.cs +++ b/HDL_ON/DAL/Mqtt/MqttClient.cs @@ -245,7 +245,7 @@ Utlis.WriteLine($"StartCloudMqtt: 寮�濮�"); - await Task.Factory.StartNew(async () => { + await Task.Factory.StartNew((Func<Task>)(async () => { try { #region 鍒濆鍖栬繙绋婱qtt @@ -257,7 +257,7 @@ if (RemoteMqttClient.ApplicationMessageReceivedHandler == null) { //澶勭悊鎺ユ敹鍒扮殑鏁版嵁 - RemoteMqttClient.UseApplicationMessageReceivedHandler((e) => { + RemoteMqttClient.UseApplicationMessageReceivedHandler((Action<MqttApplicationMessageReceivedEventArgs>)((e) => { try { var topic = e.ApplicationMessage.Topic; @@ -298,7 +298,7 @@ { var bytes = Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, tuyaEncryptKey); var revString = Encoding.UTF8.GetString(bytes); - HDL_ON.UI.UI2.PersonalCenter.PirDevice.Method.addcontrondata = revString; + HDL_ON.UI.UI2.PersonalCenter.PirDevice.Method.mqttdata = revString; //ReceiveCheckGateway(ss); //return; } @@ -307,7 +307,7 @@ { var bytes = Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, tuyaEncryptKey); var revString = Encoding.UTF8.GetString(bytes); - HDL_ON.UI.UI2.PersonalCenter.PirDevice.Method.studybtndata = revString; + HDL_ON.UI.UI2.PersonalCenter.PirDevice.Method.mqttdata = revString; //ReceiveCheckGateway(ss); //return; } @@ -338,7 +338,7 @@ } } catch { } - }); + })); } //(2)DisconnectedHandler @@ -389,7 +389,7 @@ Utlis.WriteLine($"StartCloudMqtt: 缁撴潫"); } - }); + })); } diff --git a/HDL_ON/DAL/Server/NewAPI.cs b/HDL_ON/DAL/Server/NewAPI.cs index 2991a2a..86fce77 100644 --- a/HDL_ON/DAL/Server/NewAPI.cs +++ b/HDL_ON/DAL/Server/NewAPI.cs @@ -507,6 +507,14 @@ /// 鑾峰彇璁惧璇︽儏閫氳繃(spk,sid) /// </summary> public const string Api_Post_GetinfoBySid = "/home-wisdom/app/device/infoBySid"; + /// <summary> + /// 绾㈠瀹�/閬ユ帶鍣ㄥ垹闄� + /// </summary> + public const string API_POST_Ir_DeviceDel = "/home-wisdom/app/device/remove"; + /// <summary> + /// 淇敼璁惧鍚嶇О + /// </summary> + public const string API_POST_Ir_DeviceRename = "/home-wisdom/app/device/rename"; #endregion @@ -518,14 +526,7 @@ /// 娌充笢鑾峰彇钀ょ煶浜戝瓙璐﹀彿token鐨勬帴鍙� /// </summary> public const string API_POST_EZ_GetChildToken = "/home-wisdom/platform/childToken"; - /// <summary> - /// 绾㈠瀹�/閬ユ帶鍣ㄥ垹闄� - /// </summary> - public const string API_POST_Ir_DeviceDel= "/home-wisdom/app/device/remove"; - /// <summary> - /// 淇敼绾㈠瀹濆悕绉� - /// </summary> - public const string API_POST_Ir_DeviceRename = "/home-wisdom/app/device/rename"; + #endregion diff --git a/HDL_ON/HDL_ON.projitems b/HDL_ON/HDL_ON.projitems index 210b3f1..e3e94a0 100644 --- a/HDL_ON/HDL_ON.projitems +++ b/HDL_ON/HDL_ON.projitems @@ -359,6 +359,8 @@ <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\AC\AcControlPage.cs" /> <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\4-PersonalCenter\PirDevice\Matching.cs" /> <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\4-PersonalCenter\PirDevice\View\PirNameView.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\4-PersonalCenter\PirDevice\EditControl.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\4-PersonalCenter\PirDevice\View\FrameLayout50.cs" /> </ItemGroup> <ItemGroup> <Folder Include="$(MSBuildThisFileDirectory)UI\" /> diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs index f598e88..d01e28b 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs @@ -234,7 +234,7 @@ try { //鍙戦�佹寜閿垹闄わ紱 - responsePackNew = PirSend.CodeRemove(obj); + responsePackNew = PirSend.CodeRemove(obj, control.deviceId); } catch { } finally diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControlComplete.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControlComplete.cs index 61d0ee9..6a20e68 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControlComplete.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControlComplete.cs @@ -12,6 +12,13 @@ } public void Show(Control control, bool bool_library) { + //鏁版嵁杞崲 + Entity.Function function = new Entity.Function(); + function.sid = control.sid; + function.deviceId = control.deviceId; + function.name = control.name; + function.spk = control.spk; + function.attributes.AddRange(function.attributes); #region 鐣岄潰甯冨眬 this.BackgroundColor = CSS.CSS_Color.viewMiddle; PirDevice.View.TopView topView = new View.TopView(); @@ -76,12 +83,71 @@ this.AddChidren(namePatchView.FLayoutView()); namePatchView.btnText1.TextID = StringId.yaokongqimingcheng; namePatchView.btnText2.Text = control.name; + namePatchView.btnClick.MouseUpEventHandler += (sender,e) => { + + List<string> list = new List<string>(); + + for (int i = 0; i < Pir.currPir.FunctioList.Count; i++) + { + list.Add(Pir.currPir.FunctioList[i].name); + } + Method method = new Method(); + method.EditControlName(StringId.editName, list, control.name, (name, view) => + { + //鍔犺浇log + Loading loading = new Loading(); + view.AddChidren(loading); + HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null; + loading.Start(); + new System.Threading.Thread(() => + { + try + { + responsePackNew = PirSend.DeviceRename(control.deviceId, control.name); + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + loading.Hide(); + if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") + { + view.Close(); + namePatchView.btnText2.Text = name; + function.name = name; + } + else + { + Method methodError = new Method(); + methodError.ErrorShow(responsePackNew); + } + + }); + } + + }) + { IsBackground = true }.Start(); + + + }, () => { }); + }; //鎵�灞炲尯鍩� View.PatchView quyuPatchView = new View.PatchView(); quyuPatchView.frameLayout.Y = namePatchView.frameLayout.Bottom; this.AddChidren(quyuPatchView.FLayoutView()); quyuPatchView.btnText1.TextID = StringId.suoshuquyu; - quyuPatchView.btnText2.TextID = StringId.dianqi; + quyuPatchView.btnText2.Text=Intelligence.Automation.LogicMethod.GetGetRoomName(function); + quyuPatchView.btnClick.MouseUpEventHandler += (sender, e) => + { + Method method = new Method(); + method.ManagementPosition(function, () => + { + //鏇存柊鍖哄煙 + quyuPatchView.btnText2.Text = Intelligence.Automation.LogicMethod.GetGetRoomName(function); + }); + }; + //缁х画娣诲姞 Button addBtn = new Button @@ -129,13 +195,6 @@ { MainPage.BasePageView.RemoveViewByTag("AddControl"); MainPage.BasePageView.RemoveViewByTag("Pir"); - - Entity.Function function = new Entity.Function(); - function.sid = control.sid; - function.deviceId = control.deviceId; - function.name = control.name; - function.spk = control.spk; - function.attributes.AddRange(function.attributes); if (null == Pir.currPir.FunctioList.Find((c) => c.sid == function.sid)) { Pir.currPir.FunctioList.Add(function); diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs index 1b58afe..7f35847 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs @@ -242,7 +242,7 @@ X = Application.GetRealWidth(311 + 16 - (40 + 100)), Width = Application.GetRealWidth(100), Height = Application.GetRealHeight(17), - Text = j.ToString(), + Text = Intelligence.Automation.LogicMethod.GetGetRoomName(control), TextAlignment = TextAlignment.CenterRight, TextSize = TextSize.text12, TextColor = CSS.CSS_Color.textCancelColor, @@ -318,6 +318,10 @@ if (function != null) { pirDevice.FunctioList.Remove(Function); + if (Pir.currPir != null && pirDevice.sid == Pir.currPir.sid) + { + Pir.currPir.FunctioList = pirDevice.FunctioList; + } } UIView(vv); } @@ -336,6 +340,23 @@ }) { IsBackground = true }.Start(); }; + EventHandler<MouseEventArgs> editClick = (sender, e) => + { + EditControl editControl = new EditControl(); + MainPage.BasePageView.AddChidren(editControl); + editControl.Show(control, pirDevice, (device) => + { + //鍥炶皟鏇存柊鍚嶅瓧/鍖哄煙 + nameBtn.Text = device.name; + areaBtn.Text = Intelligence.Automation.LogicMethod.GetGetRoomName(device); + + }); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + funControlRow.MouseUpEventHandler += editClick; + nameBtn.MouseUpEventHandler += editClick; + areaBtn.MouseUpEventHandler += editClick; + nextIconBtn.MouseUpEventHandler += editClick; } @@ -362,8 +383,8 @@ { list.Add(Pir.pirDeviceList[b].name); } - TipPopView tipPopView = new TipPopView(); - tipPopView.InputBox(StringId.xiugaimingzi, pirclick.name, StringId.nameNull, StringId.NameAlreadyExists, list, (name, view) => + Method methodView = new Method(); + methodView.EditControlName(StringId.xiugaimingzi, list, pirclick.name, (name, view) => { pirclick.name = name; //鍔犺浇log @@ -375,7 +396,7 @@ { try { - responsePackNew = PirSend.DeviceRename(pirclick); + responsePackNew = PirSend.DeviceRename(pirclick.deviceId, pirclick.name); } catch { } finally @@ -399,11 +420,9 @@ }) { IsBackground = true }.Start(); - - }, () => - { + },()=> { NewSwitchView(pirclick, vv); - }, false); + },false); } else diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/EditControl.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/EditControl.cs new file mode 100644 index 0000000..0325f8a --- /dev/null +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/EditControl.cs @@ -0,0 +1,110 @@ +锘縰sing System; +using Shared; +using System.Collections.Generic; +using HDL_ON.UI.UI2.PersonalCenter.PirDevice.View; + +namespace HDL_ON.UI.UI2.PersonalCenter.PirDevice +{ + public class EditControl : FrameLayout + { + public EditControl() + { + } + + public void Show(Entity.Function control, Pir pir, Action<Entity.Function> action) + { + + this.BackgroundColor = CSS.CSS_Color.viewMiddle; + PirDevice.View.TopView topView = new View.TopView(); + topView.topNameBtn.TextID = StringId.pipeiyaokongqi; + this.AddChidren(topView.FLayoutView()); + topView.clickBackBtn.MouseUpEventHandler += (e, sen) => + { + action(control); + RemoveFromParent(); + }; + topView.topNameBtn.TextID = StringId.bianjixinxi; + FrameLayout viewLayout = new FrameLayout + { + Y = Application.GetRealHeight(64), + Width = Application.GetRealWidth(375), + Height = Application.GetRealHeight(667 - 64), + BackgroundColor = CSS.CSS_Color.viewMiddle, + }; + this.AddChidren(viewLayout); + + FrameLayout50 editNameFLayout = new FrameLayout50(); + editNameFLayout.btnText.Text = Language.StringByID(StringId.yaokongqimingcheng) + ":"; + editNameFLayout.btnEditText.Text = control.name; + editNameFLayout.btnNextIcon.Height = Application.GetRealWidth(28); + editNameFLayout.btnNextIcon.Width = Application.GetRealWidth(28); + editNameFLayout.btnNextIcon.UnSelectedImagePath = "LogicIcon/editname.png"; + viewLayout.AddChidren(editNameFLayout.FLayoutView()); + + FrameLayout50 areaFLayout = new FrameLayout50(); + areaFLayout.btnText.Text = Language.StringByID(StringId.yaokongqiquyu); + areaFLayout.btnEditText.Text = Intelligence.Automation.LogicMethod.GetGetRoomName(control); + areaFLayout.frameLayout.Y = editNameFLayout.frameLayout.Bottom; + viewLayout.AddChidren(areaFLayout.FLayoutView()); + + editNameFLayout.btnClick.MouseUpEventHandler += (sender, e) => + { + List<string> list = new List<string>(); + + for (int i = 0; i < pir.FunctioList.Count; i++) + { + list.Add(pir.FunctioList[i].name); + } + Method method = new Method(); + method.EditControlName(StringId.editName,list, control.name, (name,view) => + { + //鍔犺浇log + Loading loading = new Loading(); + view.AddChidren(loading); + HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null; + loading.Start(); + new System.Threading.Thread(() => + { + try + { + responsePackNew = PirSend.DeviceRename(control.deviceId, control.name); + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + loading.Hide(); + if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") + { + view.Close(); + editNameFLayout.btnEditText.Text = name; + control.name = name; + } + else + { + Method methodError = new Method(); + methodError.ErrorShow(responsePackNew); + } + + }); + } + + }) + { IsBackground = true }.Start(); + + + },()=> { }); + }; + areaFLayout.btnClick.MouseUpEventHandler += (sender, e) => + { + Method method = new Method(); + method.ManagementPosition(control, () => + { + //鏇存柊鍖哄煙 + areaFLayout.btnEditText.Text = Intelligence.Automation.LogicMethod.GetGetRoomName(control); + }); + }; + } + } +} diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs index a4a0393..8fd747b 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs @@ -8,9 +8,39 @@ { public class Method { + + /// <summary> + /// 绠$悊浣嶇疆 + /// </summary> + /// <param name="control">褰撳墠璁惧</param> + /// <param name="action">鍥炶皟鍑芥暟</param> + public void ManagementPosition(Entity.Function control, Action action) + { + var view = new ChooseRoomPage(control, action); + MainPage.BasePageView.AddChidren(view); + view.LoadPage(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + } + /// <summary> + /// 淇敼鍚嶇О + /// </summary> + /// <param name="tipText">鎻愮ず鏂囨湰</param> + /// <param name="list">褰撳墠瀛樺湪鍚嶇О鍒楄〃</param> + /// <param name="currName">褰撳墠鍚嶇О</param> + /// <param name="action">鍥炶皟鍑芥暟</param> + public void EditControlName(int tipText ,List<string> list, string currName, Action<string, Dialog> action,Action actionCancel, bool tag=false) + { + new View.TipView().InputBox(StringId.editName, currName, StringId.nameNull, StringId.NameAlreadyExists, list, (text, view + ) => + { + action(text,view); + }, () => { actionCancel(); }, tag); + } /// <summary> /// 娣诲姞閬ユ帶鍣ㄧ殑鏂规硶 /// </summary> + /// <param name="frameLayout">log鍥炬爣鍔犺浇鐣岄潰</param> + /// <param name="action">鍥炶皟鍑芥暟</param> public void AddControl(FrameLayout frameLayout, Action<Control> action) { View.TipView tipView = new View.TipView(); @@ -36,8 +66,9 @@ /// <summary> /// 鍙戦�侀仴鎺у櫒鍛戒护鏂规硶 /// </summary> - /// <param name="control"></param> - /// <param name="frame"></param> + /// <param name="control">鍙戦�佸弬鏁板璞�</param> + /// <param name="frame">log鍥炬爣鍔犺浇鐣岄潰</param> + /// <param name="action">鍥炶皟鍑芥暟</param> public void ThreadAddControl(Control control, FrameLayout frame, Action<Control> action) { DAL.Server.ResponsePackNew responsePackNew = null; @@ -48,7 +79,12 @@ { try { + //鍙戦�佹坊鍔犲懡浠� responsePackNew = PirSend.Add(control); + + + + } catch { } finally @@ -59,19 +95,32 @@ if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") { string sid = responsePackNew.Data.ToString(); - var mqttdate = MqttDate(sid); + var mqttdate =MqttDate(sid); + ///杩欓噷锛氱洃鍚琈TTP鎺ㄩ�佷笅鏉ヤ富棰橈紝鎵嶇煡閬撴槸鍚︽坊鍔犳垚鍔� if (mqttdate != null) { - ///杩欓噷锛氱洃鍚琈TTP鎺ㄩ�佷笅鏉ヤ富棰橈紝鎵嶇煡閬撴槸鍚︽坊鍔犳垚鍔� control.sid = sid; //浼戠湢500姣锛屼负绛夊緟浜戠鍒涘缓deviceid锛� System.Threading.Thread.Sleep(500); - GetControl(frame, control,(device)=> { + GetControl(frame, control, (device) => + { if (device != null) { control.deviceId = device.deviceId; frame.RemoveFromParent();//娣诲姞鎴愬姛鍏抽棴寮圭獥 + action(control); + } + else + { + //璇诲彇deviceid杩斿洖閿欒鎻愮ず + View.FailView failView = new View.FailView(); + failView.ShouError((view) => + { + view.Close(); + ThreadAddControl(control, frame, action); + }); + } }); } @@ -85,23 +134,24 @@ ThreadAddControl(control, frame, action); }); } - - } else { ErrorShow(responsePackNew); } }); + + } }) { IsBackground = true }.Start(); } - /// <summary> /// 鑾峰彇绾㈠璁惧鍒楄〃 /// </summary> + /// <param name="frame">log鍥炬爣鍔犺浇鐣岄潰</param> + /// <param name="action">鍥炶皟鍑芥暟</param> public static void GetPirDeviceList(FrameLayout frame, Action action) { //娓呴櫎涔嬪墠鍒楄〃; @@ -173,6 +223,8 @@ /// <summary> /// 鑾峰彇閬ユ帶鍣ㄥ垪琛� /// </summary> + /// <param name="frame">log鍥炬爣鍔犺浇鐣岄潰</param> + /// <param name="action">鍥炶皟鍑芥暟</param> public static void GetControlList(FrameLayout frame, Action action) { //鍔犺浇log @@ -243,10 +295,12 @@ { IsBackground = true }.Start(); } - /// <summary> - /// 鑾峰彇閬ユ帶鍣ㄨ缁� + /// 鑾峰彇璁惧璇︽儏閫氳繃(spk,sid) /// </summary> + /// <param name="frame">log鍥炬爣鍔犺浇鐣岄潰</param> + /// <param name="control">鍙戦�佸弬鏁板璞�</param> + /// <param name="action">鍥炶皟鍑芥暟</param> public void GetControl(FrameLayout frame, Control control, Action<Entity.Function> action) { Entity.Function function = null; @@ -259,6 +313,7 @@ { try { + // 鑾峰彇璁惧璇︽儏閫氳繃(spk,sid) responsePackNew = PirSend.GetinfoBySid(control); } catch { } @@ -295,61 +350,66 @@ }) { IsBackground = true }.Start(); } - /// <summary> - /// MQTT涓婚鎺ㄩ�佷笅鏉ョ殑鏁版嵁(閬ユ帶鍣ㄦ坊鍔�) + /// MQTT涓婚鎺ㄩ�佷笅鏉ョ殑鏁版嵁 /// </summary> - public static string addcontrondata = ""; - /// <summary> - /// MQTT涓婚鎺ㄩ�佷笅鏉ョ殑鏁版嵁(瀛︿範鎸夐敭) - /// </summary> - public static string studybtndata = ""; - + public static string mqttdata = ""; /// <summary> /// 鍒ゆ柇杩欎釜涓婚鏄惁鏄坊鍔犻仴鎺у櫒涓婚 /// </summary> + /// <param name="sid">鍞竴鏍囪瘑</param> + /// <param name="timeValue">绛夊緟鏃堕棿鍊�</param> /// <returns></returns> - public Cloud MqttDate(string sid,int timeValue=10) + public Cloud MqttDate(string sid, int timeValue = 10) { - Cloud cloud=null; + Cloud cloud = null; var dateTime = DateTime.Now; while ((DateTime.Now - dateTime).TotalMilliseconds < timeValue * 1000) { - if (!string.IsNullOrEmpty(addcontrondata)) + if (!string.IsNullOrEmpty(mqttdata)) { - var cloudjson = Newtonsoft.Json.JsonConvert.DeserializeObject<Cloud>(addcontrondata); - for (int i = 0; i < cloudjson.objects.Count; i++) + try { - var objects = cloudjson.objects[i]; - if (sid == objects.sid) + var cloudjson = Newtonsoft.Json.JsonConvert.DeserializeObject<Cloud>(mqttdata); + for (int i = 0; i < cloudjson.objects.Count; i++) { - cloud = cloudjson; - break; + var objects = cloudjson.objects[i]; + if (sid == objects.sid) + { + cloud = cloudjson; + break; + } } + break; } - break; + catch { } } } return cloud; } - /// <summary> /// 閿欒鐮佹彁绀� /// </summary> /// <param name="responsePackNew"></param> - public void ErrorShow(ResponsePackNew responsePackNew) + /// <param name="str"></param> + public void ErrorShow(ResponsePackNew responsePackNew,string str="") { - - if (responsePackNew != null && responsePackNew.Code == "14005") - { - new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline)); - + if (str == "鍒犻櫎閬ユ帶鍣�") { + new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.delFail)); } else { - new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail)); + if (responsePackNew != null && responsePackNew.Code == "14005") + { + new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline)); + } + else + { + new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail)); + + } } } diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs index 96c3425..9ef310f 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs @@ -13,7 +13,6 @@ public class PirSend { - public static string pirId = "1367032976869658625"; /// <summary> /// 浣忓畢ID /// </summary> @@ -181,7 +180,7 @@ /// 鑷鎸夐敭鍒犻櫎 /// </summary> /// <returns></returns> - public static ResponsePackNew CodeRemove(AttributesStatus buttonObj) + public static ResponsePackNew CodeRemove(AttributesStatus buttonObj,string deviceId) { var job = new JObject { }; job.Add("key", buttonObj.key); @@ -191,7 +190,7 @@ job.Add("value", valuejArray); var jArray = new JArray { }; jArray.Add(job); - var jObject = new JObject { { "homeId", HomeId }, { "deviceId", pirId }, { "attributes", jArray } }; + var jObject = new JObject { { "homeId", HomeId }, { "deviceId", deviceId }, { "attributes", jArray } }; var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Ir_CodeRemove); return responsePackNew; } @@ -207,12 +206,12 @@ return responsePackNew; } /// <summary> - /// 淇敼绾㈠瀹濆悕绉� + /// 淇敼绾㈠瀹�/璁惧鍚嶇О /// </summary> /// <returns></returns> - public static ResponsePackNew DeviceRename(Pir pir) + public static ResponsePackNew DeviceRename(string deviceId,string name) { - var jObject = new JObject { { "homeId", HomeId }, { "deviceId", pir.deviceId }, { "name", pir.name } }; + var jObject = new JObject { { "homeId", HomeId }, { "deviceId", deviceId }, { "name", name} }; var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Ir_DeviceRename); return responsePackNew; } diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/FrameLayout50.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/FrameLayout50.cs new file mode 100644 index 0000000..eacada3 --- /dev/null +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/FrameLayout50.cs @@ -0,0 +1,91 @@ +锘縰sing System; +using HDL_ON.UI.Music; +using Shared; +namespace HDL_ON.UI.UI2.PersonalCenter.PirDevice.View +{ + public class FrameLayout50 + { + /// <summary> + /// 涓绘帶浠禫iew + /// </summary> + public FrameLayout frameLayout = new FrameLayout + { + Height = Application.GetRealHeight(50), + BackgroundColor = CSS.CSS_Color.view, + }; + + /// <summary> + /// 鏂囨湰鎻忚堪 + /// </summary> + public Button btnText = new Button + { + TextSize = TextSize.Text16, + Width = Application.GetRealWidth(200), + Height = Application.GetRealHeight(22), + TextColor = CSS.CSS_Color.textColor, + X = Application.GetRealWidth(16), + }; + + /// <summary> + /// 缂栬緫鏂囨湰 + /// </summary> + public Button btnEditText = new Button + { + Width = Application.GetRealWidth(357 - 52 - 200 - 16), + Height = Application.GetRealHeight(20), + TextSize = TextSize.Text14, + TextColor = CSS.CSS_Color.textCancelColor, + X = Application.GetRealWidth(200 + 16), + TextAlignment = TextAlignment.CenterRight, + }; + + + /// <summary> + /// 鍥炬爣 + /// </summary> + public Button btnNextIcon = new Button + { + Width = Application.GetRealWidth(16), + Height = Application.GetRealWidth(16), + UnSelectedImagePath = "LogicIcon/next.png", + X = Application.GetRealWidth(339), + + }; + + /// <summary> + /// 绾� + /// </summary> + public Button btnLine = new Button + { + Width = Application.GetRealWidth(375 - 32), + X = Application.GetRealWidth(16), + Height = 1, + BackgroundColor = CSS.CSS_Color.viewLine, + + }; + + public Button btnClick = new Button + { + Height = Application.GetRealHeight(50), + }; + /// <summary> + /// View鐨勬柟娉� + /// </summary> + /// <returns></returns> + public FrameLayout FLayoutView() + { + btnText.Gravity = Gravity.CenterVertical; + btnText.TextAlignment = TextAlignment.CenterLeft; + btnNextIcon.Gravity = Gravity.CenterVertical; + btnEditText.Gravity = Gravity.CenterVertical; + frameLayout.AddChidren(btnText); + frameLayout.AddChidren(btnEditText); + frameLayout.AddChidren(btnNextIcon); + btnLine.Y = frameLayout.Height - 1; + frameLayout.AddChidren(btnLine); + frameLayout.AddChidren(btnClick); + return frameLayout; + } + } +} + diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/TipView.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/TipView.cs index 6fec343..9a2280b 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/TipView.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/TipView.cs @@ -15,6 +15,186 @@ /// 灏忔鍦嗚鍊� /// </summary> public int radiusEditFrameLayout = 4; + /// <summary> + /// 杈撳叆妗� + /// </summary> + /// <param name="titleId">鏍囬鏂囨湰</param> + /// <param name="tnputEditTxet">鏄剧ず鏂囨湰</param> + /// <param name="errorId_IsNullOrEmpty">杈撳叆妗嗘枃鏈负绌鸿嚜瀹氫箟鎻愮ず閿欒鏂囨湰</param> + /// <param name="errorId_PresenceP">妫�绱㈠凡瀛樺湪鍚嶇О鑷畾涔夋彁绀洪敊璇枃鏈�</param> + /// <param name="confirmAction">鍥炶皟鍑芥暟</param> + /// <param name="List">琚绱㈠垪琛�</param> + /// <param name="confirmAction">鍥炶皟鍑芥暟</param> + public void InputBox(int titleId, string tnputEditTxet, int errorId_IsNullOrEmpty, int errorId_PresenceP, List<string> List, Action<string, Dialog> confirmAction, Action action, bool tag = true) + { + Dialog dialog = new Dialog() + { + BackgroundColor = CSS.CSS_Color.viewTrans60lucence, + }; + + FrameLayout whiteView = new FrameLayout() + { + //Gravity = Gravity.Center, + X = Application.GetRealWidth(53), + Y = Application.GetRealHeight(264), + Width = Application.GetRealWidth(270), + Height = Application.GetRealHeight(172), + BackgroundColor = CSS_Color.view, + BorderColor = CSS_Color.viewTranslucence, + BorderWidth = 0, + Radius = (uint)Application.GetRealHeight(RradiusFrameLayout), + }; + dialog.AddChidren(whiteView); + + Button btnTitle = new Button() + { + Y = Application.GetRealHeight(20), + X = Application.GetRealWidth(35), + Height = Application.GetRealHeight(22), + Width = Application.GetRealWidth(200), + TextColor = CSS_Color.textConfirmColor, + TextSize = TextSize.Text16, + TextAlignment = TextAlignment.Center, + TextID = titleId, + + }; + whiteView.AddChidren(btnTitle); + + FrameLayout editBjView = new FrameLayout() + { + // Gravity = Gravity.CenterHorizontal, + Y = btnTitle.Bottom + Application.GetRealHeight(16), + X = Application.GetRealWidth(24), + Width = Application.GetRealWidth(222), + Height = Application.GetRealHeight(40), + BackgroundColor = CSS_Color.viewMiddle, + BorderColor = CSS_Color.viewTranslucence, + BorderWidth = 0, + Radius = (uint)Application.GetMinRealAverage(radiusEditFrameLayout), + }; + whiteView.AddChidren(editBjView); + + EditText editText = new EditText() + { + X = Application.GetRealWidth(12), + Y = Application.GetRealHeight(10), + Width = Application.GetRealWidth(160), + Height = Application.GetRealHeight(20), + Text = tnputEditTxet, + TextColor = CSS_Color.textColor, + TextSize = TextSize.Text14, + TextAlignment = TextAlignment.CenterLeft, + + }; + editBjView.AddChidren(editText); + + Button clearIconBtn = new Button + { + X = Application.GetRealWidth(194), + Y = Application.GetRealHeight(8), + Width = Application.GetRealWidth(24), + Height = Application.GetRealWidth(24), + UnSelectedImagePath = "MusicIcon/clear.png", + }; + editBjView.AddChidren(clearIconBtn); + clearIconBtn.MouseUpEventHandler += (sender, e) => + { + editText.Text = ""; + }; + + Button btnLine = new Button() + { + Y = whiteView.Height - Application.GetRealHeight(44 + 1), + Height = Application.GetRealHeight(1), + BackgroundColor = CSS_Color.viewLine, + }; + whiteView.AddChidren(btnLine); + + Button btnCancel = new Button() + { + Y = btnLine.Bottom, + Width = Application.GetRealWidth(135), + Height = Application.GetRealHeight(44), + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.textTipColor, + TextSize = TextSize.Text16, + TextID = StringId.cancelMusic, + Gravity = Gravity.BottomLeft, + }; + whiteView.AddChidren(btnCancel); + btnCancel.SetCornerWithSameRadius(Application.GetRealHeight(RradiusFrameLayout), HDLUtils.RectCornerBottomLeft); + Button btnConfirm = new Button() + { + X = btnCancel.Right, + Y = btnLine.Bottom, + Width = Application.GetRealWidth(135), + Height = Application.GetRealHeight(44), + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.view, + IsBold = true, + TextSize = TextSize.Text16, + TextID = StringId.confirmMusic, + BackgroundColor = CSS_Color.textConfirmColor, + Gravity = Gravity.BottomRight, + }; + whiteView.AddChidren(btnConfirm); + btnConfirm.SetCornerWithSameRadius(Application.GetRealHeight(RradiusFrameLayout), HDLUtils.RectCornerBottomRight); + + dialog.Show(); + btnCancel.MouseUpEventHandler += (sender, e) => + { + dialog.Close(); + action(); + + }; + Button btnTip = new Button + { + Width = Application.GetRealWidth(0), + }; + whiteView.AddChidren(btnTip);//涓�鐩撮敊璇紝涓�鐩寸寷鐐癸紝涓�鐩村姞鎺т欢 + btnConfirm.MouseUpEventHandler += (sender, e) => + { + string listNameText = editText.Text.Trim(); + if (string.IsNullOrEmpty(listNameText) || List.Contains(listNameText)) + { + string tipMsgString = ""; + if (string.IsNullOrEmpty(editText.Text.Trim())) + { + tipMsgString = Language.StringByID(errorId_IsNullOrEmpty); + } + else + { + tipMsgString = Language.StringByID(errorId_PresenceP); + } + + whiteView.Height = Application.GetRealHeight(183); + btnLine.Y = whiteView.Height - Application.GetRealHeight(44 + 1); + btnCancel.Y = btnLine.Bottom; + btnCancel.Gravity = Gravity.BottomLeft; + btnConfirm.Y = btnLine.Bottom; + btnConfirm.Gravity = Gravity.BottomRight; + + btnTip.X = Application.GetRealWidth(24); + btnTip.Y = editBjView.Bottom + Application.GetRealHeight(12); + btnTip.Width = Application.GetRealWidth(222); + btnTip.Height = Application.GetRealHeight(17); + btnTip.Text = tipMsgString; + btnTip.TextColor = CSS_Color.textRedColor; + btnTip.TextSize = TextSize.Text12; + btnTip.TextAlignment = TextAlignment.CenterLeft; + + return; + } + + + confirmAction(editText.Text.Trim(), dialog); + if (tag) + { + dialog.Close(); + } + }; + + } /// <summary> /// 杈撳叆妗� -- Gitblit v1.8.0