xm
2021-12-01 6d73bf6e816570291865674bef8bce8972e4de3f
HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs
@@ -12,10 +12,10 @@
            Tag = "PirView";
        }
      
        public void Show(List<Brand> brandList,List<Library> libraryList,string spk)
        public void Show(List<Brand> brandList, List<Library> libraryList,string spk)
        {
           
            #region 界面布局
            this.BackgroundColor = CSS.CSS_Color.viewMiddle;
            PirDevice.View.TopView topView = new View.TopView();
@@ -105,10 +105,10 @@
            Button sumBtn = new Button
            {
                Y = Application.GetRealHeight(267),
                X = Application.GetRealWidth(170),
                Width = Application.GetRealWidth(36),
                X = Application.GetRealWidth(136),
                Width = Application.GetRealWidth(104),
                Height = Application.GetRealHeight(17),
                Text = "(1/20)",
                Text = $"(1/{libraryList.Count})",
                TextSize = TextSize.text12,
                TextColor = CSS.CSS_Color.textCancelColor,
            };
@@ -125,7 +125,7 @@
                TextSize = TextSize.text16,
                TextColor = CSS.CSS_Color.textConfirmColor,
                TextAlignment = TextAlignment.Center,
                Radius = (uint)Application.GetRealHeight(44),
                Radius = (uint)Application.GetRealHeight(22),
                BorderWidth = 1,
                BorderColor = CSS.CSS_Color.textConfirmColor,
            };
@@ -141,13 +141,14 @@
                TextSize = TextSize.text16,
                TextColor = CSS.CSS_Color.textWhiteColor,
                TextAlignment = TextAlignment.Center,
                Radius = (uint)Application.GetRealHeight(44),
                Radius = (uint)Application.GetRealHeight(22),
                //BorderWidth = 1,
                //BorderColor = CSS.CSS_Color.textConfirmColor,
                BackgroundColor = CSS.CSS_Color.textConfirmColor,
            };
            fLayout.AddChidren(succeedBtn);
            #endregion
            #region 点击事件
            //表示库列表索引值(目前只20个库)
            int index = 1; 
@@ -160,7 +161,7 @@
            {
                if (index>1) {
                    index--;
                    sumBtn.Text = "(" + index.ToString() + "/20)";
                    sumBtn.Text = $"({index.ToString()}/{libraryList.Count})";
                }
                code = 1;
                GetBtnText(testBtn, code, spk);
@@ -168,36 +169,40 @@
            //右
            rightIconBtn.MouseUpEventHandler += (sender, e) =>
            {
                if (index < 20)
                if (index < libraryList.Count)
                {
                    index++;
                    sumBtn.Text = "(" + index.ToString() + "/20)";
                    sumBtn.Text = $"({index.ToString()}/{libraryList.Count})";
                }
                code = 1;
                GetBtnText(testBtn, code, spk);
            };
            //测试Text
            testBtn.MouseUpEventHandler += (sender, e) =>
            {
                var library = libraryList[index];
               // testBtn.BackgroundColor = CSS.CSS_Color.viewMiddle;
                var library = libraryList[index - 1];
                var control = GetControl(spk, testBtn.TextID, library);
                //发送测试码命令
                CodeTest(control);
                PirMethod.ThreadSend(control, (responsePackNew) => { }, "库码测试", "frame", this, null);
                if (code == 3) {
                    //标记最后那个码
                    if_bool = true;
                }
            };
            testBtn.MouseDownEventHandler += (sender, e) =>
            {
                //testBtn.BackgroundColor = CSS.CSS_Color.textConfirmColor;
            };
            //控制失败
            failedBtn.MouseUpEventHandler += (sender, e) =>
            {
                if (index < 20)
                if (index < libraryList.Count)
                {
                    //先加
                    index++;
                    //更新文本
                    sumBtn.Text = "(" + index.ToString() + "/20)";
                    sumBtn.Text = $"({index.ToString()}/{libraryList.Count})";
                }
                code = 1;
                //更新状态
@@ -214,16 +219,29 @@
                GetBtnText(testBtn, code, spk);
                if (if_bool)
                {
                    var library = libraryList[index];
                    var library = libraryList[index-1];
                    var control = GetControl(spk, testBtn.TextID, library);
                    Method method = new Method();
                    if (spk == SPK.TvIr)
                    {
                        //备注:伟南要求小米电视换掉spk=ir.tvxm(听说是临时解决方案)
                        var brand = brandList.Find((c) => c.id == library.brandId);
                        if (brand != null)
                        {
                            if (brand.brandName.Contains("小米") || brand.brandName.Contains("Xiaomi"))
                            {
                                //更换spk
                                control.spk = "ir.tvxm";
                            }
                        }
                    }
                    PirMethod method = new PirMethod();
                    //发送库添加遥控器命令
                    method.ThreadAddControl(control, this, (cont) =>
                    method.ThreadAddControl(control, this, (device) =>
                    {
                        MainPage.BasePageView.RemoveViewByTag("PirView");
                        AddControlComplete addControlComplete = new AddControlComplete();
                        MainPage.BasePageView.AddChidren(addControlComplete);
                        addControlComplete.Show(cont, true);
                        addControlComplete.Show(device, true);
                        MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                    });
@@ -295,6 +313,136 @@
                        }
                    }
                    break;
                case SPK.FanIr:
                    {
                        switch (textInt)
                        {
                            case StringId.dianyuan:
                                {
                                    key = "on_off";
                                    value = "on";
                                }
                                break;
                            case StringId.fengsuqiehuan:
                                {
                                    key = "speed";
                                    value = "";
                                }
                                break;
                            case StringId.yaotou:
                                {
                                    key = "swing";
                                    value = "";
                                }
                                break;
                        }
                    }
                    break;
                case SPK.PjtIr:
                    {
                        switch (textInt)
                        {
                            case StringId.dianyuan:
                                {
                                    key = "on_off";
                                    value = "on";
                                }
                                break;
                            case StringId.yinliangjia:
                                {
                                    key = "volume+";
                                    value = "";
                                }
                                break;
                            case StringId.yinliangjian:
                                {
                                    key = "volume-";
                                    value = "";
                                }
                                break;
                        }
                    }
                    break;
                case SPK.StbIr:
                    {
                        switch (textInt)
                        {
                            case StringId.dianyuan:
                                {
                                    key = "on_off";
                                    value = "on";
                                }
                                break;
                            case StringId.yinliangjia:
                                {
                                    key = "volume+";
                                    value = "";
                                }
                                break;
                            case StringId.yinliangjian:
                                {
                                    key = "volume-";
                                    value = "";
                                }
                                break;
                        }
                    }
                    break;
                case SPK.DvDIr:
                    {
                    }
                    break;
                case SPK.PurifierIr:
                    {
                        switch (textInt)
                        {
                            case StringId.dianyuan:
                                {
                                    key = "on_off";
                                    value = "on";
                                }
                                break;
                            case StringId.zidong:
                                {
                                    key = "auto";
                                    value = "";
                                }
                                break;
                            case StringId.jingyin:
                                {
                                    key = "mute";
                                    value = "0";
                                }
                                break;
                        }
                    }
                    break;
                case SPK.HeaterIr:
                    {
                        switch (textInt)
                        {
                            case StringId.dianyuan:
                                {
                                    key = "on_off";
                                    value = "on";
                                }
                                break;
                            case StringId.wendujia:
                                {
                                    key = "temp+";
                                    value = "";
                                }
                                break;
                            case StringId.wendujian:
                                {
                                    key = "temp-";
                                    value = "";
                                }
                                break;
                        }
                    }
                    break;
            }
            AttributesStatus buttonObj = new AttributesStatus();
            buttonObj.key = key;
@@ -316,47 +464,6 @@
            }
            return control;
        }
        /// <summary>
        /// 发送库码测试命令
        /// </summary>
        /// <param name="control"></param>
        private void CodeTest(Control control)
        {
            //加载log
            Loading loading = new Loading();
            this.AddChidren(loading);
            HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null;
            loading.Start();
            new System.Threading.Thread(() =>
            {
                try
                {
                    responsePackNew = PirSend.CodeTest(control);
                }
                catch { }
                finally
                {
                    Application.RunOnMainThread(() =>
                    {
                        loading.Hide();
                        if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
                        {
                        }
                        else
                        {
                            //Method method = new Method();
                            //method.ErrorShow(responsePackNew);
                        }
                    });
                }
            })
            { IsBackground = true }.Start();
        }
        /// <summary>
