HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2019-10-10 2ed75b8b337048e5d75e6d9ec8307633134f02fd
ZigbeeApp/Shared/Phone/Device/Category/CategorySceneSelectImgByLocal.cs
@@ -1,78 +1,111 @@
using System;
using Shared.Common;
using Shared.Phone.Device.CommonForm;
namespace Shared.Phone.Device.Category
{
    public class CategorySceneSelectImgByLocal:FrameLayout
    {
        /// <summary>
        /// bodyFrameLayout
        /// </summary>
        private FrameLayout bodyFrameLayout;
        public  Action action;
        public CategorySceneSelectImgByLocal()
        {
            BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
        }
        public override void RemoveFromParent()
        {
            base.RemoveFromParent();
        }
        public void Show()
        {
            #region topview
            var topBGView = new FrameLayout()
            {
                Height = Application.GetRealHeight(CommonPage.Navigation_Height),
                BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor
            };
            AddChidren(topBGView);
            var topView = new FrameLayout()
            {
                Y = Application.GetRealHeight(CommonPage.NavigationTitle_Y),
                Height = Application.GetRealHeight(CommonPage.Navigation_Height - CommonPage.NavigationTitle_Y),
                BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor,
            };
            AddChidren(topView);
            var title = new Button()
            {
                TextAlignment = TextAlignment.Center,
                TextID = R.MyInternationalizationString.SelectPic,
                TextSize = 20,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                Width = Application.GetRealWidth(CommonPage.AppRealWidth - 500),
                Gravity = Gravity.CenterHorizontal
            };
            topView.AddChidren(title);
            AddTop();
            var back = new Device.CommonForm.BackButton() { };
            topView.AddChidren(back);
            back.MouseUpEventHandler += (sender, e) =>
            {
                this.RemoveFromParent();
            };
            #endregion
            #region midFL
            var midFl = new VerticalScrolViewLayout()
            {
                Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.Navigation_Height),
                Y = topView.Bottom,
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
            };
            this.AddChidren(midFl);
            for (int i = 0; i < 17; i++)
            {
                var RoomRowView = new FrameLayout()
                {
                    Y=midFl.Bottom,
                    Height = Application.GetRealHeight(430),
                    BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
                };
                midFl.AddChidren(RoomRowView);
                var backGroundBtn = new Button()
                {
                    Y = Application.GetRealHeight(30),
                    Width = Application.GetMinRealAverage(CommonPage.AppRealWidth - CommonPage.XLeft * 2),
                    Height = Application.GetMinRealAverage(400),
                    Gravity=Gravity.CenterHorizontal,
                    UnSelectedImagePath = "Scene/Scene" + i.ToString() + ".png",
                    Radius = CommonPage.BigFormRadius
                };
                RoomRowView.AddChidren(backGroundBtn);
                backGroundBtn.MouseUpEventHandler += (sender, e) =>
                {
                    CategoryAddScene.ImagePath = backGroundBtn.UnSelectedImagePath;
                    Room.AddRoomScene.ImagePath = backGroundBtn.UnSelectedImagePath;
                    action?.Invoke();
                    this.RemoveFromParent();
                };
            }
            #endregion
            AddBodyView();
        }
        #region Add____________________________________
        /// <summary>
        /// AddTop
        /// </summary>
        public void AddTop()
        {
            var top = new TopFrameLayout();
            AddChidren(top);
            top.InitTopview();
            top.SetTopTitle(R.MyInternationalizationString.SelectScenePic);
            top.backButton.MouseUpEventHandler += (sender, e) =>
            {
                RemoveFromParent();
            };
        }
        /// <summary>
        /// AddBodyView
        /// </summary>
        public void AddBodyView()
        {
            bodyFrameLayout = new FrameLayout()
            {
                Y = Application.GetRealHeight(184),
                Height = Application.GetRealHeight(1737),
                BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor
            };
            AddChidren(bodyFrameLayout);
            //FunctionIconButton
            var scrollView = new VerticalScrolViewLayout()
            {
                Height = Application.GetRealHeight(1737),
                BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor
            };
            bodyFrameLayout.AddChidren(scrollView);
            int k = 1;
            for (int j = 0; j < 2; j++)
            {
                var itemView = new FrameLayout()
                {
                    Height = Application.GetRealHeight(311 + CommonPage.XLeft)
                };
                scrollView.AddChidren(itemView);
                for (int i = 0; i < 2; i++)
                {
                    var icon = new Button()
                    {
                        X=Application.GetRealWidth(CommonPage.XLeft+i*(467+32)),
                        Width=Application.GetMinRealAverage(467),
                        Height=Application.GetMinRealAverage(311),
                        Gravity=Gravity.CenterVertical,
                        UnSelectedImagePath = $"SceneIcon/{k}.png",
                    };
                    itemView.AddChidren(icon);
                    k++;
                    EventHandler<MouseEventArgs> selectIcon = (sender, e) =>
                    {
                        CategoryAddScene.ImagePath = icon.UnSelectedImagePath;
                        Room.AddRoomScene.ImagePath = icon.UnSelectedImagePath;
                        action?.Invoke();
                        action = null;
                        this.RemoveFromParent();
                    };
                    icon.MouseUpEventHandler += selectIcon;
                }
            }
        }
        #endregion
    }
}