wxr
2020-03-31 002a3f2e9d2f9579c01f88af12bd8a320003569f
HDL_ON/UI/UI2/1-HomePage/HomePage.cs
@@ -10,7 +10,7 @@
    {
        #region 控件列表
        static FrameLayout bodyView;
        static HomePage bodyView;
        /// <summary>
        /// 顶部信息区域
        /// </summary>
@@ -60,17 +60,9 @@
        /// </summary>
        VerticalScrolViewLayout sceneFunctionView;
        /// <summary>
        /// 灯光区域集合
        /// 功能区域集合
        /// </summary>
        static Dictionary<string, FrameLayout> LightViews;
        /// <summary>
        /// 空调区域集合
        /// </summary>
        static Dictionary<string, FrameLayout> AcViews;
        /// <summary>
        /// 窗帘区域集合
        /// </summary>
        static Dictionary<string, FrameLayout> CurtainViews;
        List<FrameLayout> functionViews;
        #endregion
        #region 区域变量
@@ -87,6 +79,8 @@
        }
        public void LoadPage()
        {
            try
        {
            #region topView
            topView = new FrameLayout()
@@ -191,7 +185,6 @@
            environmentalView.AddChidren(btnPm25Values);
            #endregion
            #region msg
            FrameLayout msgView;
            msgView = new FrameLayout()
@@ -244,11 +237,9 @@
                TextAlignment = TextAlignment.CenterLeft,
            };
            msgView.AddChidren(btnMsgTime);
            #endregion
            #endregion
            #region 功能场景切换
            changeView = new FrameLayout()
@@ -295,7 +286,6 @@
                TextAlignment = TextAlignment.Center,
            };
            changeView.AddChidren(btnChangeScene);
            #endregion
            #region ContextView
@@ -306,9 +296,7 @@
            };
            bodyView.AddChidren(contentView);
            LightViews = new Dictionary<string, FrameLayout>();
            AcViews = new Dictionary<string, FrameLayout>();
            CurtainViews = new Dictionary<string, FrameLayout>();
                functionViews = new List<FrameLayout>();
            deviceFunctionView = new VerticalScrolViewLayout();
            contentView.AddChidren(deviceFunctionView);
@@ -321,8 +309,11 @@
            #endregion
            LoadEvent_ChangeShowedFunctionType();
            //刷新功能状态
            DB_ResidenceData.residenceData.RefreshResidenceFunctionStatus();
            }
            catch (Exception ex)
            {
                MainPage.Log($"HomePage LoadPage Error : {ex.Message}");
            }
        }
        /// <summary>
@@ -332,9 +323,7 @@
        {
            #region ContextView
            deviceFunctionView.RemoveAll();
            LightViews.Clear();
            AcViews.Clear();
            CurtainViews.Clear();
            functionViews.Clear();
            var rowView = new FrameLayout();
            try
            {
@@ -374,33 +363,17 @@
                    {
                        UnSelectedImagePath = "Collection/Functionbg.png",
                        SelectedImagePath = "Collection/FunctionOnbg.png",
                        Tag = function.sid
                    };
                    functionView.AddChidren(btnbg);
                    switch (function.functionCategory)
                    {
                        case FunctionType.Light:
                            #region 灯光 Light
                            LightViews.Add(function.sid, functionView);
                            #endregion
                            break;
                        case FunctionType.Curtain:
                            #region 窗帘
                            CurtainViews.Add(function.sid, functionView);
                            #endregion
                            break;
                        case FunctionType.AC:
                            #region 空调 AC
                            AcViews.Add(function.sid, functionView);
                            #endregion
                            break;
                    }
                    functionViews.Add(functionView);
                    LoadDeviceFunctionDiv(functionView, function);
                    index++;
                }
            }
            catch (Exception ex)
            {
                MainPage.Log("homepage erorr : " + ex.Message);
                MainPage.Log("homepage error : " + ex.Message);
            }
            deviceFunctionView.AddChidren(new Button { Height = Application.GetRealHeight(30) });
            #endregion
@@ -446,10 +419,6 @@
                        BackgroundImagePath = (function as Scene).ImagePath,
                    };
                    rowView.AddChidren(functionView);
                    //functionView.Radius = (uint)Application.GetRealWidth(12);
                    //functionView.BorderColor = CSS_Color.BackgroundColor;
                    //functionView.BorderWidth = 1;
                    LoadSceneFunctionDiv(functionView, function);
                    index++;
