From 49248e3bdff0458f8f6f4156d1425bd6f6074e32 Mon Sep 17 00:00:00 2001
From: lss <lsc@hdlchina.com.cn>
Date: 星期二, 17 五月 2022 13:17:21 +0800
Subject: [PATCH] Merge branch 'dev' into lss

---
 HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs |  137 ++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 122 insertions(+), 15 deletions(-)

diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
index 80793fd..342d1d5 100644
--- a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
+++ b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
@@ -10,6 +10,52 @@
     public partial class HomePage
     {
         /// <summary>
+        /// 鏇存柊璁惧鍦ㄧ嚎鐘舵��
+        /// </summary>
+        public static void LoadEvent_RefreshDevcieOnline(Function function)
+        {
+            Application.RunOnMainThread(() =>
+            {
+                if (bodyView != null)
+                {
+                    foreach (var view in bodyView.functionViews)
+                    {
+                        if (view.Tag.ToString() == function.sid)
+                        {
+                            for (int i = 0; i < view.ChildrenCount; i++)
+                            {
+                                if (view.GetChildren(i).GetType() == typeof(Button))
+                                {
+                                    var btn = view.GetChildren(i) as Button;
+                                    if(btn.Tag == null)
+                                    {
+                                        continue;
+                                    }
+                                    if (btn.Tag.ToString() == function.sid)
+                                    {
+                                        if (function.online)
+                                        {
+                                            btn.UnSelectedImagePath = "Collection/Functionbg.png";
+                                            btn.IsSelected = false;
+                                        }
+                                        else
+                                        {
+                                            btn.UnSelectedImagePath = "Collection/FunctionOfflineBg.png";
+                                            btn.IsSelected = false;
+                                        }
+                                    }
+                                    else if (btn.Tag.ToString() == "OnlineTag")
+                                    {
+                                        btn.Visible = !function.online;
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            });
+        }
+        /// <summary>
         /// 鏇存柊涓婚〉澶╂皵
         /// </summary>
         public static void LoadEvent_RefreshAir()
@@ -199,24 +245,20 @@
             //Dome妯″紡
             if (MainPage.NoLoginMode)
             {
-                bodyView.btnLinkStateTip.BackgroundColor = CSS.CSS_Color.MainColor;
                 return;
             }
 
             if (!Control.Ins.GatewayOnline_Local && !Control.Ins.GatewayOnline_Cloud)
             {
                 bodyView.btnLinkStateTip.BackgroundColor = CSS.CSS_Color.LinkTipFail;
+                bodyView.btnLinkStateTip.TextID = StringId.NetworkAnomaly;
+                bodyView.environmentalView.Y = Application.GetRealHeight(8) + btnResidenceName.Bottom;
             }
             else
             {
-                if (Control.Ins.GatewayOnline_Local)
-                {
-                    bodyView.btnLinkStateTip.BackgroundColor = CSS.CSS_Color.LinkTipLocal;
-                }
-                else
-                {
-                    bodyView.btnLinkStateTip.BackgroundColor = CSS.CSS_Color.MainColor;
-                }
+                bodyView.btnLinkStateTip.BackgroundColor = 0x00000000;
+                bodyView.btnLinkStateTip.Text = "";
+                bodyView.environmentalView.Y = Application.GetRealHeight(1) + btnResidenceName.Bottom;
             }
         }
 
@@ -244,11 +286,11 @@
                 function.collect = false;
                 if (SPK.MusicSpkList().Contains(function.spk))//澶勭悊闊充箰涓讳粠鍏崇郴
                 {
-                    if ((function as Music.A31MusicModel).ServerClientType == 1)
-                    {
-                        (function as Music.A31MusicModel).MainPlayCollection = false;
-                        Music.A31MusicModel.Save();
-                    }
+                    //if ((function as Music.A31MusicModel).ServerClientType == 1)
+                    //{
+                    //    (function as Music.A31MusicModel).MainPlayCollection = false;
+                    //    Music.A31MusicModel.Save();
+                    //}
                 }
                 string msg = function.name + Language.StringByID(StringId.CollectionCancelled);
                 LoadDeviceFunctionControlZone();
@@ -346,6 +388,11 @@
                         {
                             if (view.Tag.ToString() == function.sid)
                             {
+                                //if (!function.online)
+                                //{
+                                //    view.UnSelectedImagePath = "Collection/FunctionOfflineBg.png";
+                                //}
+
                                 var state = false;
                                 if (function.spk == SPK.CurtainRoller || function.spk == SPK.CurtainShades || function.spk == SPK.CurtainTrietex ||
                                 function.spk == SPK.CurtainSwitch)//绐楀笜璁惧鏍规嵁鐧惧垎姣斿垽鏂紑鍏崇姸鎬�
@@ -374,7 +421,7 @@
                                         {
                                             if (SPK.MusicSpkList().Contains(function.spk))
                                             {
-                                                btn.Text = (function as Music.A31MusicModel).A31PlayStatus.Title;
+                                                btn.Text =function.GetAttrState("song_name");
                                             }
                                             else
                                             {
@@ -467,6 +514,16 @@
         {
             btnSwitch.MouseUpEventHandler = (sender, e) =>
             {
+                if (!function.online)//绂荤嚎涓嶅厑璁告搷浣�
+                {
+                    new Tip()
+                    {
+                        CloseTime = 1,
+                        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+                        Direction = AMPopTipDirection.None,
+                    }.Show(MainPage.BaseView);
+                    return;
+                }
                 btnSwitch.IsSelected = !btnSwitch.IsSelected;
                 new System.Threading.Thread(() =>
                 {
@@ -520,6 +577,16 @@
         {
             btnSwitch.MouseUpEventHandler = (sender, e) =>
             {
+                if (!function.online)//绂荤嚎涓嶅厑璁告搷浣�
+                {
+                    new Tip()
+                    {
+                        CloseTime = 1,
+                        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+                        Direction = AMPopTipDirection.None,
+                    }.Show(MainPage.BaseView);
+                    return;
+                }
                 if (DB_ResidenceData.Instance.GatewayType == 1)
                 {
                     btnSwitch.IsSelected = !btnSwitch.IsSelected;
@@ -554,6 +621,16 @@
         {
             btnClose.MouseUpEventHandler = (sender, e) =>
             {
+                if (!curtain.online)//绂荤嚎涓嶅厑璁告搷浣�
+                {
+                    new Tip()
+                    {
+                        CloseTime = 1,
+                        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+                        Direction = AMPopTipDirection.None,
+                    }.Show(MainPage.BaseView);
+                    return;
+                }
                 btnClose.IsSelected = true;
                 curtain.trait_on_off.curValue = "off";
                 curtain.SetAttrState(FunctionAttributeKey.Percent, 0);
@@ -564,6 +641,16 @@
 
             btnOpen.MouseUpEventHandler = (sender, e) =>
             {
+                if (!curtain.online)//绂荤嚎涓嶅厑璁告搷浣�
+                {
+                    new Tip()
+                    {
+                        CloseTime = 1,
+                        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+                        Direction = AMPopTipDirection.None,
+                    }.Show(MainPage.BaseView);
+                    return;
+                }
                 btnOpen.IsSelected = true;
                 curtain.trait_on_off.curValue = "on";
                 curtain.SetAttrState(FunctionAttributeKey.Percent, 100);
@@ -584,6 +671,16 @@
             };
             btnUp.MouseUpEventHandler = (sender, e) =>
             {
+                if (!function.online)//绂荤嚎涓嶅厑璁告搷浣�
+                {
+                    new Tip()
+                    {
+                        CloseTime = 1,
+                        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+                        Direction = AMPopTipDirection.None,
+                    }.Show(MainPage.BaseView);
+                    return;
+                }
                 new System.Threading.Thread(() =>
                 {
                     System.Threading.Thread.Sleep(2000);
@@ -605,6 +702,16 @@
             };
             btnDown.MouseUpEventHandler = (sender, e) =>
             {
+                if (!function.online)//绂荤嚎涓嶅厑璁告搷浣�
+                {
+                    new Tip()
+                    {
+                        CloseTime = 1,
+                        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+                        Direction = AMPopTipDirection.None,
+                    }.Show(MainPage.BaseView);
+                    return;
+                }
                 new System.Threading.Thread(() =>
                 {
                     System.Threading.Thread.Sleep(2000);

--
Gitblit v1.8.0