4
wei
2021-03-16 63a1e0dd7fcda5948c26490d5d7e4c84d6dbf99f
HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs
@@ -27,124 +27,10 @@
            middFLayout.Y = Application.GetRealHeight(64);
            middFLayout.Height = Application.GetRealHeight(667 - 64);
            this.AddChidren(middFLayout);
            FrameLayout pirDeviceFLayout = new FrameLayout();
            pirDeviceFLayout.Y = Application.GetRealHeight(12);
            pirDeviceFLayout.X = Application.GetRealWidth(16);
            pirDeviceFLayout.Width = Application.GetRealWidth(343);
            pirDeviceFLayout.Height = Application.GetRealHeight(187);
            pirDeviceFLayout.BackgroundColor = CSS.CSS_Color.view;
            pirDeviceFLayout.Radius = (uint)Application.GetRealHeight(12);
            middFLayout.AddChidren(pirDeviceFLayout);
            //设备管理
            Button text1Btn = new Button
            {
                Y = Application.GetRealHeight(11),
                X = Application.GetRealWidth(16),
                Width = Application.GetRealWidth(120),
                Height = Application.GetRealHeight(20),
                TextSize = TextSize.text14,
                TextColor = CSS.CSS_Color.textConfirmColor,
                TextAlignment = TextAlignment.CenterLeft,
                TextID = StringId.shebeigaunli,
                IsBold = true,
            };
            pirDeviceFLayout.AddChidren(text1Btn);
            Button pirIcon = new Button
            {
                Y = Application.GetRealHeight(47),
                X = Application.GetRealWidth(28),
                Width = Application.GetRealWidth(66),
                Height = Application.GetRealWidth(66),
                UnSelectedImagePath = "PirIcon/Infraredtreasure.png",
            };
            pirDeviceFLayout.AddChidren(pirIcon);
            //mini智能遥控器
            Button text2Btn = new Button
            {
                Y = Application.GetRealHeight(70),
                X = Application.GetRealWidth(112),
                Width = Application.GetRealWidth(120),
                Height = Application.GetRealHeight(20),
                TextSize = TextSize.text14,
                TextColor = CSS.CSS_Color.textTipColor,
                TextAlignment = TextAlignment.CenterLeft,
                Text = "mini智能遥控器",
            };
            pirDeviceFLayout.AddChidren(text2Btn);
            //
            Button numberDeviceBtn = new Button
            {
                Y = Application.GetRealHeight(137),
                X = Application.GetRealWidth(32),
                Width = Application.GetRealWidth(100),
                Height = Application.GetRealHeight(20),
                TextSize = TextSize.text14,
                TextColor = CSS.CSS_Color.textColor,
                TextAlignment = TextAlignment.CenterLeft,
                Text = "1" + Language.StringByID(StringId.ge),
                IsBold = true,
            };
            pirDeviceFLayout.AddChidren(numberDeviceBtn);
            //当前红外遥控设备
            Button numberDeviceTextBtn = new Button
            {
                Y = numberDeviceBtn.Bottom + Application.GetRealHeight(4),
                X = Application.GetRealWidth(32),
                Width = Application.GetRealWidth(100),
                Height = Application.GetRealHeight(14),
                TextSize = TextSize.text10,
                TextColor = CSS.CSS_Color.textCancelColor,
                TextAlignment = TextAlignment.CenterLeft,
                TextID = StringId.dangqianhongwaishebei,
            };
            pirDeviceFLayout.AddChidren(numberDeviceTextBtn);
            //
            Button currDeviceNumberControlBtn = new Button
            {
                Y = Application.GetRealHeight(137),
                X = Application.GetRealWidth(198),
                Width = Application.GetRealWidth(80),
                Height = Application.GetRealHeight(20),
                TextSize = TextSize.text14,
                TextColor = CSS.CSS_Color.textColor,
                TextAlignment = TextAlignment.CenterLeft,
                Text = "1" + Language.StringByID(StringId.ge),
                IsBold = true,
            };
            pirDeviceFLayout.AddChidren(currDeviceNumberControlBtn);
            //已添加遥控器
            Button currDeviceNumberControlTextBtn = new Button
            {
                Y = currDeviceNumberControlBtn.Bottom + Application.GetRealHeight(4),
                X = Application.GetRealWidth(198),
                Width = Application.GetRealWidth(80),
                Height = Application.GetRealHeight(14),
                TextSize = TextSize.text10,
                TextColor = CSS.CSS_Color.textCancelColor,
                TextAlignment = TextAlignment.CenterLeft,
                TextID = StringId.yitianjiayaokongqi,
            };
            pirDeviceFLayout.AddChidren(currDeviceNumberControlTextBtn);
            ///红外宝点击事件
            FrameLayout clickFLayout = new FrameLayout();
            pirDeviceFLayout.AddChidren(clickFLayout);
            clickFLayout.MouseUpEventHandler += (sender, e) =>
            {
                DeviceSet deviceSet = new DeviceSet();
                MainPage.BasePageView.AddChidren(deviceSet);
                deviceSet.Show();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            View.MainView mainView = new View.MainView();
            mainView.Show(middFLayout);
            FrameLayout deviceListFLayout = new FrameLayout();
            deviceListFLayout.Y = pirDeviceFLayout.Bottom + Application.GetRealHeight(12);
            deviceListFLayout.Y = mainView.pirDeviceFLayout.Bottom + Application.GetRealHeight(12);
            deviceListFLayout.X = Application.GetRealWidth(16);
            deviceListFLayout.Width = Application.GetRealWidth(343);
            deviceListFLayout.Height = Application.GetRealHeight(328);
@@ -189,14 +75,57 @@
                UnSelectedImagePath = "PirIcon/dropdown.png",
            };
            deviceListFLayout.AddChidren(dropdownIconBtn);
            #endregion
            deviceNameBtn.MouseUpEventHandler += (sender, e) =>
            if (Pir.pirDeviceList.Count != 0)
            {
                //默认第一个红外宝
                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;
                mainView.numberDeviceBtn.Text = Pir.pirDeviceList.Count.ToString() + Language.StringByID(StringId.ge);
                mainView.currDeviceNumberControlBtn.Text = sum.ToString() + Language.StringByID(StringId.ge);
            }
            ///设备管理的点击事件
            mainView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                DeviceSet deviceSet = new DeviceSet();
                MainPage.BasePageView.AddChidren(deviceSet);
                deviceSet.Show(() =>
                {
                    if (Pir.currPir != null)
                    {
                        deviceNameBtn.Text = Pir.currPir.name;
                        mainView.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;
                    }
                    mainView.currDeviceNumberControlBtn.Text = sum.ToString() + Language.StringByID(StringId.ge);
                });
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            ///红外名称的点击事件
            deviceNameBtn.MouseUpEventHandler += (sender, e) =>
            {
                View.HeigthChangeView heigthChangeView = new View.HeigthChangeView();
                heigthChangeView.Show(this, Pir.pirDeviceList, (pirJson) =>
                {
                    deviceNameBtn.Text = pirJson.name;
                    Pir.currPir = pirJson;
                });
            };
            #endregion
            int line = 0;
            for (int i = 1, j = 0; i <= 7; i++, j++)
            {
@@ -239,52 +168,76 @@
                GetIconAndText(i, deviceIconBtn, iconNameBtn);
                clickBtn.MouseUpEventHandler += (sender, e) =>
                {
                    //1=空调;2=电视;3=风扇;4=机顶盒;5=DVD/EVD/VCD;6=投影仪;7=自定义;
                    int if_value = int.Parse(clickBtn.Tag.ToString());
                    if (if_value == 7)
                    {
                        Method method = new Method();
                        method.AddControl(this);
                        method.AddControl(this, (control) =>
                        {
                            AddButton addButton = new AddButton();
                            MainPage.BasePageView.AddChidren(addButton);
                            addButton.Show(control);
                            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                        });
                    }
                    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++)
                            {
                                string s = brandList[str].brandName;
                                var bool_if = brandSupportStrList.Find((c)=>s.Contains(c));
                                if (bool_if!=null)
                                {
                                    strList.Add(s);
                                }
                            GetDeviceTypeList(true, () =>
                             {
                                 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);
                        }
                    }
                };
            }
        }
        /// <summary>
        /// 设备进入下一级方法
        /// </summary>
        /// <param name="if_value"></param>
        private 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;
                });
            }
            GetDeviceTypeList();
            });
        }
        /// <summary>
        /// 获取品牌支持
        /// </summary>
