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
{
///
/// DeviceControlView.xaml 的交互逻辑
///
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
///
/// 界面标题
///
public string ValveName { get { return _valveName; } set { _valveName = value; OnPropertyChanged(); } }
private string _valveName;
///
/// 命令状态
///
public string CommandState { get { return _commandState; } set { _commandState = value; OnPropertyChanged(); } }
private string _commandState;
///
/// 设备状态
///
public string DeviceState { get { return _deviceState; } set { _deviceState = value; OnPropertyChanged(); } }
private string _deviceState;
///
/// 点击打开时的动作
///
public Action OpenHandler { get; set; }
///
/// 点击关闭时的动作
///
public Action CloseHandler { get; set; }
#endregion
#region Commands
public BPARelayCommand OpenCommand { get; set; }
public BPARelayCommand CloseCommand { get; set; }
#endregion
///
/// 打开对话框前事件处理
///
public Action BeforeOpenHandler;
///
/// 打开对话框后事件处理
///
public Action 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();
}
}
}