JLChen
2021-07-06 d72ca686a3e262693f8a6e45e747e8e8da43335b
HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs
@@ -11,14 +11,23 @@
        {
            Tag = "PirView";
        }
        public void Show(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();
            topView.topNameBtn.TextID = StringId.pipeiyaokongqi;
            this.AddChidren(topView.FLayoutView());
            topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); };
            topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
            {
                BrandList brandObj = new BrandList();
                brandObj.Show(brandList, spk);
                this.RemoveFromParent();
            };
            FrameLayout fLayout = new FrameLayout
            {
@@ -96,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,
            };
@@ -116,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,
            };
@@ -132,7 +141,7 @@
                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,
@@ -140,16 +149,18 @@
            fLayout.AddChidren(succeedBtn);
            #endregion
            #region 点击事件
            //表示库列表索引值
            int index= 1;
            //表示测试码索引值
            //表示库列表索引值(目前只20个库)
            int index = 1;
            //表示测试码索引值(目前只测试3个码)
            int code = 1;
            //表示测试最后一个码;
            bool if_bool = false;
            //左
            leftIconBtn.MouseUpEventHandler += (sender, e) =>
            {
                if (index>1) {
                    index--;
                    sumBtn.Text = "(" + index.ToString() + "/20)";
                    sumBtn.Text = $"({index.ToString()}/{libraryList.Count})";
                }
                code = 1;
                GetBtnText(testBtn, code, spk);
@@ -157,30 +168,39 @@
            //右
            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];
                var library = libraryList[index - 1];
                var control = GetControl(spk, testBtn.TextID, library);
                CodeTest(control);
                //发送测试码命令
                Method.ThreadSend(control, (responsePackNew) => { }, "库码测试", "frame", this, null);
                if (code == 3) {
                    //标记最后那个码
                    if_bool = true;
                }
            };
            //控制失败
            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;
                //更新状态
                GetBtnText(testBtn, code, spk);
            };
            //控制成功
@@ -190,17 +210,20 @@
                {
                    code++;
                }
                //更新状态
                GetBtnText(testBtn, code, spk);
                if (code == 3)
                if (if_bool)
                {
                    var library = libraryList[index];
                    var library = libraryList[index-1];
                    var control = GetControl(spk, testBtn.TextID, library);
                    Method method = new Method();
                    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;
                    });
@@ -247,11 +270,11 @@
                        }
                    }
                    break;
                case SPK.ElectricTV:
                case SPK.TvIr:
                    {
                        switch (textInt)
                        {
                            case StringId.dianshi:
                            case StringId.dianyuan:
                                {
                                    key = "on_off";
                                    value = "on";
@@ -259,8 +282,8 @@
                                break;
                            case StringId.yinliangjia:
                                {
                                    key = "on_off";
                                    value = "on";
                                    key = "volume+";
                                    value = "50";
                                }
                                break;
                            case StringId.jingyin:
@@ -284,6 +307,7 @@
            control.type = "library";
            control.status.Add(buttonObj);
            control.deviceId = Pir.currPir.deviceId;
            control.sid = "";
            string[] strings = library.irCode.Split(',');
            for (int arrayStr = 0; arrayStr < strings.Length; arrayStr++) 
            {
@@ -292,47 +316,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>
@@ -368,7 +351,7 @@
                        }
                    }
                    break;
                case SPK.ElectricTV:
                case SPK.TvIr:
                    {
                        switch (code)
                        {