@@ -538,6 +507,38 @@
                };
                view.AddChidren(btnCollection);
                if (function.functionCategory == FunctionCategory.Curtain)
                {
                    btnIcon.UnSelectedImagePath = "FunctionIcon/Curtain/CurtainIcon.png";
                    btnIcon.SelectedImagePath = "FunctionIcon/Curtain/CurtainOnIcon.png";
                    Button btnCurtainClose;
                    btnCurtainClose = new Button()
                    {
                        X = Application.GetRealWidth(84),
                        Y = Application.GetRealWidth(89),
                        Width = Application.GetRealWidth(44),
                        Height = Application.GetRealWidth(44),
                        UnSelectedImagePath = "FunctionIcon/Curtain/CurtainCloseBlueIcon_Shadow.png",
                        SelectedImagePath = "FunctionIcon/Curtain/CurtainCloseWhiteIcon_Shadow.png",
                    };
                    view.AddChidren(btnCurtainClose);
                    Button btnCurtainOpen;
                    btnCurtainOpen = new Button()
                    {
                        X = btnCurtainClose.Right,
                        Y = Application.GetRealWidth(89),
                        Width = Application.GetRealWidth(44),
                        Height = Application.GetRealWidth(44),
                        UnSelectedImagePath = "FunctionIcon/Curtain/CurtainOpenBlueIcon_Shadow.png",
                        SelectedImagePath = "FunctionIcon/Curtain/CurtainOpenWhiteIcon_Shadow.png",
                    };
                    view.AddChidren(btnCurtainOpen);
                    LoadEvent_ControlCurtain(function as Curtain, btnCurtainClose, btnCurtainOpen);
                }
                else
                {
                Button btnSwitch;
                btnSwitch = new Button()
                {
@@ -552,53 +553,29 @@
                switch (function.functionCategory)
                {
                    case FunctionType.Light:
                        case FunctionCategory.Light:
                        #region 灯光 Light
                        btnIcon.UnSelectedImagePath = "FunctionIcon/Light/LightIcon.png";
                        btnIcon.SelectedImagePath = "FunctionIcon/Light/LightOnIcon.png";
                        LoadRelaySwitchEvent(function, btnSwitch, view);
                        //btnCollection.IsSelected = btnIcon.IsSelected = btnName.IsSelected = btnZone.IsSelected = btnSwitch.IsSelected = (function as Light).state == 1;
                        UpdataLightView(function as Light);
                        //btnSwitch.MouseUpEventHandler += (sender, e) =>
                        //{
                        //    var curState = !btnSwitch.IsSelected;
                        //    for (int i = 0; i < view.ChildrenCount; i++)
                        //    {
                        //        if (view.GetChildren(i).GetType() == typeof(Button))
                        //        {
                        //            var btn = view.GetChildren(i) as Button;
                        //            btn.IsSelected = curState;
                        //        }
                        //    }
                        //    new System.Threading.Thread(() =>
                        //    {
                        //        var light = function as Light;
                        //        light.state = btnSwitch.IsSelected ? 1 : 0;
                        //        Control.Send("write", function, 3);
                        //    })
                        //    { IsBackground = true }.Start();
                        //};
                            UpdataFunctionStates(function as Light);
                        #endregion
                        break;
                    case FunctionType.Curtain:
                        #region 窗帘
                        btnIcon.UnSelectedImagePath = "FunctionIcon/Curtain/CurtainIcon.png";
                        btnIcon.SelectedImagePath = "FunctionIcon/Curtain/CurtainOnIcon.png";
                        #endregion
                        break;
                    case FunctionType.AC:
                        case FunctionCategory.AC:
                        #region 空调 AC
                        btnIcon.UnSelectedImagePath = "FunctionIcon/AC/AcIcon.png";
                        btnIcon.SelectedImagePath = "FunctionIcon/AC/AcOnIcon.png";
                        #endregion
                        break;
                    case FunctionType.FloorHeating:
                        case FunctionCategory.FloorHeating:
                        #region 地热
                        btnIcon.UnSelectedImagePath = "FunctionIcon/FloorHeating/FloorHeatingIcon.png";
                        btnIcon.SelectedImagePath = "FunctionIcon/FloorHeating/FloorHeatingOnIcon.png";
                        #endregion
                        break;
                }
                    LoadEvent_SwitchFunction(function, btnSwitch);
                }
                UpdataFunctionStates(function);
            }
            catch (Exception ex)
            {
@@ -618,20 +595,9 @@
                {
                    UnSelectedImagePath = "Collection/SceneCovered.png",
                    SelectedImagePath = "Collection/SceneCoveredOn.png",
                    //Width = Application.GetRealWidth(165),
                };
                view.AddChidren(btnCoverd);
                btnCoverd.MouseDownEventHandler = (sender, e) => {
                    btnCoverd.IsSelected = true;
                };
                btnCoverd.MouseUpEventHandler = (sender, e) => {
                    new System.Threading.Thread(() => {
                        System.Threading.Thread.Sleep(200);
                        Application.RunOnMainThread(() => {
                            btnCoverd.IsSelected = false;
                        });
                    }) { IsBackground = true }.Start();
                };
                LoadEvent_ControlScene(btnCoverd, function);
                Button btnDelayIcon;
                btnDelayIcon = new Button()
@@ -644,6 +610,17 @@
                };
                view.AddChidren(btnDelayIcon);
                Button btnCollection;
                btnCollection = new Button()
                {
                    X = Application.GetRealWidth(116),
                    Y = Application.GetRealWidth(8),
                    Width = Application.GetMinRealAverage(32),
                    Height = Application.GetMinRealAverage(32),
                    SelectedImagePath = "Collection/CollectionWhiteIcon.png",
                    UnSelectedImagePath = "Collection/CollectionIcon.png",
                };
                view.AddChidren(btnCollection);
                Button btnName;
                btnName = new Button()
                {
@@ -673,17 +650,6 @@
                };
                view.AddChidren(btnZone);
                Button btnCollection;
                btnCollection = new Button()
                {
                    X = Application.GetRealWidth(116),
                    Y = Application.GetRealWidth(8),
                    Width = Application.GetMinRealAverage(32),
                    Height = Application.GetMinRealAverage(32),
                    SelectedImagePath = "Collection/CollectionWhiteIcon.png",
                    UnSelectedImagePath = "Collection/CollectionIcon.png",
                };
                view.AddChidren(btnCollection);
            }
            catch (Exception ex)