陈嘉乐
2021-03-04 0d1b995a55d2c9a049550b28f72ca0265ca588f0
HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs
@@ -24,9 +24,17 @@
            vv.Y = Application.GetRealHeight(64);
            this.AddChidren(vv);
            #endregion
            UIView(vv);
        }
        /// <summary>
        /// 加载UI界面
        /// </summary>
        /// <param name="vv">上下滑控件</param>
        void UIView(VerticalScrolViewLayout vv) {
            vv.RemoveAll();
            int a = 3;
            int b = 3;
            for (int i = 0; i < b; i++)
            for (int i = 0; i < Pir.pirDeviceList.Count; i++)
            {
                #region 红外宝图标 版本号 名称 状态
                FrameLayout fLayout = new FrameLayout
@@ -47,6 +55,8 @@
                    Radius = (uint)Application.GetRealHeight(12),
                };
                fLayout.AddChidren(devfLayout);
                //红外宝图标
                Button priequipmentBtn = new Button
                {
@@ -146,15 +156,33 @@
                    BackgroundColor = CSS.CSS_Color.viewLine,
                };
                devfLayout.AddChidren(lineBtn);
                //点击事件
                FrameLayout clickFram = new FrameLayout
                {
                    Y = Application.GetRealHeight(12),
                    X = Application.GetRealWidth(16),
                    Width = Application.GetRealWidth(375 - 16 * 2),
                    Height = Application.GetRealHeight(92),
                    BackgroundColor = CSS.CSS_Color.view,
                    Radius = (uint)Application.GetRealHeight(12),
                    Tag = Pir.pirDeviceList[i],
                };
                fLayout.AddChidren(clickFram);
                if (b - 1 == i)
                clickFram.MouseUpEventHandler += (sender, e) => {
                    var pirclick = (clickFram.Tag as Pir);
                    NewSwitchView( pirclick,  vv);
                };
                if (Pir.pirDeviceList.Count - 1 == i)
                {
                    //最后一个后面增加间隔背景
                    vv.AddChidren(new FrameLayout { Height = Application.GetRealHeight(20) });
                }
                #endregion
                for (int j = 0; j < a; j++) {
                for (int j = 0; j < a; j++)
                {
                    RowLayout funControlRow = new RowLayout
                    {
                        Y = Application.GetRealHeight(92 + (50 * j)),
@@ -238,7 +266,114 @@
               
            }
        }
        /// <summary>
        /// 加载弹框
        /// </summary>
        /// <param name="pirclick"></param>
        /// <param name="vv"></param>
        void NewSwitchView(Pir pirclick,VerticalScrolViewLayout vv) {
            FrameLayout frame = new FrameLayout { BackgroundColor = CSS.CSS_Color.viewTrans60lucence };
            this.AddChidren(frame);
            SwitchView switchView = new SwitchView();
            switchView.btnOff.TextColor = CSS.CSS_Color.textConfirmColor;
            switchView.FLayoutView(frame, StringId.shanchushebei, StringId.xiugaimingzi, "", (intValue) =>
            {
                if (StringId.xiugaimingzi == intValue)
                {
                    List<string> list = new List<string>();
                    for (int b = 0; b < Pir.pirDeviceList.Count; b++)
                    {
                        list.Add(Pir.pirDeviceList[b].name);
                    }
                    TipPopView tipPopView = new TipPopView();
                    tipPopView.InputBox(StringId.xiugaimingzi, pirclick.name, StringId.nameNull, StringId.NameAlreadyExists, list, (name, view) =>
                    {
                        pirclick.name = name;
                        //加载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(pirclick);
                            }
                            catch { }
                            finally
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    loading.Hide();
                                    if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
                                    {
                                        view.Close();
                                        UIView(vv);
                                    }
                                    else
                                    {
                                        Method method = new Method();
                                        method.ErrorShow(responsePackNew);
                                    }
                                });
                            }
                        })
                        { IsBackground = true }.Start();
                    }, () => {
                        NewSwitchView(pirclick, vv);
                    }, false);
                }
                else
                {
                    string text = Language.StringByID(StringId.shanchushebei) + pirclick.name + "?";
                    TipPopView tipPopView = new TipPopView();
                    tipPopView.TipBox(StringId.tip, text, (dialog) => {
                        //加载log
                        Loading loading = new Loading();
                        dialog.AddChidren(loading);
                        HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null;
                        loading.Start();
                        new System.Threading.Thread(() =>
                        {
                            try
                            {
                                responsePackNew = PirSend.DeleteDevice(pirclick.deviceId);
                            }
                            catch { }
                            finally
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    loading.Hide();
                                    if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
                                    {
                                        dialog.Close();
                                        UIView(vv);
                                    }
                                    else
                                    {
                                        Method method = new Method();
                                        method.ErrorShow(responsePackNew);
                                    }
                                });
                            }
                        })
                        { IsBackground = true }.Start();
                    }, () => {
                        NewSwitchView(pirclick, vv);
                    }, false);
                }
            });
        }
    }
}