You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

99 lines
2.0 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace UserControlLib
{
public partial class UserButton : UserControl
{
public UserButton()
{
InitializeComponent();
}
public string BtnText
{
get
{
return button.Text;
}
set
{
button.Text = value;
}
}
/// <summary>
/// 按钮Tag值变化事件调用方法 由外部触发
/// </summary>
public void ButtonTagValueChanged(string tagTypeId, string value)
{
if (tagTypeId == TagTypeId)
{
Value = value=="true"?true:false;
if (Value)
{
button.BackColor = Color.LightBlue;
}
else
{
button.BackColor = Color.LightGray;
}
}
}
public string GroupId { get; set; }
bool tagValue;
public bool Value
{
get
{
return tagValue;
}
set
{
tagValue = value;
if (tagValue)
{
button.BackColor = Color.LightBlue;
}
else
{
button.BackColor = Color.LightGray;
}
}
}
public string TagTypeId { get; set; }
/// <summary>
/// 按钮单击事件
/// </summary>
public Action<string, bool> TagButtonClickEvent;
private void button_Click(object sender, EventArgs e)
{
TagButtonClickEvent?.Invoke(this.TagTypeId, !Value);
}
}
}