@@ -414,6 +521,121 @@
                        }
                    }
                    break;
                case SPK.FanIr:
                    {
                        switch (code)
                        {
                            case 1:
                                {
                                    textValue = StringId.dianyuan;
                                }
                                break;
                            case 2:
                                {
                                    textValue = StringId.fengsuqiehuan;
                                }
                                break;
                            case 3:
                                {
                                    textValue = StringId.yaotou;
                                }
                                break;
                        }
                    }
                    break;
                case SPK.PjtIr:
                    {
                        switch (code)
                        {
                            case 1:
                                {
                                    textValue = StringId.dianyuan;
                                }
                                break;
                            case 2:
                                {
                                    textValue = StringId.yinliangjia;
                                }
                                break;
                            case 3:
                                {
                                    textValue = StringId.yinliangjian;
                                }
                                break;
                        }
                    }
                    break;
                case SPK.StbIr:
                    {
                        switch (code)
                        {
                            case 1:
                                {
                                    textValue = StringId.dianyuan;
                                }
                                break;
                            case 2:
                                {
                                    textValue = StringId.yinliangjia;
                                }
                                break;
                            case 3:
                                {
                                    textValue = StringId.yinliangjian;
                                }
                                break;
                        }
                    }
                    break;
                case SPK.DvDIr:
                    {
                    }
                    break;
                case SPK.PurifierIr:
                    {
                        switch (code)
                        {
                            case 1:
                                {
                                    textValue = StringId.dianyuan;
                                }
                                break;
                            case 2:
                                {
                                    textValue = StringId.zidong;
                                }
                                break;
                            case 3:
                                {
                                    textValue = StringId.jingyin;
                                }
                                break;
                        }
                    }
                    break;
                case SPK.HeaterIr:
                    {
                        switch (code)
                        {
                            case 1:
                                {
                                    textValue = StringId.dianyuan;
                                }
                                break;
                            case 2:
                                {
                                    textValue = StringId.wendujia;
                                }
                                break;
                            case 3:
                                {
                                    textValue = StringId.wendujian;
                                }
                                break;
                        }
                    }
                    break;
            }
            testBtn.TextID = textValue;
        }