using System;
|
using HDL_ON.UI.Music;
|
using Shared;
|
namespace HDL_ON.UI.UI2.FuntionControlView.Aks.CommonView
|
{
|
/// <summary>
|
/// 自定义按键容器
|
/// </summary>
|
public class ButtonFramLayout : BaseFramLayout
|
{
|
|
public const int widthFrameLayout = 78;
|
public const int heightFrameLayout = 84;
|
public const int lineW = 1;
|
public const int cornerValue = 8;
|
|
public ButtonFramLayout(int width= widthFrameLayout, int height= heightFrameLayout)
|
{
|
this.Width = Application.GetRealWidth(width);
|
this.Height = Application.GetRealHeight(height);
|
//this.Radius = (uint)Application.GetRealHeight(cornerValue);
|
}
|
|
Button btnImage = new Button
|
{
|
Y = Application.GetRealHeight(12),
|
Width = Application.GetRealWidth(32),
|
Height = Application.GetRealWidth(32),
|
UnSelectedImagePath = "AksIcon/kai.png",
|
Gravity = Gravity.CenterHorizontal,
|
Name = "btnImage",
|
};
|
Button btnName = new Button
|
{
|
Y = Application.GetRealHeight(12 + 32 + 8),
|
Width = Application.GetRealWidth(widthFrameLayout),
|
Height = Application.GetRealHeight(20),
|
TextSize = TextSize.Text14,
|
TextColor = MusicColor.TextColor,
|
TextAlignment = TextAlignment.Center,
|
Gravity = Gravity.CenterHorizontal,
|
Padding = new Padding(0, 20, 0, 20),
|
Name = "btnName",
|
|
|
};
|
Button btnTopLine = new Button
|
{
|
Width = Application.GetRealWidth(widthFrameLayout),
|
Height = Application.GetRealHeight(lineW),
|
BackgroundColor = MusicColor.ViewColor,
|
Name = "btnTopLine",
|
};
|
Button btnBottomLine = new Button
|
{
|
Width = Application.GetRealWidth(widthFrameLayout),
|
Height = Application.GetRealHeight(lineW),
|
BackgroundColor = MusicColor.ViewColor,
|
Name = "btnBottomLine",
|
Y = Application.GetRealHeight(heightFrameLayout - 1),
|
};
|
Button btnLeftLine = new Button
|
{
|
Width = Application.GetRealWidth(lineW),
|
Height = Application.GetRealHeight(heightFrameLayout),
|
BackgroundColor = MusicColor.ViewColor,
|
Name = "btnLeftLine",
|
|
};
|
Button btnRightLine = new Button
|
{
|
Width = Application.GetRealWidth(lineW),
|
Height = Application.GetRealHeight(heightFrameLayout),
|
BackgroundColor = MusicColor.ViewColor,
|
X = Application.GetRealWidth(widthFrameLayout - 1),
|
Name = "btnRightLine",
|
|
};
|
/// <summary>
|
/// 添加布局
|
/// </summary>
|
/// <param name="parent"></param>
|
public void AddView(FrameLayout parent)
|
{
|
parent.AddChidren(this);
|
this.AddChidren(btnImage);
|
this.AddChidren(btnName);
|
}
|
|
public void AddImageView()
|
{
|
this.AddChidren(btnImage);
|
|
}
|
public void AddNameView()
|
{
|
this.AddChidren(btnName);
|
}
|
|
/// <summary>
|
/// 添加左边线
|
/// </summary>
|
public void AddLeftLine()
|
{
|
btnLeftLine.Height = this.Height;
|
this.AddChidren(btnLeftLine);
|
}
|
/// <summary>
|
/// 添加右边线
|
/// </summary>
|
public void AddRightLine()
|
{
|
btnRightLine.Height = this.Height;
|
btnRightLine.X = this.Width - Application.GetRealWidth(1);
|
this.AddChidren(btnRightLine);
|
}
|
|
/// <summary>
|
/// 添加顶部边线
|
/// </summary>
|
public void AddTopLine()
|
{
|
btnTopLine.Width = this.Width;
|
this.AddChidren(btnTopLine);
|
}
|
/// <summary>
|
/// 添加底部边线
|
/// </summary>
|
public void AddBottomLine()
|
{
|
btnBottomLine.Y = this.Height - Application.GetRealHeight(1);
|
btnBottomLine.Width = this.Width;
|
this.AddChidren(btnBottomLine);
|
}
|
|
public Button GetImageButton()
|
{
|
return this.btnImage;
|
}
|
public Button GetNameButton()
|
{
|
return btnName;
|
}
|
|
/// <summary>
|
/// 事件监听方法
|
/// </summary>
|
/// <param name="action">回调(第一个是父类对象;第二个是图标对象;第三个是状态对象</param>
|
public void SetClickListener(Action<FrameLayout, Button, Button> action)
|
{
|
EventHandler<MouseEventArgs> UpClick = (sender, e) =>
|
{
|
this.BackgroundColor = 0x00000000;
|
|
//弹起来还原背景颜色
|
};
|
btnImage.Tag = this.Tag;
|
btnName.Tag = this.Tag;
|
|
this.MouseUpEventHandler += UpClick;
|
btnImage.MouseUpEventHandler += UpClick;
|
btnName.MouseUpEventHandler += UpClick;
|
|
|
//EventHandler<MouseEventArgs> MoveClick = (sender, e) =>
|
//{
|
// this.BackgroundColor = 0x00000000;
|
// //弹起来还原背景颜色
|
//};
|
//this.MouseMoveEventHandler += MoveClick;
|
//btnImage.MouseMoveEventHandler += MoveClick;
|
//btnName.MouseMoveEventHandler += MoveClick;
|
|
EventHandler<MouseEventArgs> DownClick = (sender, e) =>
|
{
|
|
//按下去改变背景颜色
|
this.BackgroundColor = 0xFFEFEFEF;
|
action?.Invoke(this, btnImage, btnName);
|
};
|
|
this.MouseDownEventHandler += DownClick;
|
btnImage.MouseDownEventHandler += DownClick;
|
btnName.MouseDownEventHandler += DownClick;
|
}
|
/// <summary>
|
/// 设置图标
|
/// </summary>
|
/// <param name="stringId"></param>
|
public void SetButtonImage(int stringId)
|
{
|
|
switch (stringId)
|
{
|
case StringId.kai:
|
{
|
this.btnImage.UnSelectedImagePath = "AksIcon/kai.png";
|
}
|
break;
|
}
|
}
|
|
|
}
|
}
|