UserCounterButton.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using Sunny.UI;
  11. namespace Scada
  12. {
  13. public partial class UserCounterButton : UIUserControl
  14. {
  15. private UIStyle Style;
  16. private Color defaultFillColor;
  17. private Color defaultRectColor;
  18. public UserCounterButton()
  19. {
  20. InitializeComponent();
  21. this.Load += UserCounterButton_Load;
  22. }
  23. private void UserCounterButton_Load(object? sender, EventArgs e)
  24. {
  25. UIExtension.SetStyleManager = SetStyle;
  26. }
  27. private void SetStyle(UIStyleManager manager)
  28. {
  29. this.btn_Counter.Style = manager.Style;
  30. Style = manager.Style;
  31. defaultFillColor = this.btn_Counter.FillColor;
  32. defaultRectColor = this.btn_Counter.RectColor;
  33. }
  34. private string buttonName;
  35. [Browsable(true)]
  36. [Category("自定义属性")]
  37. [Description("按钮名称")]
  38. public string ButtonName
  39. {
  40. get { return buttonName; }
  41. set { this.btn_Counter.Text = value; }
  42. }
  43. private int counterButtonSymbol = 61452;
  44. [Browsable(true)]
  45. [Category("自定义属性")]
  46. [Description("图标")]
  47. public int CounterButtonSymbol
  48. {
  49. get { return counterButtonSymbol; }
  50. set { this.btn_Counter.Symbol = counterButtonSymbol; }
  51. }
  52. private bool counterButtonState;
  53. [Browsable(true)]
  54. [Category("自定义属性")]
  55. [Description("按钮的状态")]
  56. public bool CounterButtonState
  57. {
  58. get { return counterButtonState; }
  59. set
  60. {
  61. counterButtonState = value;
  62. if (counterButtonState = value)
  63. {
  64. this.btn_Counter.FillColor = this.btn_Counter.FillPressColor;
  65. this.btn_Counter.RectColor = this.btn_Counter.RectPressColor;
  66. }
  67. else
  68. {
  69. if (this.btn_Counter.Style != Style)
  70. {
  71. this.btn_Counter.Style = Style;
  72. }
  73. else
  74. {
  75. this.btn_Counter.FillColor = defaultFillColor;
  76. this.btn_Counter.RectColor = defaultRectColor;
  77. }
  78. }
  79. }
  80. }
  81. private string variableName = "";
  82. [Browsable(true)]
  83. [Category("自定义属性")]
  84. [Description("获取变量名称")]
  85. public string VariableName
  86. {
  87. get { return variableName; }
  88. set { variableName = value; }
  89. }
  90. public event EventHandler? CounterButtonClick;
  91. private void btn_Counter_Click(object sender, EventArgs e)
  92. {
  93. CounterButtonClick?.Invoke(this, e);
  94. }
  95. }
  96. }