Davin
2023-07-25 b2a498cb445dc28d09c07e6c57eb298e3c7f7b16
HDL_ON/UI/UI2/1-HomePage/HomePage.cs
@@ -80,6 +80,10 @@
        /// </summary>
        Button btnChangeScene;
        /// <summary>
        /// 切换显示场组控按钮
        /// </summary>
        Button btnChangeGroupControl;
        /// <summary>
        /// 功能显示区域
        /// </summary>
        PageLayout contentView;
@@ -92,6 +96,10 @@
        /// </summary>
        VerticalScrolViewLayout sceneFunctionView;
        /// <summary>
        /// 组控控制区域
        /// </summary>
        VerticalScrolViewLayout gcFunctionView;
        /// <summary>
        /// 功能区域集合
        /// </summary>
        List<FrameLayout> functionViews;
@@ -100,8 +108,11 @@
#region 区域变量
        /// <summary>
        /// 当前显示对控制类型是否是设备功能控制
        /// 0 功能
        /// 1 场景
        /// 2 群控
        /// </summary>
        bool CurShowTypeIsFunction = true;
        int CurShowTypeContent = 0;
#endregion
#region 报警信息
@@ -117,6 +128,11 @@
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
            this.VerticalScrollBarEnabled = false;
#if DEBUG
            DB_ResidenceData.Instance.HomeGateway.isSupportGroupControl = true;
#endif
#if __IOS__
            //自动偏移取消
            if (UIKit.UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
@@ -144,10 +160,7 @@
                    bodyView.EndHeaderRefreshing();
                    Common.ApiUtlis.Ins.DownloadData();
                    LoadContentView();
                    if (!CurShowTypeIsFunction)
                    {
                        contentView.PageIndex = 1;
                    }
                    contentView.PageIndex = CurShowTypeContent;
                };
                topView = new FrameLayout()
                {
@@ -167,10 +180,7 @@
                    refreshLayout.EndHeaderRefreshing();
                    Common.ApiUtlis.Ins.DownloadData();
                    LoadContentView();
                    if(!CurShowTypeIsFunction)
                    {
                        contentView.PageIndex = 1;
                    }
                    contentView.PageIndex = CurShowTypeContent;
                };
                topView = new FrameLayout()
                {
@@ -289,7 +299,7 @@
                            deviceId = enviTemp.deviceId,
                            attributes = new List<FunctionAttributes> { new FunctionAttributes { key = "value", state = humiAttr.state, curValue = humiAttr.curValue } },
                        };
                        humiSensorList.Add(newTemp);
                        humiSensorList.Add(newTemp);//020103CF594C3E00051F0001051F//   1650546588519424001
                    }
                    var tempAttr = enviTemp.attributes.Find((obj) => obj.key == "temperature");
                    if (tempAttr != null)
@@ -301,7 +311,7 @@
                            deviceId = enviTemp.deviceId,
                            attributes = new List<FunctionAttributes> { new FunctionAttributes { key = "value", state = tempAttr.state, curValue = tempAttr.curValue } },
                        };
                        tempSensorList.Add(newTemp);
                        tempSensorList.Add(newTemp);//020103CF594C3E00051F0001051F
                    }
                }
