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

97 lines
3.1 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.Controls.Primitives;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Navigation;
  18. using System.Windows.Shapes;
  19. namespace BeDesignerSCADA.CustomerControls
  20. {
  21. /// <summary>
  22. /// TheToggleButton.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class TheToggleButton : ToggleButton, IExecutable
  25. {
  26. public event EventHandler PropertyChange; //声明一个事件
  27. public TheToggleButton()
  28. {
  29. InitializeComponent();
  30. Content = "开关";
  31. Width = 80;
  32. Height = 30;
  33. Style = Application.Current.Resources["DesignToggleButton"] as Style;//FindResource("DesignToggleButton") as Style;
  34. VerticalContentAlignment = VerticalAlignment.Center;
  35. }
  36. public string ControlType => "控件";
  37. private bool isExecuteState;
  38. public bool IsExecuteState
  39. {
  40. get { return isExecuteState; }
  41. set
  42. {
  43. isExecuteState = value;
  44. if (IsExecuteState)
  45. {
  46. Style = Application.Current.Resources["ExecuteToggleButton"] as Style;//FindResource("ExecuteToggleButton") as Style;
  47. Register();
  48. }
  49. }
  50. }
  51. /// <summary>
  52. /// 不勾选时执行代码
  53. /// </summary>
  54. [Category("事件")]
  55. public string UnCheckedExec
  56. {
  57. get { return (string)GetValue(UnCheckedExecProperty); }
  58. set { SetValue(UnCheckedExecProperty, value); }
  59. }
  60. public static readonly DependencyProperty UnCheckedExecProperty =
  61. DependencyProperty.Register("UnCheckedExec", typeof(string), typeof(TheToggleButton), new PropertyMetadata(string.Empty));
  62. /// <summary>
  63. /// 勾选时执行代码
  64. /// </summary>
  65. [Category("事件")]
  66. public string CheckedExec
  67. {
  68. get { return (string)GetValue(CheckedExecProperty); }
  69. set { SetValue(CheckedExecProperty, value); }
  70. }
  71. public static readonly DependencyProperty CheckedExecProperty =
  72. DependencyProperty.Register("CheckedExec", typeof(string), typeof(TheToggleButton), new PropertyMetadata(string.Empty));
  73. public void Register()
  74. {
  75. Checked += TheCheckBox_Checked;
  76. Unchecked += TheCheckBox_Unchecked;
  77. }
  78. private void TheCheckBox_Unchecked(object sender, RoutedEventArgs e)
  79. {
  80. Config.GetInstance().RunJsScipt(UnCheckedExec);
  81. }
  82. private void TheCheckBox_Checked(object sender, RoutedEventArgs e)
  83. {
  84. Config.GetInstance().RunJsScipt(CheckedExec);
  85. }
  86. }
  87. }