From 9b44e30275621a48335fbea7b32b5065a2859c9c Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期二, 16 三月 2021 16:54:33 +0800
Subject: [PATCH] Merge branch 'WJC' into temp-wxr

---
 HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs |  397 ++++++++++++++++----------------------------------------
 1 files changed, 114 insertions(+), 283 deletions(-)

diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs
index 98c3e74..57fa14e 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs
+++ b/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,93 +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) =>
             {
 
-                #region 鍖哄煙寮规鐣岄潰
-                FrameLayout fLayout = new FrameLayout
+                DeviceSet deviceSet = new DeviceSet();
+                MainPage.BasePageView.AddChidren(deviceSet);
+                deviceSet.Show(() =>
                 {
-                    BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
-                };
-                this.AddChidren(fLayout);
-                fLayout.MouseUpEventHandler += (sender1, e1) =>
-                {
-                    fLayout.RemoveFromParent();
-                };
-
-                FrameLayout iconFLyout = new FrameLayout 
-                {
-                    X = Application.GetRealWidth(205),
-                    Y = Application.GetRealHeight(314),
-                    Width = Application.GetRealWidth(160),
-                    Height = Application.GetRealHeight(21 + 44),
-                    //BackgroundImagePath = "LogicIcon/bjicon.png",
-                };
-                fLayout.AddChidren(iconFLyout);
-
-                FrameLayout textFLyout = new FrameLayout 
-                {
-                    X = Application.GetRealWidth(8),
-                    Y = Application.GetRealHeight(14),
-                    Width = Application.GetRealWidth(144),
-                    Height = Application.GetRealHeight(44),
-                };
-                VerticalScrolViewLayout vv = new VerticalScrolViewLayout 
-                {
-                    X = Application.GetRealWidth(8),
-                    Y = Application.GetRealHeight(14),
-                    Width = Application.GetRealWidth(144),
-                    Height = Application.GetRealHeight(44 * 4),
-                };
-                var pirDeviceList = new List<int> { 1, 2, 3,4,5,6, }; 
-
-                if (pirDeviceList.Count >4)
-                {
-                    iconFLyout.Height = Application.GetRealHeight(21 + 44 * 4);
-                    iconFLyout.AddChidren(vv);
-                    iconFLyout.BackgroundImagePath = "PirIcon/4.png";
-                }
-                else
-                {
-
-                    iconFLyout.AddChidren(textFLyout);
-                    iconFLyout.Height = Application.GetRealHeight(21 + 44 * pirDeviceList.Count);
-                    textFLyout.Height = Application.GetRealHeight(44 * pirDeviceList.Count);
-                    iconFLyout.BackgroundImagePath = $"PirIcon/{pirDeviceList.Count}.png";
-                }
-                #endregion
-
-                for (int i = 0; i < pirDeviceList.Count; i++)
-                {
-                    var room = pirDeviceList[i];
-                    View.PirNameView pirNameView = new View.PirNameView(); 
-                    if (pirDeviceList.Count > 4)
+                    if (Pir.currPir != null)
                     {
-                        vv.AddChidren(pirNameView.FLayoutView());
+                        deviceNameBtn.Text = Pir.currPir.name;
+                        mainView.numberDeviceBtn.Text = Pir.pirDeviceList.Count.ToString() + Language.StringByID(StringId.ge);
                     }
-                    else
+                    int sum = 0;
+                    for (int i = 0; i < Pir.pirDeviceList.Count; i++)
                     {
-                        pirNameView.frameLayout.Y = Application.GetRealHeight(i * 44);
-                        textFLyout.AddChidren(pirNameView.FLayoutView());
+                        sum += Pir.pirDeviceList[i].FunctioList.Count;
                     }
-                    pirNameView.btnName.Text = room.ToString();
-                    pirNameView.btnClick.Tag = room;
-                    pirNameView.btnClick.MouseUpEventHandler += (sender2, e2) =>
-                    {
-                        fLayout.RemoveFromParent();
-                      
-                    };
-                    if (pirDeviceList.Count - 1 == i)
-                    {
-                        ///鏀瑰彉鏈�鍚庨偅鏉′竴涓嚎鐨勯鑹�,鐣岄潰鏄剧ず鏁堟灉浣滅敤;
-                        pirNameView.btnLine.BackgroundColor = CSS.CSS_Color.view;
-                    }
-                }
+                    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++)
             {
@@ -318,12 +168,14 @@
                 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,(control) => {
+                        method.AddControl(this, (control) =>
+                        {
                             AddButton addButton = new AddButton();
                             MainPage.BasePageView.AddChidren(addButton);
                             addButton.Show(control);
@@ -332,43 +184,60 @@
                     }
                     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>
@@ -417,7 +286,7 @@
                     {
                     }
                     break;
-              
+
 
             }
             return strList;
@@ -434,13 +303,13 @@
                 case 1:
                     {
                         //绌鸿皟
-                        type = "ac-"+SPK.AcIr;
+                        type = "ac-" + SPK.AcIr;
                     }
                     break;
                 case 2:
                     {
                         //鐢佃
-                        type = "tv-"+SPK.ElectricTV;
+                        type = "tv-" + SPK.TvIr;
                     }
                     break;
                 case 3:
@@ -452,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;
@@ -534,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) =>
             {
@@ -557,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) =>
@@ -598,53 +472,10 @@
                 else
                 {
                     Method method = new Method();
-                    method.ErrorShow(responsePackNew);
+                    method.ErrorShow(responsePackNew, "");
                 }
             }, id, "鍝佺墝鍒楄〃");
         }
-
-       
-        /// <summary>
-        /// 鑾峰彇绾㈠璁惧鍒楄〃
-        /// </summary>
-        private void GetPirDeviceList( )
-        {
-
-            //鍔犺浇log
-            Loading loading = new Loading();
-            this.AddChidren(loading);
-            HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null;
-            loading.Start();
-            new System.Threading.Thread(() =>
-            {
-                try
-                {
-                    //鍙戦�佹寜閿垹闄わ紱
-                    responsePackNew = PirSend.GetDeviceList("ir.module");
-                }
-                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();
-        }
-
     }
-  
+
 }

--
Gitblit v1.8.0