@@ -359,7 +369,10 @@
                    foreach (var temp in tempSensorList)
                    {
                        double tempValue = 0;
                        double.TryParse(temp.GetAttrState("temperature"), out tempValue);
                        if (temp.GetAttribute("temperature") != null)
                            double.TryParse(temp.GetAttrState("temperature"), out tempValue);
                        else
                            double.TryParse(temp.GetAttrState("value"), out tempValue);
                        if (tempValue > 0)
                        {
                            tempTotalValues += tempValue;
@@ -413,7 +426,10 @@
                    foreach (var humi in humiSensorList)
                    {
                        double humiValue = 0;
                        double.TryParse(humi.GetAttrState("humidity"), out humiValue);
                        if (humi.GetAttribute("temperature") != null)
                            double.TryParse(humi.GetAttrState("humidity"), out humiValue);
                        else
                            double.TryParse(humi.GetAttrState("value"), out humiValue);
                        if (humiValue > 0)
                        {
                            humiTotalValues += humiValue;
@@ -449,7 +465,8 @@
                };
                btnPm25Values.Width = btnPm25Values.GetTextWidth();
                environmentalView.AddChidren(btnPm25Values);
#endregion
                #endregion
                btnSecurityStatus = new Button()
                {
@@ -553,54 +570,127 @@
                bodyView.AddChidren(new Button() { Height = Application.GetRealHeight(20), BackgroundColor = 0x00000000 });
                changeView = new FrameLayout()
                if (DB_ResidenceData.Instance.HomeGateway.isSupportGroupControl)
                {
                    //Y = Application.GetRealHeight(20) + topView.Bottom,
                    Gravity = Gravity.CenterHorizontal,
                    Width = Application.GetRealWidth(230),
                    Height = Application.GetRealHeight(62),
                    BackgroundImagePath = "Collection/ChangeViewbg.png",
                };
                bodyView.AddChidren(changeView);
                    changeView = new FrameLayout()
                    {
                        //Y = Application.GetRealHeight(20) + topView.Bottom,
                        Gravity = Gravity.CenterHorizontal,
                        Width = Application.GetRealWidth(334),
                        Height = Application.GetRealHeight(62),
                        BackgroundImagePath = "Collection/ChangeViewbg.png",
                    };
                    bodyView.AddChidren(changeView);
                btnChangeFunction = new Button()
                    btnChangeFunction = new Button()
                    {
                        X = Application.GetRealWidth(10),
                        Width = Application.GetRealWidth(114 - 10),
                        TextID = StringId.Functions,
                        SelectedTextColor = CSS_Color.MainColor,
                        TextColor = CSS_Color.PromptingColor1,
                        TextSize = CSS_FontSize.HeadlineFontSize,
                        TextAlignment = TextAlignment.Center,
                        IsSelected = true,
                        IsBold = true,
                    };
                    changeView.AddChidren(btnChangeFunction);
                    Button btnLine = new Button()
                    {
                        X = btnChangeFunction.Right,
                        Gravity = Gravity.CenterVertical,
                        Width = Application.GetRealWidth(1),
                        Height = Application.GetRealHeight(14),
                        BackgroundColor = CSS_Color.PromptingColor1,
                    };
                    changeView.AddChidren(btnLine);
                    btnChangeScene = new Button()
                    {
                        X = btnLine.Right,
                        Width = Application.GetRealWidth(114 - 10),
                        TextID = StringId.Scenes,
                        SelectedTextColor = CSS_Color.MainColor,
                        TextColor = CSS_Color.PromptingColor1,
                        TextSize = CSS_FontSize.TextFontSize,
                        TextAlignment = TextAlignment.Center,
                    };
                    changeView.AddChidren(btnChangeScene);
                    Button btnLine2 = new Button()
                    {
                        X = btnChangeScene.Right,
                        Gravity = Gravity.CenterVertical,
                        Width = Application.GetRealWidth(1),
                        Height = Application.GetRealHeight(14),
                        BackgroundColor = CSS_Color.PromptingColor1,
                    };
                    changeView.AddChidren(btnLine2);
                    btnChangeGroupControl = new Button()
                    {
                        X = btnLine2.Right,
                        Width = Application.GetRealWidth(114 - 10),
                        TextID = StringId.GroupControl,
                        SelectedTextColor = CSS_Color.MainColor,
                        TextColor = CSS_Color.PromptingColor1,
                        TextSize = CSS_FontSize.TextFontSize,
                        TextAlignment = TextAlignment.Center,
                    };
                    changeView.AddChidren(btnChangeGroupControl);
                }
                else
                {
                    X = Application.GetRealWidth(10),
                    Width = Application.GetRealWidth(114-10),
                    TextID = StringId.Functions,
                    SelectedTextColor = CSS_Color.MainColor,
                    TextColor = CSS_Color.PromptingColor1,
                    TextSize = CSS_FontSize.HeadlineFontSize,
                    TextAlignment = TextAlignment.Center,
                    IsSelected = true,
                    IsBold = true,
                };
                changeView.AddChidren(btnChangeFunction);
                    changeView = new FrameLayout()
                    {
                        //Y = Application.GetRealHeight(20) + topView.Bottom,
                        Gravity = Gravity.CenterHorizontal,
                        Width = Application.GetRealWidth(230),
                        Height = Application.GetRealHeight(62),
                        BackgroundImagePath = "Collection/ChangeViewbg.png",
                    };
                    bodyView.AddChidren(changeView);
                Button btnLine = new Button()
                {
                    X = btnChangeFunction.Right,
                    Gravity = Gravity.CenterVertical,
                    Width = Application.GetRealWidth(1),
                    Height = Application.GetRealHeight(14),
                    BackgroundColor = CSS_Color.PromptingColor1,
                };
                changeView.AddChidren(btnLine);
                    btnChangeFunction = new Button()
                    {
                        X = Application.GetRealWidth(10),
                        Width = Application.GetRealWidth(114 - 10),
                        TextID = StringId.Functions,
                        SelectedTextColor = CSS_Color.MainColor,
                        TextColor = CSS_Color.PromptingColor1,
                        TextSize = CSS_FontSize.HeadlineFontSize,
                        TextAlignment = TextAlignment.Center,
                        IsSelected = true,
                        IsBold = true,
                    };
                    changeView.AddChidren(btnChangeFunction);
                btnChangeScene = new Button()
                {
                    X = btnLine.Right,
                    Width = Application.GetRealWidth(114-10),
                    TextID = StringId.Scenes,
                    SelectedTextColor = CSS_Color.MainColor,
                    TextColor = CSS_Color.PromptingColor1,
                    TextSize = CSS_FontSize.TextFontSize,
                    TextAlignment = TextAlignment.Center,
                };
                changeView.AddChidren(btnChangeScene);
#endregion
                    Button btnLine = new Button()
                    {
                        X = btnChangeFunction.Right,
                        Gravity = Gravity.CenterVertical,
                        Width = Application.GetRealWidth(1),
                        Height = Application.GetRealHeight(14),
                        BackgroundColor = CSS_Color.PromptingColor1,
                    };
                    changeView.AddChidren(btnLine);
#region ContextView
                    btnChangeScene = new Button()
                    {
                        X = btnLine.Right,
                        Width = Application.GetRealWidth(114 - 10),
                        TextID = StringId.Scenes,
                        SelectedTextColor = CSS_Color.MainColor,
                        TextColor = CSS_Color.PromptingColor1,
                        TextSize = CSS_FontSize.TextFontSize,
                        TextAlignment = TextAlignment.Center,
                    };
                    changeView.AddChidren(btnChangeScene);
                }
                #endregion
                #region ContextView
                contentView = new PageLayout()
                {
                    //Y = changeView.Bottom,
@@ -613,7 +703,7 @@
                LoadContentView();
#endregion
                #endregion
            }
            catch (Exception ex)
            {
@@ -627,6 +717,7 @@
        /// </summary>
        void LoadContentView()
        {
            if (!Common.ApiUtlis.Ins.DownloadDataComplete && !MainPage.NoLoginMode)
            {
                var waitPage = new Loading();
@@ -654,12 +745,12 @@
                            sceneFunctionView = new VerticalScrolViewLayout();
                            contentView.AddChidren(sceneFunctionView);
                            LoadSceneFunctionControlZone();
                            if (CurShowTypeIsFunction)
                            contentView.PageIndex = CurShowTypeContent;
                            if (DB_ResidenceData.Instance.HomeGateway.isSupportGroupControl)
                            {
                                contentView.PageIndex = 0;
                            }else
                            {
                                contentView.PageIndex = 1;
                                gcFunctionView = new VerticalScrolViewLayout();
                                contentView.AddChidren(gcFunctionView);
                                LoadGroupControlFunctionControlZone();
                            }
                            LoadEvent_ChangeShowedFunctionType();
@@ -691,15 +782,13 @@
                sceneFunctionView = new VerticalScrolViewLayout();
                contentView.AddChidren(sceneFunctionView);
                LoadSceneFunctionControlZone();
                if (CurShowTypeIsFunction)
                if (DB_ResidenceData.Instance.HomeGateway.isSupportGroupControl)
                {
                    contentView.PageIndex = 0;
                    gcFunctionView = new VerticalScrolViewLayout();
                    contentView.AddChidren(gcFunctionView);
                    LoadGroupControlFunctionControlZone();
                }
                else
                {
                    contentView.PageIndex = 1;
                }
                contentView.PageIndex = CurShowTypeContent;
                LoadEvent_ChangeShowedFunctionType();
@@ -717,7 +806,7 @@
        /// </summary>
        void LoadDeviceFunctionControlZone()
        {
#region ContextView
            #region ContextView
            deviceFunctionView.RemoveAll();
            functionViews.Clear();
            var rowView = new FrameLayout();
@@ -726,7 +815,7 @@
                int index = 0;
                var list = new List<Function>();
                list.AddRange(FunctionList.List.GetDeviceFunctionList());
                list.AddRange(FunctionList.List.groupControls);//加入群控
                //list.AddRange(FunctionList.List.groupControls);//加入群控
                foreach (var function in list)
                {
                    //音乐模块有主从关系,需要特殊处理
@@ -819,9 +908,94 @@
                MainPage.Log("homepage error : " + ex.Message);
            }
            deviceFunctionView.AddChidren(new Button { Height = Application.GetRealHeight(30) });
#endregion
            #endregion
        }
        /// <summary>
        /// 加载群控功能显示区域
        /// </summary>
        void LoadGroupControlFunctionControlZone()
        {
            #region ContextView
            gcFunctionView.RemoveAll();
            functionViews.Clear();
            var rowView = new FrameLayout();
            try
            {
                int index = 0;
                foreach (var function in FunctionList.List.groupControls)
                {
                    if (index % 2 == 0)
                    {
                        rowView = new FrameLayout()
                        {
                            Height = Application.GetRealWidth(140),
                        };
                        gcFunctionView.AddChidren(rowView);
                    }
                    var functionView_X = Application.GetRealWidth((182 + 7) * (index % 2));
                    if (index % 2 == 0)
                    {
                        functionView_X += Application.GetRealWidth(7);
                    }
                    var functionView = new FrameLayout()
                    {
                        X = functionView_X,
                        Width = Application.GetRealWidth(182),
                        Height = Application.GetRealWidth(140),
                        Radius = (uint)Application.GetRealWidth(12),
                        Tag = function.sid
                    };
                    rowView.AddChidren(functionView);
                    functionViews.Add(functionView);
                        var btnbg = new Button()
                        {
                            UnSelectedImagePath = "Collection/Functionbg.png",
                            SelectedImagePath = "Collection/FunctionOnbg.png",
                            Tag = function.sid
                        };
                        functionView.AddChidren(btnbg);
                        LoadDeviceFunctionDiv(functionView, function);
                    index++;
                }
                if (index == 0)
                {
                    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),
                        UnSelectedImagePath = "Collection/NoCollectionBg.png",
                    };
                    view.AddChidren(btnNoCollectionBg);
                    var btnNoCollectionTip = new Button()
                    {
                        Height = Application.GetRealHeight(42),
                        Y = btnNoCollectionBg.Bottom,
                        TextAlignment = TextAlignment.Center,
                        TextColor = CSS_Color.PromptingColor1,
                        TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                        //TextID = StringId.TipNoFunctionCollcetion,
                    };
                    view.AddChidren(btnNoCollectionTip);
                }
            }
            catch (Exception ex)
            {
                MainPage.Log("homepage error : " + ex.Message);
            }
            gcFunctionView.AddChidren(new Button { Height = Application.GetRealHeight(30) });
            #endregion
        }
        /// <summary>
        /// 加载场景功能显示区域
        /// </summary>
@@ -1047,7 +1221,8 @@
                    SelectedImagePath = "Collection/CollectionWhiteIcon.png",
                    UnSelectedImagePath = "Collection/CollectionIcon.png",
                };
                view.AddChidren(btnCollection);
                if (function.spk != SPK.GroupControl)//群控默认显示
                    view.AddChidren(btnCollection);
                //2020-12-16 如果是成员隐藏收藏功能
                //if (!DB_ResidenceData.Instance.CurrentRegion.isOtherShare)
                //{
@@ -1210,11 +1385,11 @@
                    btnIcon.UnSelectedImagePath = UI2.FuntionControlView.VideoDoorLock.CommonMethod.Current.GetVideoDoorLockIcon(UI2.FuntionControlView.VideoDoorLock.CommonMethod.Comerom.collect);
                    //btnIcon.SelectedImagePath = $"FunctionIcon/Icon/HomeIcon/{function.IconName}_blue.png";
                }
                else if (function.spk == SPK.GroupControl)
                {
                    btnIcon.UnSelectedImagePath = $"FunctionIcon/Icon/HomeIcon/lightswitch_blue.png";
                    btnIcon.SelectedImagePath = $"FunctionIcon/Icon/HomeIcon/lightswitch_white.png";
                }
                //else if (function.spk == SPK.GroupControl)
                //{
                //    btnIcon.UnSelectedImagePath = $"FunctionIcon/Icon/HomeIcon/lightswitch_blue.png";
                //    btnIcon.SelectedImagePath = $"FunctionIcon/Icon/HomeIcon/lightswitch_white.png";
                //}
                else
                {
                    Button btnSwitch;