终端一体化运控平台
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

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