wjc
2023-08-18 c1cb2d8c6034a2ee7aa8a5710bba15b14f76cebc
HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/MenuFramLayout.cs
@@ -1,11 +1,13 @@
using System;
using HDL_ON.UI.Music;
using HDL_ON.UI.UI2.FuntionControlView.Aks.Entity;
using Shared;
namespace HDL_ON.UI.UI2.FuntionControlView.Aks.CommonView
{
    public class MenuFramLayout : BaseFramLayout
    {
        private uint UpBackgroundColor = 0x00000000;
        private uint DownBackgroundColor = 0xff454635;
        public const int widthFrameLayout = 180;
        public const int heightFrameLayout = 180;
        public const int cornerValue = 90;
@@ -16,6 +18,7 @@
            this.Height = Application.GetMinRealAverage(height);
            this.Radius = (uint)Application.GetRealHeight(cornerValue);
            this.BackgroundColor = MusicColor.ViewColor;
            this.Gravity = Gravity.CenterHorizontal;
        }
        Button btnTop = new Button
        {
@@ -24,6 +27,8 @@
            Width = Application.GetRealWidth(24),
            Height = Application.GetRealHeight(20),
            UnSelectedImagePath = "AksIcon/shang.png",
            SelectedImagePath = "AksIcon/shang_selected.png",
            Name = "上",
        };
        Button btnBottom = new Button
        {
@@ -32,6 +37,8 @@
            Width = Application.GetRealWidth(24),
            Height = Application.GetRealHeight(20),
            UnSelectedImagePath = "AksIcon/xia.png",
            SelectedImagePath = "AksIcon/xia_selected.png",
            Name = "下",
        };
        Button btnLeft = new Button
        {
@@ -40,6 +47,8 @@
            Width = Application.GetRealWidth(20),
            Height = Application.GetRealHeight(24),
            UnSelectedImagePath = "AksIcon/zuo.png",
            SelectedImagePath = "AksIcon/zuo_selected.png",
            Name = "左",
        };
        Button btnRight = new Button
@@ -49,6 +58,8 @@
            Width = Application.GetRealWidth(20),
            Height = Application.GetRealHeight(24),
            UnSelectedImagePath = "AksIcon/you.png",
            SelectedImagePath = "AksIcon/you_selected.png",
            Name = "右",
        };
@@ -71,19 +82,165 @@
            Height = Application.GetMinRealAverage(28),
            Radius = (uint)Application.GetRealHeight(14),
            BackgroundColor = MusicColor.SelectedColor,
            Name= "确定"
        };
        public void AddView(FrameLayout layout)
        {
            layout.AddChidren(this);
            this.AddChidren(btnTop);
            this.AddChidren(btnBottom);
            this.AddChidren(btnLeft);
            this.AddChidren(btnRight);
            this.AddChidren(btnOkbj);
            this.AddChidren(btnOk);
            layout.AddChidren(this);
        }
        /// <summary>
        /// 上
        /// </summary>
        /// <param name="action"></param>
        public void SetTopClickListener(Action<KeypadEntity> action)
        {
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
            {
                btnTop.IsSelected = false;
                //弹起来还原背景颜色
            };
            btnTop.MouseUpEventHandler += UpClick;
            EventHandler<MouseEventArgs> DownClick = (sender, e) =>
            {
                //按下去改变背景颜色
                btnTop.IsSelected = true;
                KeypadEntity keypadEntity = new KeypadEntity();
                keypadEntity.name = btnTop.Name;
                keypadEntity.keypad = "key_up";
                action?.Invoke(keypadEntity);
            };
            btnTop.MouseDownEventHandler += DownClick;
        }
        /// <summary>
        /// 下
        /// </summary>
        /// <param name="action"></param>
        public void SetBottomClickListener(Action<KeypadEntity> action)
        {
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
            {
                btnBottom.IsSelected = false;
                //弹起来还原背景颜色
            };
            btnBottom.MouseUpEventHandler += UpClick;
            EventHandler<MouseEventArgs> DownClick = (sender, e) =>
            {
                btnBottom.IsSelected = true;
                KeypadEntity keypadEntity = new KeypadEntity();
                keypadEntity.name = btnBottom.Name;
                keypadEntity.keypad = "key_down";
                action?.Invoke(keypadEntity);
                //按下去改变背景颜色
            };
            btnBottom.MouseDownEventHandler += DownClick;
        }
        /// <summary>
        /// 左
        /// </summary>
        /// <param name="action"></param>
        public void SetLeftClickListener(Action<KeypadEntity> action)
        {
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
            {
                btnLeft.IsSelected = false;
                //弹起来还原背景颜色
            };
            btnLeft.MouseUpEventHandler += UpClick;
            EventHandler<MouseEventArgs> DownClick = (sender, e) =>
            {
                btnLeft.IsSelected = true;
                KeypadEntity keypadEntity = new KeypadEntity();
                keypadEntity.name = btnLeft.Name;
                keypadEntity.keypad = "key_left";
                action?.Invoke(keypadEntity);
                //按下去改变背景颜色
            };
            btnLeft.MouseDownEventHandler += DownClick;
        }
        /// <summary>
        /// 右
        /// </summary>
        /// <param name="action"></param>
        public void SetRightClickListener(Action<KeypadEntity> action)
        {
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
            {
                btnRight.IsSelected = false;
                //弹起来还原背景颜色
            };
            btnRight.MouseUpEventHandler += UpClick;
            EventHandler<MouseEventArgs> DownClick = (sender, e) =>
            {
                //按下去改变背景颜色
                btnRight.IsSelected = true;
                KeypadEntity keypadEntity = new KeypadEntity();
                keypadEntity.name = btnRight.Name;
                keypadEntity.keypad = "key_right";
                action?.Invoke(keypadEntity);
            };
            btnRight.MouseDownEventHandler += DownClick;
        }
        /// <summary>
        /// ok
        /// </summary>
        /// <param name="action"></param>
        public void SetOkClickListener(Action<KeypadEntity> action)
        {
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
            {
                btnOk.BackgroundColor = MusicColor.SelectedColor;// this.UpBackgroundColor;
                //弹起来还原背景颜色
            };
            btnOk.MouseUpEventHandler += UpClick;
            EventHandler<MouseEventArgs> DownClick = (sender, e) =>
            {
                KeypadEntity keypadEntity = new KeypadEntity();
                keypadEntity.name = btnOk.Name;
                keypadEntity.keypad = "key_ok";
                action?.Invoke(keypadEntity);
                //按下去改变背景颜色
                btnOk.BackgroundColor = this.DownBackgroundColor;
            };
            btnOk.MouseDownEventHandler += DownClick;
        }
        public void SetClickUpBackgroundColor(uint backgroundColor)
        {
            this.UpBackgroundColor = backgroundColor;
        }
        public void SetClickDownBackgroundColor(uint backgroundColor)
        {
            this.DownBackgroundColor = backgroundColor;
        }
    }
}