终端一体化运控平台
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.
 
 
 

93 lines
2.7 KiB

  1. using BPASmartClient.Compiler;
  2. using BPASmartClient.SCADAControl;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Navigation;
  17. using System.Windows.Shapes;
  18. namespace BeDesignerSCADA.CustomerControls
  19. {
  20. /// <summary>
  21. /// TheCheckBox.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class TheCheckBox : CheckBox, IExecutable
  24. {
  25. public event EventHandler PropertyChange; //声明一个事件
  26. public TheCheckBox()
  27. {
  28. InitializeComponent();
  29. Content = "勾选框";
  30. VerticalContentAlignment = VerticalAlignment.Center;
  31. }
  32. public string ControlType => "控件";
  33. private bool isExecuteState;
  34. public bool IsExecuteState
  35. {
  36. get { return isExecuteState; }
  37. set
  38. {
  39. isExecuteState = value;
  40. if (IsExecuteState)
  41. {
  42. Register();
  43. }
  44. }
  45. }
  46. /// <summary>
  47. /// 不勾选时执行代码
  48. /// </summary>
  49. [Category("事件")]
  50. public string UnCheckedExec
  51. {
  52. get { return (string)GetValue(UnCheckedExecProperty); }
  53. set { SetValue(UnCheckedExecProperty, value); }
  54. }
  55. public static readonly DependencyProperty UnCheckedExecProperty =
  56. DependencyProperty.Register("UnCheckedExec", typeof(string), typeof(TheCheckBox), new PropertyMetadata(string.Empty));
  57. /// <summary>
  58. /// 勾选时执行代码
  59. /// </summary>
  60. [Category("事件")]
  61. public string CheckedExec
  62. {
  63. get { return (string)GetValue(CheckedExecProperty); }
  64. set { SetValue(CheckedExecProperty, value); }
  65. }
  66. public static readonly DependencyProperty CheckedExecProperty =
  67. DependencyProperty.Register("CheckedExec", typeof(string), typeof(TheCheckBox), new PropertyMetadata(string.Empty));
  68. public void Register()
  69. {
  70. Checked += TheCheckBox_Checked;
  71. Unchecked += TheCheckBox_Unchecked;
  72. }
  73. private void TheCheckBox_Unchecked(object sender, RoutedEventArgs e)
  74. {
  75. Config.GetInstance().RunJsScipt(UnCheckedExec);
  76. }
  77. private void TheCheckBox_Checked(object sender, RoutedEventArgs e)
  78. {
  79. Config.GetInstance().RunJsScipt(CheckedExec);
  80. }
  81. }
  82. }