From f9181a9c8125136f597add7c30cb2ff508d54ba7 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期四, 25 七月 2024 17:34:32 +0800
Subject: [PATCH] 2024年07月25日17:33:40

---
 HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_BrandFunctionListPage.cs |  268 ++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 214 insertions(+), 54 deletions(-)

diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_BrandFunctionListPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_BrandFunctionListPage.cs
index 986a5d1..053765d 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_BrandFunctionListPage.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/AddFunction/Iot_BrandFunctionListPage.cs
@@ -8,8 +8,11 @@
 {
     public class Iot_BrandFunctionListPage :FrameLayout
     {
-
         FrameLayout bodyView;
+
+        FrameLayout contentView;
+
+        FrameLayout optionView;
 
 
         IntegratedBrand_Iot brand_Iot;
@@ -35,22 +38,24 @@
                 };
                 page.LoadPage(brand_Iot);
                 MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
-            }; 
-            new TopViewDiv(bodyView, "鍝佺墝鍚嶇О").LoadTopView_3tyIot(action);
+            };
+            var topView = new TopViewDiv(bodyView, brand_Iot.brandName);
+            topView.maginY = 10;
+            topView.LoadTopView_3tyIot(action);
 
             bodyView.BackgroundColor = CSS_Color.MainBackgroundColor;
 
 
             bodyView.AddChidren(new Button
             {
-                Y = Application.GetRealHeight(64),
+                Y = Application.GetRealHeight(64+10),
                 Height = Application.GetRealHeight(1),
                 BackgroundColor = CSS_Color.DividingLineColor,
             });
 
             Button btnTipText = new Button()
             {
-                Y = Application.GetRealHeight(80),
+                Y = Application.GetRealHeight(80+10),
                 Width = Application.GetRealWidth(347),
                 Height = Application.GetRealHeight(65),
                 Gravity = Gravity.CenterHorizontal,
@@ -59,20 +64,104 @@
                 TextColor = CSS_Color.FirstLevelTitleColor,
                 Padding = new Padding(12,  Application.GetRealWidth(16), 12, Application.GetRealWidth(16)),
                 TextSize = CSS_FontSize.TextFontSize,
-                Text = "榛樿灏嗙涓夋柟鍝佺墝鐨勮澶囧叏閮ㄥ叧鑱斿埌On Pro涓�,鎮ㄤ篃鍙互閫氳繃涓嬫柟鐨勫紑鍏虫寜閿紝杩涜閫夋嫨鎬у叧鑱斻��",
+                Text = "*鎮ㄥ彲浠ュ皢绗笁鏂瑰搧鐗岀殑璁惧鍏宠仈鍒癘n Pro鎮ㄥ綋鍓嶇殑浣忓畢涓娿��",
                 IsMoreLines = true,
                 TextAlignment = TextAlignment.CenterLeft,
             };
             bodyView.AddChidren(btnTipText);
-
-            var contentView = new VerticalRefreshLayout()
+            if (Language.CurrentLanguage != "Chinese")
             {
-                Y = Application.GetRealHeight(150),
-                Height = Application.GetRealHeight(573),
+                btnTipText.Text = "*You can associate third-party branded devices with on Pro's current home.";
+            }
+
+            contentView = new FrameLayout()
+            {
+                Y = Application.GetRealHeight(150+10),
+                Height = Application.GetRealHeight(573-10),
             };
             bodyView.AddChidren(contentView);
 
