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

134 rivejä
4.0 KiB

  1. using Opc.Ua;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Linq;
  6. using System.Runtime.CompilerServices;
  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 BPASmartClient.Academy.View
  19. {
  20. /// <summary>
  21. /// DeviceControlView.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class DeviceControlView : Window,INotifyPropertyChanged
  24. {
  25. private volatile static DeviceControlView _Instance;
  26. private static DeviceControlView GetInstance => _Instance ?? (_Instance = new DeviceControlView());
  27. private DeviceControlView()
  28. {
  29. InitializeComponent();
  30. this.DataContext = this;
  31. //this.ValveName = valveName;
  32. //this.CommandState = commandState;
  33. //this.DeviceState = deviceState;
  34. //this.OpenHandler = openHandler;
  35. //this.CloseHandler = closeHandler;
  36. OpenCommand = new BPARelayCommand(() =>
  37. {
  38. OpenHandler?.Invoke();
  39. this.Visibility = Visibility.Hidden;
  40. });
  41. CloseCommand = new(() =>
  42. {
  43. CloseHandler?.Invoke();
  44. this.Visibility = Visibility.Hidden;
  45. });
  46. this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); };
  47. }
  48. #region 属性变更通知
  49. public event PropertyChangedEventHandler? PropertyChanged;
  50. private void OnPropertyChanged([CallerMemberName] string paraName = "")
  51. {
  52. this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(paraName));
  53. }
  54. #endregion
  55. #region Properties
  56. /// <summary>
  57. /// 界面标题
  58. /// </summary>
  59. public string ValveName { get { return _valveName; } set { _valveName = value; OnPropertyChanged(); } }
  60. private string _valveName;
  61. /// <summary>
  62. /// 命令状态
  63. /// </summary>
  64. public string CommandState { get { return _commandState; } set { _commandState = value; OnPropertyChanged(); } }
  65. private string _commandState;
  66. /// <summary>
  67. /// 设备状态
  68. /// </summary>
  69. public string DeviceState { get { return _deviceState; } set { _deviceState = value; OnPropertyChanged(); } }
  70. private string _deviceState;
  71. /// <summary>
  72. /// 点击打开时的动作
  73. /// </summary>
  74. public Action OpenHandler { get; set; }
  75. /// <summary>
  76. /// 点击关闭时的动作
  77. /// </summary>
  78. public Action CloseHandler { get; set; }
  79. #endregion
  80. #region Commands
  81. public BPARelayCommand OpenCommand { get; set; }
  82. public BPARelayCommand CloseCommand { get; set; }
  83. #endregion
  84. /// <summary>
  85. /// 打开对话框前事件处理
  86. /// </summary>
  87. public Action<DeviceControlView> BeforeOpenHandler;
  88. /// <summary>
  89. /// 打开对话框后事件处理
  90. /// </summary>
  91. public Action<DeviceControlView, object> AfterCloseHandler;
  92. #region Events
  93. #endregion
  94. private void Button_Click(object sender, RoutedEventArgs e)
  95. {
  96. //this.Close();
  97. this.Visibility = Visibility.Hidden;
  98. }
  99. public static void Show(string valveName, string commandState, string deviceState, Action openHandler, Action closeHandler)
  100. {
  101. DeviceControlView view = GetInstance;
  102. view.ValveName = valveName;
  103. view.CommandState = commandState;
  104. view.DeviceState = deviceState;
  105. view.OpenHandler = openHandler;
  106. view.CloseHandler = closeHandler;
  107. view.Visibility=Visibility.Visible;
  108. //view.ShowDialog();
  109. }
  110. }
  111. }