lss
2022-05-17 ae86b09b30621e1a8512c6bcdd7e22e9c67a5402
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;
            }
        }
@@ -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)//窗帘设备根据百分比判断开关状态
@@ -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(() =>
                {
@@ -493,6 +550,14 @@
                        d.Add(FunctionAttributeKey.FadeTime, function.GetAttrState(FunctionAttributeKey.FadeTime));
                        Control.Ins.SendWriteCommand(function, d);
                    }
                    else if (function.spk == SPK.PanelSocket)
                    {
                        if (function.attributes.Find((obj) => obj.key == "on_off_usb") != null)
                        {
                            d.Add("on_off_usb", function.trait_on_off.curValue.ToString());
                        }
                        Control.Ins.SendWriteCommand(function, d);
                    }
                    else
                    {
                        d.Add("on_off", function.trait_on_off.curValue.ToString());
@@ -512,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;
@@ -546,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);
@@ -556,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);
@@ -576,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);
@@ -597,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);