@@ -333,7 +286,7 @@
                    {
                    }
                    break;
            }
            return strList;
@@ -350,13 +303,13 @@
                case 1:
                    {
                        //空调
                        type = "ac-"+SPK.AcStandard;
                        type = "ac-" + SPK.AcIr;
                    }
                    break;
                case 2:
                    {
                        //电视
                        type = "tv-"+SPK.ElectricTV;
                        type = "tv-" + SPK.TvIr;
                    }
                    break;
                case 3:
@@ -368,22 +321,22 @@
                case 4:
                    {
                        //机顶盒
                      //  type = "set_top_box-" + SPK.ElectricTV;
                        //  type = "set_top_box-" + SPK.ElectricTV;
                    }
                    break;
                case 5:
                    {
                      //影碟机
                      // type = "dvd-" + SPK.ElectricTV;
                        //影碟机
                        // type = "dvd-" + SPK.ElectricTV;
                    }
                    break;
                case 6:
                    {
                        //投影仪
                      //  type = "projector-" + SPK.ElectricTV;
                        //  type = "projector-" + SPK.ElectricTV;
                    }
                    break;
            }
            return type;
@@ -450,7 +403,9 @@
        /// <summary>
        /// 读取红外设备类型列表
        /// </summary>
        private void GetDeviceTypeList()
        /// <param name="tag">标识要不要提示(true=提示)</param>
        /// <param name="action">回调函数</param>
        public  void GetDeviceTypeList(bool tag, Action action)
        {
            PirSend.GetDeviceTypesList(this, (responsePackNew) =>
            {
@@ -473,19 +428,22 @@
                            }
                        }
                    }
                    action();
                }
                else
                {
                    Method method = new Method();
                    method.ErrorShow(responsePackNew);
                    if (tag)
                    {
                        Method method = new Method();
                        method.ErrorShow(responsePackNew, "");
                    }
                }
            }, "", "设备类型列表");
        }
        /// <summary>
        /// 读取红外设备类型的品牌列表
        /// </summary>
        private void GetBrandList(string id,Action<List<Brand>> actionBrand)
        public  void GetBrandList(string id, Action<List<Brand>> actionBrand)
        {
            List<Brand> brandList = new List<Brand>();
            PirSend.GetDeviceTypesList(this, (responsePackNew) =>
@@ -514,11 +472,10 @@
                else
                {
                    Method method = new Method();
                    method.ErrorShow(responsePackNew);
                    method.ErrorShow(responsePackNew, "");
                }
            }, id, "品牌列表");
        }
    }
}