mac
2024-07-25 3f6685c77beeb12baf840733fb890860f4c26e7c
HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/TypeMultiFramLayout.cs
@@ -3,102 +3,129 @@
using Shared;
namespace HDL_ON.UI.UI2.FuntionControlView.Aks.CommonView
{
    public class TypeMultiFramLayout:BaseFramLayout
    public class TypeMultiFramLayout
    {
        /// <summary>
        /// 是否可以点击
        /// </summary>
        private bool mIsClick = true;
        private uint UpBackgroundColor = 0x00000000;
        private uint DownBackgroundColor = 0xff454635;
        public TypeMultiFramLayout()
        /// <summary>
        /// 设置控制点击事件
        /// </summary>
        /// <param name="isClick">false点击无效</param>
        public void setClick(bool isClick)
        {
            this.BackgroundColor = MusicColor.ViewColor;
            this.Height = Application.GetRealHeight(40);
            this.Radius = (uint)Application.GetRealHeight(20);
            this.mIsClick = isClick;
        }
        Button btnLeftImage = new Button
        private uint UpBackgroundColor =BaseFramLayout.unParentBackgroundColor;
        private uint DownBackgroundColor =BaseFramLayout.seleBackgroundColor;
        /// <summary>
        /// 多个类型容器
        /// </summary>
        public FrameLayout multiFramLayout = new FrameLayout
        {
           X = Application.GetRealWidth(16),
            BackgroundColor = MusicColor.ViewColor,
            X = Application.GetRealWidth(16),
            Width = Application.GetRealWidth(311),
            Height = Application.GetRealHeight(40),
            Radius = (uint)Application.GetRealHeight(20),
        };
        public FrameLayout leftFramLayout = new FrameLayout
        {
            X = Application.GetRealWidth(16),
            Gravity = Gravity.CenterVertical,
            Width = Application.GetRealWidth(139),
            Height = Application.GetRealHeight(23),
            Radius = (uint)Application.GetRealHeight(20),
        };
        public Button btnLeftImage = new Button
        {
            Width = Application.GetRealWidth(16),
            Height = Application.GetRealWidth(16),
            UnSelectedImagePath = "AksIcon/yingku.png",
            UnSelectedImagePath = "AksIcon/shixuqi.png",
            Gravity = Gravity.CenterVertical,
            Name = "btnLeftImage",
            Name = "btnBottonLeftImage",
        };
        Button btnName1 = new Button
        public Button btnLeftName = new Button
        {
            Width = Application.GetRealWidth(32),
            Width = Application.GetRealWidth(100 + 10),
            Height = Application.GetRealHeight(23),
            TextID = StringId.shixuqi,
            TextSize = TextSize.Text16,
            TextColor = MusicColor.TextColor,
            TextAlignment = TextAlignment.Center,
            TextAlignment = TextAlignment.CenterLeft,
            Gravity = Gravity.CenterVertical,
            IsMoreLines = true,
            Name = "btnName",
        };
        Button btnRightImage = new Button
        public FrameLayout lineFramLayout = new FrameLayout
        {
            BackgroundColor = MusicColor.TextColor,
            Y = Application.GetRealHeight(10),
            Width = Application.GetRealWidth(1),
            Height = Application.GetRealHeight(20),
        };
        public FrameLayout rightFramLayout = new FrameLayout
        {
            Gravity = Gravity.CenterVertical,
            Width = Application.GetRealWidth(138),
            Height = Application.GetRealHeight(23),
            Radius = (uint)Application.GetRealHeight(20),
        };
        public Button btnRightImage = new Button
        {
            Width = Application.GetRealWidth(16),
            Height = Application.GetRealWidth(16),
            UnSelectedImagePath = "AksIcon/yingkunext.png",
            Gravity = Gravity.CenterVertical,
            Name = "btnRightImage",
            UnSelectedImagePath = "AksIcon/xuanze.png",
            Gravity = Gravity.CenterRight,
        };
        public void AddBtnLeftImage()
        public Button btnRightName = new Button
        {
            this.AddChidren(btnLeftImage);
            Width = Application.GetRealWidth(100 + 16),
            Height = Application.GetRealHeight(23),
            TextID = StringId.bofangqi,
            TextSize = TextSize.Text16,
            TextColor = MusicColor.TextColor,
            TextAlignment = TextAlignment.CenterRight,
            Gravity = Gravity.CenterVertical,
            Padding = new Padding(0, 0, 0, 0),
        };
        public void AddView(FrameLayout layout)
        {
            layout.AddChidren(multiFramLayout);
            multiFramLayout.AddChidren(leftFramLayout);
            leftFramLayout.AddChidren(btnLeftImage);
            leftFramLayout.AddChidren(btnLeftName);
            multiFramLayout.AddChidren(lineFramLayout);
            multiFramLayout.AddChidren(rightFramLayout);
            rightFramLayout.AddChidren(btnRightImage);
            rightFramLayout.AddChidren(btnRightName);
            btnLeftName.X = btnLeftImage.Right + Application.GetRealWidth(4);
            lineFramLayout.X = leftFramLayout.Right;
            rightFramLayout.X = lineFramLayout.Right;
            btnRightName.X = Application.GetRealWidth(4);
        }
        public void AddBtnName(int gap = 4)
        {
            if (this.IsAddBtn(btnLeftImage))
            {
                btnName1.X = btnLeftImage.Right + Application.GetRealWidth(gap);
            }
            //if (btnName.GetTextWidth() < btnName.Width)
            //{
            //    btnName.Width = btnName.GetTextWidth();
            //}
            this.AddChidren(btnName1);
        }
        public void AddBtnRightImage(int gap = 8)
        {
            if (this.IsAddBtn(btnName1))
            {
                btnRightImage.X = btnName1.Right + Application.GetRealWidth(gap);
                if (gap == 8)
                {
                    btnRightImage.Width = Application.GetRealWidth(5);
                    btnRightImage.Height = Application.GetRealHeight(8);
                }
            }
            this.AddChidren(btnRightImage);
        }
        public Button GetBtnLeftImage()
        {
            return btnLeftImage;
        }
        public Button GetBtnName()
        {
            return btnName1;
        }
        public Button GetBtnRightImage()
        {
            return btnRightImage;
        }
        public void SetClickUpBackgroundColor(uint backgroundColor)
        {
@@ -112,64 +139,63 @@
        }
        /// <summary>
        /// 事件监听方法
        /// 序时器类型容器
        /// </summary>
        /// <param name="action">回调(第一个是父类对象;第二个是图标对象;第三个是状态对象</param>
        public void SetClickListener(Action<FrameLayout, Button, Button, Button> action)
        /// <param name="action">回调(第一个是父类对象</param>
        public void SetLeftFlClickListener(Action<FrameLayout> action)
        {
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
            {
                this.BackgroundColor = this.UpBackgroundColor;
                action?.Invoke(this, btnLeftImage, btnName1, btnRightImage);
                //leftFramLayout.BackgroundColor = this.UpBackgroundColor;
                //弹起来还原背景颜色
            };
            this.MouseUpEventHandler += UpClick;
            leftFramLayout.MouseUpEventHandler += UpClick;
            btnLeftImage.MouseUpEventHandler += UpClick;
            btnName1.MouseUpEventHandler += UpClick;
            btnRightImage.MouseUpEventHandler += UpClick;
            btnLeftName.MouseUpEventHandler += UpClick;
            EventHandler<MouseEventArgs> DownClick = (sender, e) =>
            {
                //按下去改变背景颜色
                this.BackgroundColor = this.DownBackgroundColor;
                //leftFramLayout.BackgroundColor = this.DownBackgroundColor;
                action?.Invoke(leftFramLayout);
            };
            this.MouseDownEventHandler += DownClick;
            leftFramLayout.MouseDownEventHandler += DownClick;
            btnLeftImage.MouseDownEventHandler += DownClick;
            btnName1.MouseDownEventHandler += DownClick;
            btnRightImage.MouseDownEventHandler += DownClick;
            btnLeftName.MouseDownEventHandler += DownClick;
        }
        /// <summary>
        /// 在父布局查找子控件是否存在
        /// 播放器类型容器
        /// </summary>
        /// <param name="btn">查找对象</param>
        /// <returns>存在为true,否则为false</returns>
        private bool IsAddBtn(View btn)
        /// <param name="action">回调(第一个是父类对象</param>
        public void SetRightFlClickListener(Action<FrameLayout> action)
        {
            if (this.ChildrenCount <= 0 || btn == null)
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
            {
                return false;
            }
            for (int i = 0; i < this.ChildrenCount; i++)
                action?.Invoke(rightFramLayout);
                //rightFramLayout.BackgroundColor = this.UpBackgroundColor;
                //弹起来还原背景颜色
            };
            rightFramLayout.MouseUpEventHandler += UpClick;
            btnRightImage.MouseUpEventHandler += UpClick;
            btnRightName.MouseUpEventHandler += UpClick;
            EventHandler<MouseEventArgs> DownClick = (sender, e) =>
            {
                View view = this.GetChildren(i);
                if (view == null)
                {
                    continue;
                }
                if (view is Button)
                {
                    if (view.Name == btn.Name)
                    {
                        return true;
                    }
                }
                //按下去改变背景颜色
                //rightFramLayout.BackgroundColor =AksCommonMethod.seleBackgroundColor;
            }
            return false;
            };
            rightFramLayout.MouseDownEventHandler += DownClick;
            btnRightImage.MouseDownEventHandler += DownClick;
            btnRightName.MouseDownEventHandler += DownClick;
        }
    }
}