黄学彪
2019-10-10 2ed75b8b337048e5d75e6d9ec8307633134f02fd
ZigbeeApp/Shared/Phone/Device/CommonForm/DeviceIconSelectedIMGByLocal.cs
@@ -5,86 +5,119 @@
{
    public class DeviceIconSelectedIMGByLocal:FrameLayout
    {
        /// <summary>
        /// bodyFrameLayout
        /// </summary>
        private FrameLayout bodyFrameLayout;
        /// <summary>
        /// action
        /// </summary>
        public Action<string,string > action;
        /// <summary>
        /// tempIcon
        /// </summary>
        private FunctionIconButton tempIcon;
        /// <summary>
        /// DeviceIconSelectedIMGByLocal
        /// </summary>
        public DeviceIconSelectedIMGByLocal()
        {
            BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
        }
        /// <summary>
        /// RemoveFromParent
        /// </summary>
        public override void RemoveFromParent()
        {
            base.RemoveFromParent();
        }
        /// <summary>
        /// Show
        /// </summary>
        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);
            AddTop();
            var title = new Button()
            {
                TextAlignment = TextAlignment.Center,
                TextID = R.MyInternationalizationString.ChangeDeviceInfo,
                TextSize = 20,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                Width = Application.GetRealWidth(CommonPage.AppRealWidth - 500),
                Gravity = Gravity.CenterHorizontal
            };
            topView.AddChidren(title);
            AddBodyView();
        }
            var back = new BackButton { };
            topView.AddChidren(back);
            back.MouseUpEventHandler += (sender, e) =>
        #region Add____________________________________
        /// <summary>
        /// AddTop
        /// </summary>
        public void AddTop()
        {
            var top = new TopFrameLayout();
            AddChidren(top);
            top.InitTopview();
            top.SetTopTitle(R.MyInternationalizationString.SelectIcon);
            top.backButton.MouseUpEventHandler += (sender, e) =>
            {
                this.RemoveFromParent();
                RemoveFromParent();
            };
            #endregion
            #region 选择图片
        }
        /// <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()
            {
                Y=topBGView.Bottom,
                Height=Application.GetRealHeight(CommonPage.AppRealHeight-CommonPage.Navigation_Height),
                Width=Application.GetRealWidth(CommonPage.AppRealWidth-CommonPage.XLeft*2),
                Gravity=Gravity.CenterHorizontal
                Height = Application.GetRealHeight(1450),
                BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor
            };
            AddChidren(scrollView);
            int xWidth = (int)((CommonPage.AppRealWidth - CommonPage.XLeft * 2 - 100) / 3.0);
            bodyFrameLayout.AddChidren(scrollView);
            int k= 0;
            for (int j = 0; j < 8; j++)
            int k = 1;
            tempIcon = new FunctionIconButton();
            for (int j = 0; j < 5; j++)
            {
                var itemView = new FrameLayout()
                {
                    Height = Application.GetRealHeight(xWidth + 50)
                    Height = Application.GetRealHeight(207 + CommonPage.XLeft)
                };
                scrollView.AddChidren(itemView);
                for (int i = 1; i <= 3; i++)
                for (int i = 0; i < 4; i++)
                {
                    var icon = new Device.CommonForm.SelectedStatuButton
                    {
                        X = Application.GetRealWidth((xWidth + 50) * (i-1)),
                        Y = Application.GetRealHeight(50),
                        Width = Application.GetMinRealAverage(xWidth),
                        Height = Application.GetMinRealAverage(xWidth),
                        UnSelectedImagePath = $"DeviceIcon/{k}.png",
                        SelectedImagePath = $"DeviceIcon/{k}Selected.png"
                    };
                    k++;
                    var icon = new FunctionIconButton(58+ i*(207+46), 58);
                    icon.Init($"FunctionIcon/{k}Icon.png", $"FunctionIcon/{k}IconSelected.png");
                    itemView.AddChidren(icon);
                    icon.MouseUpEventHandler += (sender, e) =>
                    k++;
                    EventHandler<MouseEventArgs> selectIcon = (sender, e) =>
                    {
                        action(icon.UnSelectedImagePath,icon.SelectedImagePath);
                        RemoveFromParent();
                        ((sender as Button).Parent as FunctionIconButton).IsSelected = true;
                        tempIcon.IsSelected = false;
                        tempIcon = (sender as Button).Parent as FunctionIconButton;
                    };
                    icon.ImageBG.MouseUpEventHandler += selectIcon;
                    icon.ImageBtn.MouseUpEventHandler += selectIcon;
                }
            }
            #endregion
            var confirmBtn = new CommonForm.CompleteButton(1472, 907, 127);
            confirmBtn.SetTitle(R.MyInternationalizationString.Save);
            bodyFrameLayout.AddChidren(confirmBtn);
            confirmBtn.MouseUpEventHandler += (sender, e) =>
            {
                action(tempIcon.ImageBtn.UnSelectedImagePath, tempIcon.ImageBtn.SelectedImagePath);
                RemoveFromParent();
            };
        }
        #endregion
    }
}