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

TheButton.xaml.cs 2.1 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. 
  2. using BPASmartClient.Compiler;
  3. using BPASmartClient.SCADAControl;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  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. /// TheButton.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class TheButton : Button, IExecutable
  25. {
  26. public event EventHandler PropertyChange; //声明一个事件
  27. public TheButton()
  28. {
  29. InitializeComponent();
  30. Content = "按钮";
  31. Width = 80;
  32. Height = 30;
  33. Style = Application.Current.Resources["DesignButton"] as Style;//FindResource("DesignButton") as Style;
  34. }
  35. public string ControlType => "控件";
  36. private bool isExecuteState;
  37. public bool IsExecuteState
  38. {
  39. get { return isExecuteState; }
  40. set
  41. {
  42. isExecuteState = value;
  43. if (IsExecuteState)
  44. {
  45. Style = null;
  46. Register();
  47. }
  48. }
  49. }
  50. [Category("事件")]
  51. public string ClickExec
  52. {
  53. get { return (string)GetValue(ClickExecProperty); }
  54. set { SetValue(ClickExecProperty, value); }
  55. }
  56. public static readonly DependencyProperty ClickExecProperty =
  57. DependencyProperty.Register("ClickExec", typeof(string), typeof(TheButton), new PropertyMetadata(string.Empty));
  58. /// <summary>
  59. /// 注册需要处理的事件
  60. /// </summary>
  61. public void Register()
  62. {
  63. this.Click += MyButton_Click;
  64. }
  65. private void MyButton_Click(object sender, RoutedEventArgs e)
  66. {
  67. Config.GetInstance().RunJsScipt(ClickExec);
  68. }
  69. }
  70. }