wjc
2023-08-01 f8283c8ebef3e0af8bd990c3e86cc9d010ba528e
HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/MenuFramLayout.cs
@@ -5,7 +5,8 @@
{
    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 +17,7 @@
            this.Height = Application.GetMinRealAverage(height);
            this.Radius = (uint)Application.GetRealHeight(cornerValue);
            this.BackgroundColor = MusicColor.ViewColor;
            this.Gravity = Gravity.CenterHorizontal;
        }
        Button btnTop = new Button
        {
@@ -75,15 +77,147 @@
        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<Button> action)
        {
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
            {
                //btnTop.BackgroundColor = this.UpBackgroundColor;
                btnTop.IsSelected = false;
                action?.Invoke(btnTop);
                //弹起来还原背景颜色
            };
            btnTop.MouseUpEventHandler += UpClick;
            EventHandler<MouseEventArgs> DownClick = (sender, e) =>
            {
                //按下去改变背景颜色
                btnTop.BackgroundColor = this.DownBackgroundColor;
            };
            btnTop.MouseDownEventHandler += DownClick;
        }
        /// <summary>
        /// 下
        /// </summary>
        /// <param name="action"></param>
        public void SetBottomClickListener(Action<Button> action)
        {
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
            {
                //btnBottom.BackgroundColor = this.UpBackgroundColor;
                btnBottom.IsSelected = false;
                action?.Invoke(btnBottom);
                //弹起来还原背景颜色
            };
            btnBottom.MouseUpEventHandler += UpClick;
            EventHandler<MouseEventArgs> DownClick = (sender, e) =>
            {
                //按下去改变背景颜色
                btnBottom.BackgroundColor = this.DownBackgroundColor;
            };
            btnBottom.MouseDownEventHandler += DownClick;
        }
        /// <summary>
        /// 左
        /// </summary>
        /// <param name="action"></param>
        public void SetLeftClickListener(Action<Button> action)
        {
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
            {
                //btnLeft.BackgroundColor = this.UpBackgroundColor;
                btnLeft.IsSelected = false;
                action?.Invoke(btnLeft);
                //弹起来还原背景颜色
            };
            btnLeft.MouseUpEventHandler += UpClick;
            EventHandler<MouseEventArgs> DownClick = (sender, e) =>
            {
                //按下去改变背景颜色
                btnLeft.BackgroundColor = this.DownBackgroundColor;
            };
            btnLeft.MouseDownEventHandler += DownClick;
        }
        /// <summary>
        /// 右
        /// </summary>
        /// <param name="action"></param>
        public void SetRightClickListener(Action<Button> action)
        {
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
            {
                //btnRight.BackgroundColor = this.UpBackgroundColor;
                btnRight.IsSelected = false;
                action?.Invoke(btnRight);
                //弹起来还原背景颜色
            };
            btnRight.MouseUpEventHandler += UpClick;
            EventHandler<MouseEventArgs> DownClick = (sender, e) =>
            {
                //按下去改变背景颜色
                btnRight.BackgroundColor = this.DownBackgroundColor;
            };
            btnRight.MouseDownEventHandler += DownClick;
        }
        /// <summary>
        /// ok
        /// </summary>
        /// <param name="action"></param>
        public void SetOkClickListener(Action<Button> action)
        {
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
            {
                btnOk.BackgroundColor = MusicColor.SelectedColor;// this.UpBackgroundColor;
                action?.Invoke(btnOk);
                //弹起来还原背景颜色
            };
            btnOk.MouseUpEventHandler += UpClick;
            EventHandler<MouseEventArgs> DownClick = (sender, e) =>
            {
                //按下去改变背景颜色
                btnOk.BackgroundColor = this.DownBackgroundColor;
            };
            btnOk.MouseDownEventHandler += DownClick;
        }
        public void SetClickUpBackgroundColor(uint backgroundColor)
        {
            this.UpBackgroundColor = backgroundColor;
        }
        public void SetClickDownBackgroundColor(uint backgroundColor)
        {
            this.DownBackgroundColor = backgroundColor;
        }
    }
}