陈嘉乐
2021-03-16 6a7a5797af489455bbae8db46c30ec229fc2a020
HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs
@@ -78,7 +78,7 @@
            };
            pirDeviceFLayout.AddChidren(text2Btn);
            //
            //红外宝数量
            Button numberDeviceBtn = new Button
            {
                Y = Application.GetRealHeight(137),
@@ -105,7 +105,7 @@
                TextID = StringId.dangqianhongwaishebei,
            };
            pirDeviceFLayout.AddChidren(numberDeviceTextBtn);
            //
            //所有红外宝的遥控器数量
            Button currDeviceNumberControlBtn = new Button
            {
                Y = Application.GetRealHeight(137),
@@ -135,7 +135,7 @@
            ///红外宝点击事件
            FrameLayout clickFLayout = new FrameLayout();
            pirDeviceFLayout.AddChidren(clickFLayout);
            FrameLayout deviceListFLayout = new FrameLayout();
            deviceListFLayout.Y = pirDeviceFLayout.Bottom + Application.GetRealHeight(12);
@@ -174,8 +174,15 @@
            deviceListFLayout.AddChidren(deviceNameBtn);
            if (Pir.pirDeviceList.Count != 0)
            {
                deviceNameBtn.Text = Pir.pirDeviceList[0].name;
                Pir.currPir = Pir.pirDeviceList[0];
                int sum = 0;
                for (int i = 0; i < Pir.pirDeviceList.Count; i++)
                {
                    sum += Pir.pirDeviceList[i].FunctioList.Count;
                }
                deviceNameBtn.Text = Pir.pirDeviceList[0].name;
                numberDeviceBtn.Text = Pir.pirDeviceList.Count.ToString() + Language.StringByID(StringId.ge);
                currDeviceNumberControlBtn.Text = sum.ToString() + Language.StringByID(StringId.ge);
            }
            //下拉图标
@@ -274,17 +281,28 @@
                }
            };
            ///
            clickFLayout.MouseUpEventHandler += (sender, e) =>
            {
                DeviceSet deviceSet = new DeviceSet();
                MainPage.BasePageView.AddChidren(deviceSet);
                deviceSet.Show(() => {
                deviceSet.Show(() =>
                {
                    if (Pir.currPir != null)
                    {
                        deviceNameBtn.Text = Pir.currPir.name;
                        deviceNameBtn.Text = Pir.pirDeviceList[0].name;
                        numberDeviceBtn.Text = Pir.pirDeviceList.Count.ToString() + Language.StringByID(StringId.ge);
                    }
                    int sum = 0;
                    for (int i = 0; i < Pir.pirDeviceList.Count; i++)
                    {
                        sum += Pir.pirDeviceList[i].FunctioList.Count;
                    }
                    currDeviceNumberControlBtn.Text = sum.ToString() + Language.StringByID(StringId.ge);
                });
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
@@ -347,45 +365,61 @@
                    }
                    else
                    {
                        var strings = GetTypeString(if_value).Split('-');
                        var jobDeviceType = DeviceTypeList.Find((c) => c.deviceType == strings[0]);
                        if (jobDeviceType == null)
                        if (DeviceTypeList.Count == 0)
                        {
                            return;
                        }
                        GetBrandList(jobDeviceType.id, (brandList) =>
                        {
                            var brandSupportStrList = GetBrandSupport(if_value);
                            var strList = new List<string>();
                            for (int str = 0; str < brandList.Count; str++)
                            GetDeviceTypeList(true,() =>
                            {
                                string s = brandList[str].brandName;
                                var bool_if = brandSupportStrList.Find((c) => s.Contains(c));
                                if (bool_if != null)
                                {
                                    strList.Add(s);
                                }
                                DeviceTypeViewClick(if_value);
                            }
                            Application.RunOnMainThread(() =>
                            {
                                BrandList brandObj = new BrandList();
                                MainPage.BasePageView.AddChidren(brandObj);
                                brandObj.Show(brandList, strList, strings[1]);
                                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                            });
                        });
                        }
                        else
                        {
                            DeviceTypeViewClick(if_value);
                        }
                    }
                };
            }
            GetDeviceTypeList();
            GetDeviceTypeList(false,() => { });
        }
        /// <summary>
        /// 设备进入下一级方法
        /// </summary>
        /// <param name="if_value"></param>
        void DeviceTypeViewClick(int if_value) {
            var strings = GetTypeString(if_value).Split('-');
            var jobDeviceType = DeviceTypeList.Find((c) => c.deviceType == strings[0]);
            if (jobDeviceType == null)
            {
                return;
            }
            GetBrandList(jobDeviceType.id, (brandList) =>
            {
                var brandSupportStrList = GetBrandSupport(if_value);
                var strList = new List<string>();
                for (int str = 0; str < brandList.Count; str++)
                {
                    string s = brandList[str].brandName;
                    var bool_if = brandSupportStrList.Find((c) => s.Contains(c));
                    if (bool_if != null)
                    {
                        strList.Add(s);
                    }
                }
                Application.RunOnMainThread(() =>
                {
                    BrandList brandObj = new BrandList();
                    MainPage.BasePageView.AddChidren(brandObj);
                    brandObj.Show(brandList, strList, strings[1]);
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                });
            });
        }
        /// <summary>
        /// 获取品牌支持
        /// </summary>
@@ -551,7 +585,9 @@
        /// <summary>
        /// 读取红外设备类型列表
        /// </summary>
        private void GetDeviceTypeList()
        /// <param name="tag">标识要不要提示(true=提示)</param>
        /// <param name="action">回调函数</param>
        private void GetDeviceTypeList(bool tag,Action action)
        {
            PirSend.GetDeviceTypesList(this, (responsePackNew) =>
            {
@@ -574,11 +610,14 @@
                            }
                        }
                    }
                    action();
                }
                else
                {
                    Method method = new Method();
                    method.ErrorShow(responsePackNew);
                    if (tag) {
                        Method method = new Method();
                        method.ErrorShow(responsePackNew,"");
                    }
                }
            }, "", "设备类型列表");
        }
@@ -614,7 +653,7 @@
                else
                {
                    Method method = new Method();
                    method.ErrorShow(responsePackNew);
                    method.ErrorShow(responsePackNew,"");
                }
            }, id, "品牌列表");
        }