From 1ab1baa42f133ab6fe802a91390167c2ba7e610b Mon Sep 17 00:00:00 2001
From: ZhaoGang <15196688790@163.com>
Date: Thu, 21 Nov 2024 16:38:25 +0800
Subject: [PATCH 1/2] =?UTF-8?q?add:=E6=B7=BB=E5=8A=A0=E9=98=80=E9=97=A8?=
=?UTF-8?q?=E7=94=B5=E6=9C=BA=E7=AD=89=E6=8E=A7=E5=88=B6=E5=BC=B9=E7=AA=97?=
=?UTF-8?q?=E3=80=82=20modify:=E6=97=8B=E8=BD=AC=E7=94=B5=E6=9C=BA?=
=?UTF-8?q?=E6=94=B9=E4=B8=BA=E6=8C=89=E4=B8=8B=E7=BD=AE1=EF=BC=8C?=
=?UTF-8?q?=E6=9D=BE=E5=BC=80=E7=BD=AE0.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BPASmartClient.Academy/App.xaml.cs | 2 +-
.../BPASmartClient.Academy.csproj | 1 +
.../View/DeviceControlView.xaml | 91 ++++++++++++
.../View/DeviceControlView.xaml.cs | 133 ++++++++++++++++++
.../View/ReactionKettle50LView.xaml | 61 ++++----
.../View/ReactionKettle50LView.xaml.cs | 116 ++++++++++++---
.../ViewModel/DeviceControlViewModel.cs | 16 +++
7 files changed, 374 insertions(+), 46 deletions(-)
create mode 100644 BPASmartClient.Academy/View/DeviceControlView.xaml
create mode 100644 BPASmartClient.Academy/View/DeviceControlView.xaml.cs
create mode 100644 BPASmartClient.Academy/ViewModel/DeviceControlViewModel.cs
diff --git a/BPASmartClient.Academy/App.xaml.cs b/BPASmartClient.Academy/App.xaml.cs
index 8da6032b..f22c92a9 100644
--- a/BPASmartClient.Academy/App.xaml.cs
+++ b/BPASmartClient.Academy/App.xaml.cs
@@ -47,7 +47,7 @@ namespace BPASmartClient.Academy
Environment.Exit(0);
}
base.OnStartup(e);
- SystemHelper.GetInstance.CreateDesktopShortcut();
+ //SystemHelper.GetInstance.CreateDesktopShortcut();
DataInit();
MenuInit();
MainView mv = new MainView();
diff --git a/BPASmartClient.Academy/BPASmartClient.Academy.csproj b/BPASmartClient.Academy/BPASmartClient.Academy.csproj
index a8400e6f..fffb170e 100644
--- a/BPASmartClient.Academy/BPASmartClient.Academy.csproj
+++ b/BPASmartClient.Academy/BPASmartClient.Academy.csproj
@@ -22,6 +22,7 @@
+
diff --git a/BPASmartClient.Academy/View/DeviceControlView.xaml b/BPASmartClient.Academy/View/DeviceControlView.xaml
new file mode 100644
index 00000000..2d784bcc
--- /dev/null
+++ b/BPASmartClient.Academy/View/DeviceControlView.xaml
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BPASmartClient.Academy/View/DeviceControlView.xaml.cs b/BPASmartClient.Academy/View/DeviceControlView.xaml.cs
new file mode 100644
index 00000000..3a92c228
--- /dev/null
+++ b/BPASmartClient.Academy/View/DeviceControlView.xaml.cs
@@ -0,0 +1,133 @@
+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();
+ }
+ }
+}
diff --git a/BPASmartClient.Academy/View/ReactionKettle50LView.xaml b/BPASmartClient.Academy/View/ReactionKettle50LView.xaml
index 03e4fa19..de78762a 100644
--- a/BPASmartClient.Academy/View/ReactionKettle50LView.xaml
+++ b/BPASmartClient.Academy/View/ReactionKettle50LView.xaml
@@ -4,6 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:bpa="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:local="clr-namespace:BPASmartClient.Academy.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmartClient.Academy.ViewModel"
@@ -292,7 +293,8 @@
-