-            LoadDeviceFunctionControlZone(contentView);
+
+            var waitPage = new Loading();
+            contentView.AddChidren(waitPage);
+            waitPage.Start("");
+            new System.Threading.Thread(() =>
+            {
+                try
+                {
+                    var pack0 = http.Search3tyIotDevice(brand_Iot.companyId);
+                    if(pack0 != null)
+                    {
+
+                    }
+                    var pack = http.Get3tyIotDeviceFunctionList(brand_Iot.companyId);
+                    if (pack != null)
+                    {
+                        if (pack.Code == StateCode.SUCCESS)
+                        {
+                            var list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Function>>(pack.Data.ToString());
+                            Application.RunOnMainThread(() =>
+                            {
+                                LoadDeviceFunctionControlZone(list);
+                            });
+                        }
+                    }
+                }
+                catch { }
+                finally
+                {
+                    Application.RunOnMainThread(() => {
+                        waitPage.Hide();
+                        waitPage.RemoveFromParent();
+                    });
+                }
+            }) { IsBackground = true }.Start();
+
+
+            optionView = new FrameLayout()
+            {
+                Y = Application.GetRealHeight(667 - 80),
+                Height = Application.GetRealHeight(90),
+                Radius = (uint)Application.GetRealWidth(22),
+                //Visible =false,
+            };
+            bodyView.AddChidren(optionView);
+
+
+            var btnComfirm = new Button()
+            {
+                Gravity = Gravity.CenterHorizontal,
+                Y = Application.GetRealHeight(14),
+                Width = Application.GetRealWidth(164),
+                Height = Application.GetRealHeight(44),
+                TextAlignment = TextAlignment.Center,
+                BackgroundColor = CSS_Color.MainColor,
+                TextColor = CSS_Color.MainBackgroundColor,
+                TextSize = CSS_FontSize.SubheadingFontSize,
+                TextID = StringId.Confirm,
+                Radius = (uint)Application.GetRealHeight(22)
+            };
+            optionView.AddChidren(btnComfirm);
+            btnComfirm.MouseUpEventHandler = (sender, e) => {
+
+                var pack = http.Set3tyIotFunctionToHouse(optionList, DB_ResidenceData.Instance.CurrentRegion.id, brand_Iot.companyId);
+                if (pack != null)
+                {
+                    if (pack.Code == StateCode.SUCCESS)
+                    {
+                        optionView.Visible = false;
+                    }
+                }
+                //var pack = http.Set3tyIotFunctionToHouse(function.deviceId, "0", brand_Iot.companyId);
+                //if (pack != null)
+                //{
+                //    if (pack.Code == StateCode.SUCCESS)
+                //    {
+                //        btnName.IsSelected = btnIcon.IsSelected = btnCheckIcon.IsSelected = false;
+                //    }
+                //}
+
+            };
 
 
 
@@ -82,26 +171,32 @@
         /// <summary>
         /// 鍔犺浇璁惧鍔熻兘鏄剧ず鍖哄煙
         /// </summary>
