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; using Sunny.UI; namespace Scada { public partial class UserCounterButton : UIUserControl { private UIStyle Style; private Color defaultFillColor; private Color defaultRectColor; public UserCounterButton() { InitializeComponent(); this.Load += UserCounterButton_Load; } private void UserCounterButton_Load(object? sender, EventArgs e) { UIExtension.SetStyleManager = SetStyle; } private void SetStyle(UIStyleManager manager) { this.btn_Counter.Style = manager.Style; Style = manager.Style; defaultFillColor = this.btn_Counter.FillColor; defaultRectColor = this.btn_Counter.RectColor; } private string buttonName; [Browsable(true)] [Category("自定义属性")] [Description("按钮名称")] public string ButtonName { get { return buttonName; } set { this.btn_Counter.Text = value; } } private int counterButtonSymbol = 61452; [Browsable(true)] [Category("自定义属性")] [Description("图标")] public int CounterButtonSymbol { get { return counterButtonSymbol; } set { this.btn_Counter.Symbol = counterButtonSymbol; } } private bool counterButtonState; [Browsable(true)] [Category("自定义属性")] [Description("按钮的状态")] public bool CounterButtonState { get { return counterButtonState; } set { counterButtonState = value; if (counterButtonState = value) { this.btn_Counter.FillColor = this.btn_Counter.FillPressColor; this.btn_Counter.RectColor = this.btn_Counter.RectPressColor; } else { if (this.btn_Counter.Style != Style) { this.btn_Counter.Style = Style; } else { this.btn_Counter.FillColor = defaultFillColor; this.btn_Counter.RectColor = defaultRectColor; } } } } private string variableName = ""; [Browsable(true)] [Category("自定义属性")] [Description("获取变量名称")] public string VariableName { get { return variableName; } set { variableName = value; } } public event EventHandler? CounterButtonClick; private void btn_Counter_Click(object sender, EventArgs e) { CounterButtonClick?.Invoke(this, e); } } }