using System; using HDL_ON.UI.Music; using Shared; namespace HDL_ON.UI.UI2.FuntionControlView.Aks.CommonView { public class VerticalBoutonFLayout:BaseFramLayout { /// /// 是否可以点击 /// private bool mIsClick = true; /// /// 设置控制点击事件 /// /// false点击无效 public void setClick(bool isClick) { this.mIsClick = isClick; } public const int widthFrameLayout = 80; public const int heightFrameLayout = 140-15; public const int cornerValue = 12; public VerticalBoutonFLayout(int width = widthFrameLayout, int height = heightFrameLayout) { this.Width = Application.GetRealWidth(width); this.Height = Application.GetRealHeight(height); this.BackgroundColor = MusicColor.ViewColor; Radius = (uint)Application.GetRealHeight(cornerValue); } public FrameLayout ONFLayout = new FrameLayout { Height = Application.GetRealWidth(40), Width = Application.GetRealWidth(40), Radius = (uint)Application.GetRealWidth(20), BackgroundColor = MusicColor.WhiteColor, Gravity = Gravity.CenterHorizontal, }; public Button ONButton = new Button { Text = "ON", Gravity = Gravity.Center, TextColor = MusicColor.MusicTxet14SelectedColor, TextSize = TextSize.Text14, IsBold=true, }; public Button btnName = new Button { Width = Application.GetRealWidth(widthFrameLayout), Height = Application.GetRealHeight(17), TextSize = TextSize.Text12, TextColor = MusicColor.TextColor, TextAlignment = TextAlignment.Center, Gravity = Gravity.CenterHorizontal, Padding = new Padding(0, 8, 0, 8), IsMoreLines = true, Text="none" }; public FrameLayout OFFFLayout = new FrameLayout { Height = Application.GetRealWidth(40), Width = Application.GetRealWidth(40), Radius = (uint)Application.GetRealWidth(20), BackgroundColor = MusicColor.WhiteColor, Gravity = Gravity.CenterHorizontal, }; public Button OFFButton = new Button { Text = "OFF", Gravity = Gravity.Center, TextColor = 0xFFA5AEBC, TextSize = TextSize.Text14, IsBold = true, }; /// /// 添加布局 /// /// public void AddView(FrameLayout parent) { parent.AddChidren(this); this.AddChidren(ONFLayout); ONFLayout.AddChidren(ONButton); this.AddChidren(btnName); this.AddChidren(OFFFLayout); OFFFLayout.AddChidren(OFFButton); ONFLayout.Y = Application.GetRealHeight(11); btnName.Y = ONFLayout.Bottom + Application.GetRealHeight(11); OFFFLayout.Y = btnName.Bottom + Application.GetRealHeight(11); } /// /// 事件监听方法 /// /// 回调(第一个是父类对象;第二个是图标对象 public void SetONClickListener(Action action) { EventHandler UpClick = (sender, e) => { ONFLayout.BackgroundColor = MusicColor.WhiteColor; ONButton.TextColor = MusicColor.MusicTxet14SelectedColor; //弹起来还原背景颜色 }; ONFLayout.MouseUpEventHandler += UpClick; ONButton.MouseUpEventHandler += UpClick; //EventHandler MoveClick = (sender, e) => //{ // this.BackgroundColor = 0x00000000; // //弹起来还原背景颜色 //}; //this.MouseMoveEventHandler += MoveClick; //btnImage.MouseMoveEventHandler += MoveClick; //btnName.MouseMoveEventHandler += MoveClick; EventHandler DownClick = (sender, e) => { //按下去改变背景颜色 ONFLayout.BackgroundColor = MusicColor.MusicTxet14SelectedColor; ONButton.TextColor = MusicColor.WhiteColor; action?.Invoke(ONFLayout, ONButton); }; ONFLayout.MouseDownEventHandler += DownClick; ONButton.MouseDownEventHandler += DownClick; } /// /// 事件监听方法 /// /// 回调(第一个是父类对象;第二个是图标对象 public void SetOFFClickListener(Action action) { EventHandler UpClick = (sender, e) => { action?.Invoke(OFFFLayout, OFFButton); OFFFLayout.BackgroundColor = MusicColor.WhiteColor; OFFButton.TextColor = 0xFFA5AEBC; //弹起来还原背景颜色 }; OFFFLayout.MouseUpEventHandler += UpClick; OFFButton.MouseUpEventHandler += UpClick; EventHandler CancelClick = (sender, e) => { OFFFLayout.BackgroundColor = MusicColor.WhiteColor; OFFButton.TextColor = 0xFFA5AEBC; //弹起来还原背景颜色 }; OFFFLayout.MouseUpOutsideEventHandler += CancelClick; OFFButton.MouseUpOutsideEventHandler += CancelClick; EventHandler DownClick = (sender, e) => { //按下去改变背景颜色 OFFFLayout.BackgroundColor = MusicColor.MusicTxet14SelectedColor; OFFButton.TextColor = MusicColor.WhiteColor; }; OFFFLayout.MouseDownEventHandler += DownClick; OFFButton.MouseDownEventHandler += DownClick; } } }