-        void LoadDeviceFunctionControlZone(VerticalRefreshLayout deviceFunctionView)
+        void LoadDeviceFunctionControlZone(List<Function> list)
         {
+            contentView.RemoveAll();
+
+            if (list.Count == 0)
+            {
+                NotListTipView();
+                return;
+            }
+
+            VerticalScrolViewLayout deviceFunctionView = new VerticalScrolViewLayout();
+            contentView.AddChidren(deviceFunctionView);
+
             #region ContextView
             var rowView = new FrameLayout();
             try
             {
                 int index = 0;
-                var list = new List<Function>();
-                list.Add(new Function
-                {
-                    spk = SPK.AcStandard,
-                    name = "绌鸿皟"
-                });
-                list.Add(new Function
-                {
-                    spk = SPK.LightDimming,
-                    name = "鐏厜"
-                });
+              
                 foreach (var function in list)
                 {
+                    if(function.homeId != DB_ResidenceData.Instance.CurrentRegion.id && function.homeId != "0")
+                    {
+                        continue;
+                    }
+
                     if (index % 2 == 0)
                     {
                         rowView = new FrameLayout()
@@ -128,11 +223,11 @@
                     var btnbg = new Button()
                     {
                         UnSelectedImagePath = "Collection/Functionbg.png",
-                        SelectedImagePath = "Collection/FunctionOnbg.png",
+                        SelectedImagePath = "Collection/Functionbg.png",
                         Tag = function.sid
                     };
                     functionView.AddChidren(btnbg);
-                    LoadDeviceFunctionDiv(functionView, function,btnbg);
+                    LoadDeviceFunctionDiv(functionView, function);
                     index++;
 
                 
@@ -143,26 +238,20 @@
                     var view = new FrameLayout();
                     deviceFunctionView.AddChidren(view);
 
-                    var btnNoCollectionBg = new Button()
-                    {
-                        Y = Application.GetRealHeight(20),
-                        Gravity = Gravity.CenterHorizontal,
-                        Width = Application.GetRealWidth(180),
-                        Height = Application.GetRealWidth(180),
-                        Text = "娌℃湁浠讳綍璁惧"
-                    };
-                    view.AddChidren(btnNoCollectionBg);
-
                     var btnNoCollectionTip = new Button()
                     {
                         Height = Application.GetRealHeight(42),
-                        Y = btnNoCollectionBg.Bottom,
+                        Y = Application.GetRealHeight(100),
                         TextAlignment = TextAlignment.Center,
                         TextColor = CSS_Color.PromptingColor1,
                         TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
-                        TextID = StringId.TipNoFunctionCollcetion,
+                        Text = "娌℃湁浠讳綍璁惧"
                     };
                     view.AddChidren(btnNoCollectionTip);
+                    if (Language.CurrentLanguage != "Chinese")
+                    {
+                        btnNoCollectionTip.Text = "No equipment";
+                    }
                 }
             }
             catch (Exception ex)
@@ -171,16 +260,34 @@
             deviceFunctionView.AddChidren(new Button { Height = Application.GetRealHeight(30) });
             #endregion
 
+
+            deviceFunctionView.AddChidren(new Button {
+                Height = Application.GetRealHeight(90),
+            });
+
         }
 
 
         /// <summary>
         /// 鍔犺浇鍔熻兘鎺у埗鍗$墖
         /// </summary>
-        void LoadDeviceFunctionDiv(FrameLayout view, Function function,Button btnBg)
+        void LoadDeviceFunctionDiv(FrameLayout view, Function function)
         {
             try
             {
+
+
+                var btnCheckIcon = new Button()
+                {
+                    X = Application.GetRealWidth(22),
+                    Y = Application.GetRealHeight(16),
+                    Width = Application.GetRealWidth(21),
+                    Height = Application.GetRealWidth(21),
+                    UnSelectedImagePath = "Public/IotCheckIcon.png",
+                    SelectedImagePath = "Public/IotCheckOnIcon.png",
+                };
+                view.AddChidren(btnCheckIcon);
+
                 Button btnIcon;
                 btnIcon = new Button()
                 {
@@ -212,36 +319,89 @@
                 Button btnClick = new Button();
                 view.AddChidren(btnClick);
                 btnClick.MouseUpEventHandler = (sender, e) => {
-                    function.collect = !function.collect;
-                    if (function.collect)
+                    if (optionList.Contains(function.deviceId))
                     {
-                        btnName.IsSelected = btnIcon.IsSelected = btnBg.IsSelected = true;
-                        var pack = http.Set3tyIotFunctionToHouse(function.deviceId, DB_ResidenceData.Instance.CurrentRegion.id);
-                        if (pack != null)
-                        {
-
-                        }
+                        btnCheckIcon.IsSelected = function.collect = false;
+                        optionList.Remove(function.deviceId);
                     }
                     else
                     {
-                        btnName.IsSelected = btnIcon.IsSelected = btnBg.IsSelected = false;
-                        var pack = http.Set3tyIotFunctionToHouse(function.deviceId, "0");
-                        if (pack != null)
-                        {
-
-                        }
+                        btnCheckIcon.IsSelected = function.collect = true;
+                        optionList.Add(function.deviceId);
                     }
-
+                
+                    optionView.Visible =true;
                 };
-
+                if (function.homeId == DB_ResidenceData.Instance.CurrentRegion.id )
+                {
+                    btnCheckIcon.IsSelected = true;
+                    optionList.Add(function.deviceId);
+                }
             }
             catch (Exception ex)
             {
                 MainPage.Log("homepage LoadControlView error : " + ex.Message);
             }
         }
+        /// <summary>
+        /// 璁板綍闇�瑕佹搷浣滅殑鍒楄〃
+        /// </summary>
+        private List<string> optionList = new List<string>();
 
 
+        void NotListTipView()
+        {
+            contentView.RemoveAll();
+            var btnTip = new Button()
+            {
+                Gravity = Gravity.CenterHorizontal,
+                Y = Application.GetRealHeight(88 + 10),
+                Width = Application.GetRealWidth(180),
+                Height = Application.GetRealWidth(180),
+                UnSelectedImagePath = "TipNot.png",
+            };
+            contentView.AddChidren(btnTip);
+
+            var btnTipText = new Button()
+            {
+                Y = Application.GetRealHeight(252),
+                Height = Application.GetRealHeight(52),
+                TextSize = CSS_FontSize.TextFontSize,
+                TextColor = CSS_Color.FirstLevelTitleColor,
+                TextAlignment = TextAlignment.Center,
+                TextID = StringId.TipNotThirdPartyDevice,
+            };
+            contentView.AddChidren(btnTipText);
+
+            var btnAdd = new Button()
+            {
+                Y = Application.GetRealHeight(400),
+                Gravity = Gravity.CenterHorizontal,
+                Width = Application.GetRealWidth(220),
+                Height = Application.GetRealWidth(44),
+                BackgroundColor = CSS_Color.MainColor,
+                TextAlignment = TextAlignment.Center,
+                TextColor = CSS_Color.MainBackgroundColor,
+                TextSize = CSS_FontSize.SubheadingFontSize,
+                IsBold = true,
+                Radius = (uint)Application.GetRealWidth(22),
+                BorderColor = 0x00000000,
+                BorderWidth = 0,
+                Text = "鏌ョ湅璁惧鏀寔鑼冨洿"
+            };
+            //contentView.AddChidren(btnAdd);
+            btnAdd.MouseUpEventHandler = (sender, e) =>
+            {
+                //var page = new AddThirdPartyBrandListpage(brandList);
+                //MainPage.BasePageView.AddChidren(page);
+                //page.LoadPage();
+                //MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+            };
+
+
+
+        }
+
 
         HttpServerRequest http = new HttpServerRequest();
 

--
Gitblit v1.8.0