陈嘉乐
2021-03-10 1d1cad99a27c9f644c84eb3d376c70bd30a55879
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);