|
- using Opc.Ua;
-
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Runtime.CompilerServices;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
-
- namespace BPASmartClient.Academy.View
- {
- /// <summary>
- /// DeviceControlView.xaml 的交互逻辑
- /// </summary>
- public partial class DeviceControlView : Window,INotifyPropertyChanged
- {
- private volatile static DeviceControlView _Instance;
- private static DeviceControlView GetInstance => _Instance ?? (_Instance = new DeviceControlView());
- private DeviceControlView()
- {
- InitializeComponent();
-
- this.DataContext = this;
-
- //this.ValveName = valveName;
- //this.CommandState = commandState;
- //this.DeviceState = deviceState;
- //this.OpenHandler = openHandler;
- //this.CloseHandler = closeHandler;
-
- OpenCommand = new BPARelayCommand(() =>
- {
- OpenHandler?.Invoke();
- this.Visibility = Visibility.Hidden;
- });
-
- CloseCommand = new(() =>
- {
- CloseHandler?.Invoke();
- this.Visibility = Visibility.Hidden;
- });
-
- this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); };
- }
-
- #region 属性变更通知
- public event PropertyChangedEventHandler? PropertyChanged;
-
- private void OnPropertyChanged([CallerMemberName] string paraName = "")
- {
- this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(paraName));
- }
- #endregion
-
- #region Properties
- /// <summary>
- /// 界面标题
- /// </summary>
- public string ValveName { get { return _valveName; } set { _valveName = value; OnPropertyChanged(); } }
- private string _valveName;
-
- /// <summary>
- /// 命令状态
- /// </summary>
- public string CommandState { get { return _commandState; } set { _commandState = value; OnPropertyChanged(); } }
- private string _commandState;
-
- /// <summary>
- /// 设备状态
- /// </summary>
- public string DeviceState { get { return _deviceState; } set { _deviceState = value; OnPropertyChanged(); } }
- private string _deviceState;
- /// <summary>
- /// 点击打开时的动作
- /// </summary>
- public Action OpenHandler { get; set; }
- /// <summary>
- /// 点击关闭时的动作
- /// </summary>
- public Action CloseHandler { get; set; }
-
- #endregion
-
- #region Commands
- public BPARelayCommand OpenCommand { get; set; }
- public BPARelayCommand CloseCommand { get; set; }
- #endregion
-
-
- /// <summary>
- /// 打开对话框前事件处理
- /// </summary>
- public Action<DeviceControlView> BeforeOpenHandler;
-
- /// <summary>
- /// 打开对话框后事件处理
- /// </summary>
- public Action<DeviceControlView, object> AfterCloseHandler;
-
- #region Events
-
- #endregion
-
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- //this.Close();
- this.Visibility = Visibility.Hidden;
- }
-
- public static void Show(string valveName, string commandState, string deviceState, Action openHandler, Action closeHandler)
- {
- DeviceControlView view = GetInstance;
-
- view.ValveName = valveName;
- view.CommandState = commandState;
- view.DeviceState = deviceState;
- view.OpenHandler = openHandler;
- view.CloseHandler = closeHandler;
- view.Visibility=Visibility.Visible;
- //view.ShowDialog();
- }
- }
- }
|