diff --git a/DeviceCommand/DeviceCommand.csproj b/DeviceCommand/DeviceCommand.csproj index 6c99400..c0031e7 100644 --- a/DeviceCommand/DeviceCommand.csproj +++ b/DeviceCommand/DeviceCommand.csproj @@ -14,6 +14,7 @@ + diff --git a/DeviceCommand/Devices/Others.cs b/DeviceCommand/Devices/Others.cs deleted file mode 100644 index 8de9646..0000000 --- a/DeviceCommand/Devices/Others.cs +++ /dev/null @@ -1,108 +0,0 @@ -using DeviceCommand.Base; - -public class Others : ModbusTcp -{ - private readonly byte _slaveId; - - /// - /// 通道1PV - /// - private const ushort CH1_PV = 100; - - /// - /// 通道2PV - /// - private const ushort CH2_PV = 102; - - /// - /// 通道3PV - /// - private const ushort CH3_PV = 104; - - /// - /// 通道4PV - /// - private const ushort CH4_PV = 106; - - public Others( - byte slaveId, - string ip, - int port = 508, - int sendTimeoutMs = 3000, - int receiveTimeoutMs = 3000) - : base() - { - _slaveId = slaveId; - ConfigureDevice(ip, port, sendTimeoutMs, receiveTimeoutMs); - } - - /// - /// 读取通道1PV - /// - public async Task ReadCH1Async(CancellationToken ct = default) - { - return await ReadRealAsync(CH1_PV, ct); - } - - /// - /// 读取通道2PV - /// - public async Task ReadCH2Async(CancellationToken ct = default) - { - return await ReadRealAsync(CH2_PV, ct); - } - - /// - /// 读取通道3PV - /// - public async Task ReadCH3Async(CancellationToken ct = default) - { - return await ReadRealAsync(CH3_PV, ct); - } - - /// - /// 读取通道4PV - /// - public async Task ReadCH4Async(CancellationToken ct = default) - { - return await ReadRealAsync(CH4_PV, ct); - } - - /// - /// 一次读取4个通道PV - /// - public async Task<(float ch1, float ch2, float ch3, float ch4)> ReadAllAsync(CancellationToken ct = default) - { - ushort[] raw = await ReadHoldingRegistersAsync(_slaveId, 100, 8, ct); - - return - ( - ToFloat(raw[0], raw[1]), - ToFloat(raw[2], raw[3]), - ToFloat(raw[4], raw[5]), - ToFloat(raw[6], raw[7]) - ); - } - - private async Task ReadRealAsync(ushort address, CancellationToken ct) - { - ushort[] raw = await ReadHoldingRegistersAsync(_slaveId, address, 2, ct); - return ToFloat(raw[0], raw[1]); - } - - private static float ToFloat(ushort high, ushort low) - { - byte[] bytes = - { - (byte)(high >> 8), - (byte)high, - (byte)(low >> 8), - (byte)low - }; - - if (BitConverter.IsLittleEndian) - Array.Reverse(bytes); - - return BitConverter.ToSingle(bytes, 0); - } -} \ No newline at end of file diff --git a/DeviceCommand/Devices/THC-1100-602A.cs b/DeviceCommand/Devices/THC-1100-602A.cs index 5d1d968..4b3a3f4 100644 --- a/DeviceCommand/Devices/THC-1100-602A.cs +++ b/DeviceCommand/Devices/THC-1100-602A.cs @@ -13,7 +13,7 @@ namespace DeviceCommand.Devices public class THC1100 : S7Device { #region THC设备默认连接参数 - private const string DefaultIpAddress = "192.168.0.1"; + private const string DefaultIpAddress = "192.168.1.3"; private const CpuType DefaultCpuType = CpuType.S71200; private const short DefaultRack = 0; private const short DefaultSlot = 1; diff --git a/IOT.sln b/IOT.sln index 1f279c3..02cf8f5 100644 --- a/IOT.sln +++ b/IOT.sln @@ -13,23 +13,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Service", "Service\Service. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{C769E6C6-55E9-40C3-A611-9EFAB101BE6A}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Module", "Module", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoginModule", "LoginModule\LoginModule.csproj", "{F79AC87E-7A5A-486F-BE6C-51E81CA569E4}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UIShare", "UIShare\UIShare.csproj", "{F7A7D4FA-974C-470F-9543-0B256640BD81}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingModule", "SettingModule\SettingModule.csproj", "{2C3C2DBB-F782-416B-8571-07D3F533820B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateInfoModule", "UpdateInfoModule\UpdateInfoModule.csproj", "{B99017CA-BB14-426A-BBF0-C0C05C6510CA}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MainModule", "MainModule\MainModule.csproj", "{715852A3-D2DE-4C2E-AEF2-2BC0ADBEAC0A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LOT", "LOT\LOT.csproj", "{01E01684-DDE8-4B00-9BFC-2C5CDB2A261F}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceCommand", "DeviceCommand\DeviceCommand.csproj", "{2F035F70-5F1D-4C22-B4F0-1AEA0ED127A6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAPI", "WebAPI\WebAPI.csproj", "{D12C03C6-91F1-4792-9787-1EBD98E349EF}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IOT_API", "IOT_API\IOT_API.csproj", "{1E2A7C73-2CAE-4084-939B-0F8EE73AA955}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -57,48 +43,18 @@ Global {C769E6C6-55E9-40C3-A611-9EFAB101BE6A}.Debug|Any CPU.Build.0 = Debug|Any CPU {C769E6C6-55E9-40C3-A611-9EFAB101BE6A}.Release|Any CPU.ActiveCfg = Release|Any CPU {C769E6C6-55E9-40C3-A611-9EFAB101BE6A}.Release|Any CPU.Build.0 = Release|Any CPU - {F79AC87E-7A5A-486F-BE6C-51E81CA569E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F79AC87E-7A5A-486F-BE6C-51E81CA569E4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F79AC87E-7A5A-486F-BE6C-51E81CA569E4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F79AC87E-7A5A-486F-BE6C-51E81CA569E4}.Release|Any CPU.Build.0 = Release|Any CPU - {F7A7D4FA-974C-470F-9543-0B256640BD81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F7A7D4FA-974C-470F-9543-0B256640BD81}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F7A7D4FA-974C-470F-9543-0B256640BD81}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F7A7D4FA-974C-470F-9543-0B256640BD81}.Release|Any CPU.Build.0 = Release|Any CPU - {2C3C2DBB-F782-416B-8571-07D3F533820B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2C3C2DBB-F782-416B-8571-07D3F533820B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2C3C2DBB-F782-416B-8571-07D3F533820B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2C3C2DBB-F782-416B-8571-07D3F533820B}.Release|Any CPU.Build.0 = Release|Any CPU - {B99017CA-BB14-426A-BBF0-C0C05C6510CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B99017CA-BB14-426A-BBF0-C0C05C6510CA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B99017CA-BB14-426A-BBF0-C0C05C6510CA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B99017CA-BB14-426A-BBF0-C0C05C6510CA}.Release|Any CPU.Build.0 = Release|Any CPU - {715852A3-D2DE-4C2E-AEF2-2BC0ADBEAC0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {715852A3-D2DE-4C2E-AEF2-2BC0ADBEAC0A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {715852A3-D2DE-4C2E-AEF2-2BC0ADBEAC0A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {715852A3-D2DE-4C2E-AEF2-2BC0ADBEAC0A}.Release|Any CPU.Build.0 = Release|Any CPU - {01E01684-DDE8-4B00-9BFC-2C5CDB2A261F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {01E01684-DDE8-4B00-9BFC-2C5CDB2A261F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {01E01684-DDE8-4B00-9BFC-2C5CDB2A261F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {01E01684-DDE8-4B00-9BFC-2C5CDB2A261F}.Release|Any CPU.Build.0 = Release|Any CPU {2F035F70-5F1D-4C22-B4F0-1AEA0ED127A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2F035F70-5F1D-4C22-B4F0-1AEA0ED127A6}.Debug|Any CPU.Build.0 = Debug|Any CPU {2F035F70-5F1D-4C22-B4F0-1AEA0ED127A6}.Release|Any CPU.ActiveCfg = Release|Any CPU {2F035F70-5F1D-4C22-B4F0-1AEA0ED127A6}.Release|Any CPU.Build.0 = Release|Any CPU - {D12C03C6-91F1-4792-9787-1EBD98E349EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D12C03C6-91F1-4792-9787-1EBD98E349EF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D12C03C6-91F1-4792-9787-1EBD98E349EF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D12C03C6-91F1-4792-9787-1EBD98E349EF}.Release|Any CPU.Build.0 = Release|Any CPU + {1E2A7C73-2CAE-4084-939B-0F8EE73AA955}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1E2A7C73-2CAE-4084-939B-0F8EE73AA955}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1E2A7C73-2CAE-4084-939B-0F8EE73AA955}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1E2A7C73-2CAE-4084-939B-0F8EE73AA955}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {F79AC87E-7A5A-486F-BE6C-51E81CA569E4} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} - {2C3C2DBB-F782-416B-8571-07D3F533820B} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} - {B99017CA-BB14-426A-BBF0-C0C05C6510CA} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} - {715852A3-D2DE-4C2E-AEF2-2BC0ADBEAC0A} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} - EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {22BD9235-6581-454D-97D8-F4E932F80888} EndGlobalSection diff --git a/WebAPI/Controllers/EnovaDataController.cs b/IOT_API/Controllers/EnovaDataController.cs similarity index 100% rename from WebAPI/Controllers/EnovaDataController.cs rename to IOT_API/Controllers/EnovaDataController.cs diff --git a/WebAPI/WebAPI.csproj b/IOT_API/IOT_API.csproj similarity index 87% rename from WebAPI/WebAPI.csproj rename to IOT_API/IOT_API.csproj index b57eda5..794d4bb 100644 --- a/WebAPI/WebAPI.csproj +++ b/IOT_API/IOT_API.csproj @@ -11,8 +11,8 @@ - + diff --git a/WebAPI/Program.cs b/IOT_API/Program.cs similarity index 100% rename from WebAPI/Program.cs rename to IOT_API/Program.cs diff --git a/WebAPI/Properties/launchSettings.json b/IOT_API/Properties/launchSettings.json similarity index 100% rename from WebAPI/Properties/launchSettings.json rename to IOT_API/Properties/launchSettings.json diff --git a/WebAPI/WebAPI.http b/IOT_API/WebAPI.http similarity index 100% rename from WebAPI/WebAPI.http rename to IOT_API/WebAPI.http diff --git a/WebAPI/appsettings.Development.json b/IOT_API/appsettings.Development.json similarity index 100% rename from WebAPI/appsettings.Development.json rename to IOT_API/appsettings.Development.json diff --git a/WebAPI/appsettings.json b/IOT_API/appsettings.json similarity index 100% rename from WebAPI/appsettings.json rename to IOT_API/appsettings.json diff --git a/LOT/App.xaml b/LOT/App.xaml deleted file mode 100644 index f6038fd..0000000 --- a/LOT/App.xaml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/LOT/App.xaml.cs b/LOT/App.xaml.cs deleted file mode 100644 index d5b131a..0000000 --- a/LOT/App.xaml.cs +++ /dev/null @@ -1,82 +0,0 @@ -using Castle.DynamicProxy; -using Common; -using LOT.ViewModels; -using LOT.ViewModels.Dialogs; -using LOT.Views; -using LOT.Views; -using LOT.Views.Dialogs; -using Logger; -using Notifications.Wpf.Core; -using ORM; -using Service.Implement; -using Service.Interface; -using System.Configuration; -using System.Data; -using System.Reflection; -using System.Windows; -using UIShare.PubEvent; -using static System.Runtime.InteropServices.JavaScript.JSType; - -namespace LOT -{ - /// - /// Interaction logic for App.xaml - /// - public partial class App : PrismApplication - { - protected override Window CreateShell() - { - //UI线程未捕获异常处理事件 - this.DispatcherUnhandledException += OnDispatcherUnhandledException; - //Task线程内未捕获异常处理事件 - TaskScheduler.UnobservedTaskException += OnUnobservedTaskException; - ////多线程异常 - AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; - return Container.Resolve(); - } - private void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) - { - LoggerHelper.Error(e.Exception.Message,e.Exception.StackTrace); - } - - private void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) - { - LoggerHelper.Error(e.Exception.Message, e.Exception.StackTrace); - } - - private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) - { - //记录dump文件 - Exception ex = e.ExceptionObject as Exception; - MiniDump.TryDump($"dumps\\Error_{DateTime.Now:yyyy-MM-dd HH-mm-ss-ms}.dmp", MiniDump.Option.WithFullMemory, ex); - } - protected override void OnInitialized() - { - //初始化数据库 - //DatabaseConfig.SetTenant(10001); - //DatabaseConfig.InitMySql("127.0.0.1",3306,"LOT","root","123456"); - //DatabaseConfig.CreateDatabaseAndCheckConnection(createDatabase: true, checkConnection: true); - //SqlSugarContext.InitDatabase(); - //显示登录窗口 - var login=Container.Resolve(); - var re=Container.Resolve(); - RegionManager.SetRegionManager(login, re); - RegionManager.SetRegionManager(Application.Current.MainWindow, re); - login.Show(); - } - protected override void RegisterTypes(IContainerRegistry containerRegistry) - { - //注册弹窗 - containerRegistry.RegisterDialog("MessageBox"); - // 注册通知管理器 - INotificationManager NotificationManager = new NotificationManager(); - containerRegistry.RegisterInstance(NotificationManager); - } - //指定模块加载方式(需要手动将模块生成的dll放入Modules文件夹中) - protected override IModuleCatalog CreateModuleCatalog() - { - //指定模块加载方式为从文件夹中以反射发现并加载module(推荐用法) - return new DirectoryModuleCatalog() { ModulePath = @".\Modules" }; - } - } -} diff --git a/LOT/AssemblyInfo.cs b/LOT/AssemblyInfo.cs deleted file mode 100644 index b0ec827..0000000 --- a/LOT/AssemblyInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Windows; - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] diff --git a/LOT/LOT.csproj b/LOT/LOT.csproj deleted file mode 100644 index cd8ca8e..0000000 --- a/LOT/LOT.csproj +++ /dev/null @@ -1,67 +0,0 @@ - - - - WinExe - net8.0-windows - enable - enable - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - diff --git a/LOT/Resources/Images/error.png b/LOT/Resources/Images/error.png deleted file mode 100644 index de079d0..0000000 Binary files a/LOT/Resources/Images/error.png and /dev/null differ diff --git a/LOT/Resources/Images/info.png b/LOT/Resources/Images/info.png deleted file mode 100644 index 8fed1fb..0000000 Binary files a/LOT/Resources/Images/info.png and /dev/null differ diff --git a/LOT/Resources/Images/warning.png b/LOT/Resources/Images/warning.png deleted file mode 100644 index 1acd082..0000000 Binary files a/LOT/Resources/Images/warning.png and /dev/null differ diff --git a/LOT/ViewModels/Dialogs/MessageBoxViewModel.cs b/LOT/ViewModels/Dialogs/MessageBoxViewModel.cs deleted file mode 100644 index 2aac5fd..0000000 --- a/LOT/ViewModels/Dialogs/MessageBoxViewModel.cs +++ /dev/null @@ -1,120 +0,0 @@ -using UIShare.PubEvent; -using UIShare.ViewModelBase; -using System.Windows.Input; - -namespace LOT.ViewModels.Dialogs -{ - public class MessageBoxViewModel : DialogViewModelBase - { - #region 属性 - - private string _Title; - public string Title - { - get => _Title; - set => SetProperty(ref _Title, value); - } - - private string _Message = ""; - public string Message - { - get => _Message; - set => SetProperty(ref _Message, value); - } - - private string _Icon= $"pack://siteoforigin:,,,/Resources/Images/info.png"; - public string Icon - { - get => _Icon; - set => SetProperty(ref _Icon, value); - } - - private bool _ShowYes; - public bool ShowYes - { - get => _ShowYes; - set => SetProperty(ref _ShowYes, value); - } - - private bool _ShowNo; - public bool ShowNo - { - get => _ShowNo; - set => SetProperty(ref _ShowNo, value); - } - - private bool _ShowOk; - public bool ShowOk - { - get => _ShowOk; - set => SetProperty(ref _ShowOk, value); - } - - private bool _ShowCancel; - public bool ShowCancel - { - get => _ShowCancel; - set => SetProperty(ref _ShowCancel, value); - } - - #endregion - - #region 命令 - public ICommand YesCommand { get; set; } - public ICommand NoCommand { get; set; } - public ICommand OkCommand { get; set; } - public ICommand CancelCommand { get; set; } - #endregion - - public DialogCloseListener RequestClose { get; set; } - - public MessageBoxViewModel(IContainerProvider containerProvider):base(containerProvider) - { - YesCommand = new DelegateCommand(OnYes); - NoCommand = new DelegateCommand(OnNo); - OkCommand = new DelegateCommand(OnOk); - CancelCommand = new DelegateCommand(OnCancel); - } - - private void CloseDialog(ButtonResult result) - { - var parameters = new DialogParameters(); - RequestClose.Invoke(new DialogResult(result)); - } - - private void OnYes() => CloseDialog(ButtonResult.Yes); - private void OnNo() => CloseDialog(ButtonResult.No); - private void OnOk() => CloseDialog(ButtonResult.OK); - private void OnCancel() => CloseDialog(ButtonResult.Cancel); - - #region Prism Dialog 规范 - public bool CanCloseDialog() => true; - - public override void OnDialogClosed() - { - _eventAggregator.GetEvent().Publish(false); - } - - public override void OnDialogOpened(IDialogParameters parameters) - { - _eventAggregator.GetEvent().Publish(true); - Title = parameters.GetValue("Title"); - Message = parameters.GetValue("Message"); - var iconKey = parameters.GetValue("Icon"); // info / error / warn - Icon = iconKey switch - { - "info" => $"pack://siteoforigin:,,,/Resources/Images/info.png", - "error" => $"pack://siteoforigin:,,,/Resources/Images/error.png", - "warn" => $"pack://siteoforigin:,,,/Resources/Images/warning.png", - _ => $"pack://siteoforigin:,,,/Resources/Images/info.png" // 默认 - }; - - - ShowYes = parameters.GetValue("ShowYes"); - ShowNo = parameters.GetValue("ShowNo"); - ShowOk = parameters.GetValue("ShowOk"); - ShowCancel = parameters.GetValue("ShowCancel"); - } - #endregion - } -} diff --git a/LOT/ViewModels/ShellViewModel.cs b/LOT/ViewModels/ShellViewModel.cs deleted file mode 100644 index 646d21c..0000000 --- a/LOT/ViewModels/ShellViewModel.cs +++ /dev/null @@ -1,109 +0,0 @@ -using Notifications.Wpf.Core; -using System.Windows; -using System.Windows.Input; -using UIShare.PubEvent; - -namespace LOT.ViewModels -{ - public class ShellViewModel : BindableBase - { - #region 属性 - private bool _IsLeftDrawerOpen; - - public bool IsLeftDrawerOpen - { - get => _IsLeftDrawerOpen; - set => SetProperty(ref _IsLeftDrawerOpen, value); - } - - #endregion - #region 命令 - public ICommand LeftDrawerOpenCommand { get; set; } - public ICommand MinimizeCommand { get; set; } - public ICommand MaximizeCommand { get; set; } - public ICommand CloseCommand { get; set; } - public ICommand NavigateCommand { get; set; } - public ICommand LoadCommand { get; set; } - - #endregion - - private IEventAggregator _eventAggregator; - private IRegionManager _regionManager; - private IContainerProvider _containerProvider; - private INotificationManager _notificationManager; - private IModuleManager _moduleManager; - public ShellViewModel( IContainerProvider containerProvider) - { - _containerProvider= containerProvider; - _eventAggregator = containerProvider.Resolve(); - _regionManager = containerProvider.Resolve(); - _notificationManager = containerProvider.Resolve(); - _moduleManager = containerProvider.Resolve(); - LeftDrawerOpenCommand = new DelegateCommand(LeftDrawerOpen); - MinimizeCommand = new DelegateCommand(MinimizeWindow); - MaximizeCommand = new DelegateCommand(MaximizeWindow); - CloseCommand = new DelegateCommand(CloseWindow); - NavigateCommand = new DelegateCommand(Navigate); - LoadCommand = new DelegateCommand(Load); - //订阅登录成功事件 - _eventAggregator.GetEvent().Subscribe(() => - { - Application.Current.MainWindow.Show(); - _regionManager.RequestNavigate("ShellViewManager", "MainView"); - }); - } - - #region 命令处理 - private void Load() - { - _notificationManager.ShowAsync(new NotificationContent { Title = "登录成功", Message = "", Type = NotificationType.Success }); - //默认导航到主界面 - Type moduleAType = typeof(MainModule.MainModule); - _moduleManager.LoadModule(moduleAType.Name); - } - private void Navigate(string content) - { - switch (content) - { - case "主界面": - _regionManager.RequestNavigate("ShellViewManager", "MainView"); - break; - - case "设置界面": - _regionManager.RequestNavigate("ShellViewManager", "SettingView"); - break; - - case "更新界面": - _regionManager.RequestNavigate("ShellViewManager", "UpdateInfoView"); - break; - - default: - break; - } - } - - private void LeftDrawerOpen() - { - IsLeftDrawerOpen = true; - } - private void MinimizeWindow(Window window) - { - if (window != null) - window.WindowState = WindowState.Minimized; - } - - private void MaximizeWindow(Window window) - { - if (window != null) - { - window.WindowState = window.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; - } - } - - private void CloseWindow(Window window) - { - window?.Close(); - } - #endregion - } -} diff --git a/LOT/Views/Dialogs/MessageBoxView.xaml b/LOT/Views/Dialogs/MessageBoxView.xaml deleted file mode 100644 index 7b13b8e..0000000 --- a/LOT/Views/Dialogs/MessageBoxView.xaml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/LoginModule/Views/LoginView.xaml.cs b/LoginModule/Views/LoginView.xaml.cs deleted file mode 100644 index 31db76b..0000000 --- a/LoginModule/Views/LoginView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -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 LoginModule.Views -{ - /// - /// LoginView.xaml 的交互逻辑 - /// - public partial class LoginView : UserControl - { - public LoginView() - { - InitializeComponent(); - } - } -} diff --git a/LoginModule/Views/RegisterView.xaml b/LoginModule/Views/RegisterView.xaml deleted file mode 100644 index 2708b9c..0000000 --- a/LoginModule/Views/RegisterView.xaml +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/LoginModule/Views/RegisterView.xaml.cs b/LoginModule/Views/RegisterView.xaml.cs deleted file mode 100644 index f8d1138..0000000 --- a/LoginModule/Views/RegisterView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -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 LoginModule.Views -{ - /// - /// RegisterView.xaml 的交互逻辑 - /// - public partial class RegisterView : UserControl - { - public RegisterView() - { - InitializeComponent(); - } - } -} diff --git a/MainModule/Events/ConnectionConfigEvent.cs b/MainModule/Events/ConnectionConfigEvent.cs deleted file mode 100644 index 8be73c8..0000000 --- a/MainModule/Events/ConnectionConfigEvent.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Prism.Events; -using S7.Net; -using System.IO.Ports; - -namespace MainModule.Events -{ - public enum ProtocolType - { - S7, - ModbusTCP, - ModbusRTU, - TCP, - HTTP - } - - public class ConnectionConfigEvent : PubSubEvent - { - public class ConnectionConfigData - { - public ProtocolType Protocol { get; set; } - public string IpAddress { get; set; } = string.Empty; - public int Port { get; set; } - public string SerialPort { get; set; } = string.Empty; - public int BaudRate { get; set; } - public Parity Parity { get; set; } - public int DataBits { get; set; } - public StopBits StopBits { get; set; } - public CpuType CpuType { get; set; } - public short Rack { get; set; } - public short Slot { get; set; } - public int SendTimeout { get; set; } - public int ReceiveTimeout { get; set; } - } - } -} diff --git a/MainModule/MainModule.cs b/MainModule/MainModule.cs deleted file mode 100644 index 8e596cd..0000000 --- a/MainModule/MainModule.cs +++ /dev/null @@ -1,22 +0,0 @@ -using MainModule.ViewModels; -using MainModule.Views; -using Prism.Ioc; -using System.Reflection; - -namespace MainModule -{ - [Module(OnDemand=true)] - public class MainModule : IModule - { - public void OnInitialized(IContainerProvider containerProvider) - { - IRegionManager regionManager = containerProvider.Resolve(); - regionManager.RegisterViewWithRegion("ShellViewManager", typeof(MainView)); - } - - public void RegisterTypes(IContainerRegistry containerRegistry) - { - containerRegistry.RegisterForNavigation("MainView"); - } - } -} diff --git a/MainModule/MainModule.csproj b/MainModule/MainModule.csproj deleted file mode 100644 index d334cd2..0000000 --- a/MainModule/MainModule.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - net8.0-windows - enable - true - enable - - - - - - - - - - - - Code - - - - diff --git a/MainModule/ViewModels/ConnectionConfigViewModel.cs b/MainModule/ViewModels/ConnectionConfigViewModel.cs deleted file mode 100644 index 59bd0bc..0000000 --- a/MainModule/ViewModels/ConnectionConfigViewModel.cs +++ /dev/null @@ -1,237 +0,0 @@ -using MainModule.Events; -using Prism.Commands; -using Prism.Mvvm; -using S7.Net; -using System.Collections.Generic; -using System.IO.Ports; -using System.Windows; - -namespace MainModule.ViewModels -{ - public class ConnectionConfigViewModel : BindableBase - { - #region 私有字段 - private Events.ProtocolType _selectedProtocol = Events.ProtocolType.S7; - private string _ipAddress = "127.0.0.1"; - private int _port = 502; - private string _serialPort = "COM1"; - private int _baudRate = 9600; - private Parity _parity = Parity.None; - private int _dataBits = 8; - private StopBits _stopBits = StopBits.One; - private CpuType _cpuType = CpuType.S71200; - private short _rack = 0; - private short _slot = 1; - private int _sendTimeout = 3000; - private int _receiveTimeout = 5000; - #endregion - - #region 公共属性 - public Events.ProtocolType SelectedProtocol - { - get => _selectedProtocol; - set - { - if (SetProperty(ref _selectedProtocol, value)) - { - RaisePropertyChanged(nameof(IsS7Protocol)); - RaisePropertyChanged(nameof(IsModbusTCPProtocol)); - RaisePropertyChanged(nameof(IsModbusRTUProtocol)); - RaisePropertyChanged(nameof(IsTCPProtocol)); - RaisePropertyChanged(nameof(IsHTTPProtocol)); - } - } - } - - public string IpAddress - { - get => _ipAddress; - set => SetProperty(ref _ipAddress, value); - } - - public int Port - { - get => _port; - set => SetProperty(ref _port, value); - } - - public string SerialPort - { - get => _serialPort; - set => SetProperty(ref _serialPort, value); - } - - public int BaudRate - { - get => _baudRate; - set => SetProperty(ref _baudRate, value); - } - - public Parity Parity - { - get => _parity; - set => SetProperty(ref _parity, value); - } - - public int DataBits - { - get => _dataBits; - set => SetProperty(ref _dataBits, value); - } - - public StopBits StopBits - { - get => _stopBits; - set => SetProperty(ref _stopBits, value); - } - - public CpuType CpuType - { - get => _cpuType; - set => SetProperty(ref _cpuType, value); - } - - public short Rack - { - get => _rack; - set => SetProperty(ref _rack, value); - } - - public short Slot - { - get => _slot; - set => SetProperty(ref _slot, value); - } - - public int SendTimeout - { - get => _sendTimeout; - set => SetProperty(ref _sendTimeout, value); - } - - public int ReceiveTimeout - { - get => _receiveTimeout; - set => SetProperty(ref _receiveTimeout, value); - } - #endregion - - #region 协议类型判断属性 - public bool IsS7Protocol => SelectedProtocol == Events.ProtocolType.S7; - public bool IsModbusTCPProtocol => SelectedProtocol == Events.ProtocolType.ModbusTCP; - public bool IsModbusRTUProtocol => SelectedProtocol == Events.ProtocolType.ModbusRTU; - public bool IsTCPProtocol => SelectedProtocol == Events.ProtocolType.TCP; - public bool IsHTTPProtocol => SelectedProtocol == Events.ProtocolType.HTTP; - #endregion - - #region 下拉列表数据源 - public List CpuTypes { get; } = new List - { - CpuType.S71200, - CpuType.S71500, - CpuType.S7200, - CpuType.S7300, - CpuType.S7400, - CpuType.S7200Smart - }; - - public List BaudRates { get; } = new List - { - 9600, - 19200, - 38400, - 57600, - 115200 - }; - - public List DataBitsList { get; } = new List { 7, 8 }; - - public List ParityList { get; } = new List - { - Parity.None, - Parity.Odd, - Parity.Even, - Parity.Mark, - Parity.Space - }; - - public List StopBitsList { get; } = new List - { - StopBits.None, - StopBits.One, - StopBits.OnePointFive, - StopBits.Two - }; - - public List SerialPorts { get; } = new List - { - "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8" - }; - #endregion - - #region 命令 - public DelegateCommand ConfirmCommand { get; } - public DelegateCommand CancelCommand { get; } - public DelegateCommand SelectS7Command { get; } - public DelegateCommand SelectModbusTCPCommand { get; } - public DelegateCommand SelectModbusRTUCommand { get; } - public DelegateCommand SelectTCPCommand { get; } - public DelegateCommand SelectHTTPCommand { get; } - #endregion - - #region 配置数据(供外部获取) - public ConnectionConfigEvent.ConnectionConfigData ConnectionConfigData { get; private set; } - #endregion - - public ConnectionConfigViewModel() - { - ConfirmCommand = new DelegateCommand(ExecuteConfirm); - CancelCommand = new DelegateCommand(ExecuteCancel); - SelectS7Command = new DelegateCommand(() => SelectedProtocol = Events.ProtocolType.S7); - SelectModbusTCPCommand = new DelegateCommand(() => SelectedProtocol = Events.ProtocolType.ModbusTCP); - SelectModbusRTUCommand = new DelegateCommand(() => SelectedProtocol = Events.ProtocolType.ModbusRTU); - SelectTCPCommand = new DelegateCommand(() => SelectedProtocol = Events.ProtocolType.TCP); - SelectHTTPCommand = new DelegateCommand(() => SelectedProtocol = Events.ProtocolType.HTTP); - } - - #region 命令执行 - private void ExecuteConfirm() - { - ConnectionConfigData = new ConnectionConfigEvent.ConnectionConfigData - { - Protocol = SelectedProtocol, - IpAddress = IpAddress, - Port = Port, - SerialPort = SerialPort, - BaudRate = BaudRate, - Parity = Parity, - DataBits = DataBits, - StopBits = StopBits, - CpuType = CpuType, - Rack = Rack, - Slot = Slot, - SendTimeout = SendTimeout, - ReceiveTimeout = ReceiveTimeout - }; - - var window = Application.Current.Windows.OfType().FirstOrDefault(); - if (window != null) - { - window.DialogResult = true; - window.Close(); - } - } - - private void ExecuteCancel() - { - ConnectionConfigData = null; - var window = Application.Current.Windows.OfType().FirstOrDefault(); - if (window != null) - { - window.DialogResult = false; - window.Close(); - } - } - #endregion - } -} diff --git a/MainModule/ViewModels/MainViewModel.cs b/MainModule/ViewModels/MainViewModel.cs deleted file mode 100644 index 9d41537..0000000 --- a/MainModule/ViewModels/MainViewModel.cs +++ /dev/null @@ -1,846 +0,0 @@ -using DeviceCommand.Base; -using DeviceCommand.Devices; -using MainModule.Events; -using MainModule.Views; -using Model.Entity; -using Prism.Commands; -using Prism.Events; -using Prism.Ioc; -using Prism.Navigation; -using System.Collections.ObjectModel; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Threading; -using UIShare.ViewModelBase; - -namespace MainModule.ViewModels -{ - public class MainViewModel : NavigateViewModelBase - { - private readonly THC1100 _thc1100 = new(); - private readonly UMC1300 _umc1300; - private UMC1000Rtu? _umc1000Rtu; - public ObservableCollection Chambers { get; } = new(); - private IContainerProvider _containerProvider; - private CancellationTokenSource _refreshCts; - private DispatcherTimer _refreshTimer; - private bool _isInitialized = false; - - #region 按钮文本和连接状态 - private string _connectButtonText = "连接设备"; - public string ConnectButtonText - { - get => _connectButtonText; - set => SetProperty(ref _connectButtonText, value); - } - - private bool _isConnected = false; - public bool IsConnected - { - get => _isConnected; - set - { - if (SetProperty(ref _isConnected, value)) - { - ConnectButtonText = value ? "断开连接" : "连接设备"; - } - } - } - #endregion - - #region 命令定义 - public DelegateCommand ConnectCommand { get; } - public DelegateCommand DisconnectCommand { get; } - public DelegateCommand RefreshCommand { get; } - public DelegateCommand ConfigCommand { get; } - public DelegateCommand ConnectDeviceCommand { get; } - #endregion - - #region 配置信息 - private Events.ProtocolType _selectedProtocol = Events.ProtocolType.S7; - public Events.ProtocolType SelectedProtocol - { - get => _selectedProtocol; - set => SetProperty(ref _selectedProtocol, value); - } - - private string _configIpAddress = "127.0.0.1"; - public string ConfigIpAddress - { - get => _configIpAddress; - set => SetProperty(ref _configIpAddress, value); - } - - private int _configPort = 102; - public int ConfigPort - { - get => _configPort; - set => SetProperty(ref _configPort, value); - } - - private S7.Net.CpuType _configCpuType = S7.Net.CpuType.S71200; - public S7.Net.CpuType ConfigCpuType - { - get => _configCpuType; - set => SetProperty(ref _configCpuType, value); - } - - private short _configRack = 0; - public short ConfigRack - { - get => _configRack; - set => SetProperty(ref _configRack, value); - } - - private short _configSlot = 1; - public short ConfigSlot - { - get => _configSlot; - set => SetProperty(ref _configSlot, value); - } - - private string _configSerialPort = "COM1"; - public string ConfigSerialPort - { - get => _configSerialPort; - set => SetProperty(ref _configSerialPort, value); - } - - private int _configBaudRate = 9600; - public int ConfigBaudRate - { - get => _configBaudRate; - set => SetProperty(ref _configBaudRate, value); - } - - private int _configDataBits = 8; - public int ConfigDataBits - { - get => _configDataBits; - set => SetProperty(ref _configDataBits, value); - } - - private byte _configSlaveId = 1; - public byte ConfigSlaveId - { - get => _configSlaveId; - set => SetProperty(ref _configSlaveId, value); - } - - private int _configSendTimeout = 3000; - public int ConfigSendTimeout - { - get => _configSendTimeout; - set => SetProperty(ref _configSendTimeout, value); - } - - private int _configReceiveTimeout = 5000; - public int ConfigReceiveTimeout - { - get => _configReceiveTimeout; - set => SetProperty(ref _configReceiveTimeout, value); - } - #endregion - - public MainViewModel(IContainerProvider containerProvider) : base(containerProvider) - { - _containerProvider = containerProvider; - - // 初始化UMC1300设备(默认从站地址1) - _umc1300 = new UMC1300(1, "127.0.0.1", 502); - - // 初始化命令 - ConnectCommand = new DelegateCommand(async () => await ExecuteConnectAsync()); - DisconnectCommand = new DelegateCommand(ExecuteDisconnect); - RefreshCommand = new DelegateCommand(async () => await RefreshDeviceDataAsync()); - ConfigCommand = new DelegateCommand(() => ShowConfigDialogAsync()); - ConnectDeviceCommand = new DelegateCommand(async (item) => await ExecuteConnectDeviceAsync(item)); - } - - /// - /// 当视图被导航到时执行初始化(Prism导航机制) - /// - public override async void OnNavigatedTo(NavigationContext navigationContext) - { - base.OnNavigatedTo(navigationContext); - - // 避免重复初始化 - if (_isInitialized) - return; - _isInitialized = true; - - await InitializeAsync(); - } - - /// - /// 异步初始化设备连接和数据 - /// - private async Task InitializeAsync() - { - try - { - // 先添加所有卡片(显示初始状态) - Application.Current.Dispatcher.Invoke(() => - { - Chambers.Clear(); - Chambers.Add(new ChamberMonitorItem - { - Id = 1, - Name = "环境箱 01", - ProtocolType = "Modbus TCP", - IsConnected = false, - Temperature = 0.0, - Humidity = 0.0 - }); - - Chambers.Add(new ChamberMonitorItem - { - Id = 2, - Name = "环境箱 02", - ProtocolType = "Modbus RTU", - IsConnected = false, - Temperature = 0.0, - Humidity = 0.0 - }); - - Chambers.Add(new ChamberMonitorItem - { - Id = 3, - Name = "环境箱 03", - ProtocolType = "S7", - IsConnected = false, - Temperature = 0.0, - Humidity = 0.0 - }); - - Chambers.Add(new ChamberMonitorItem - { - Id = 4, - Name = "环境箱 04", - ProtocolType = "HTTP", - IsConnected = false, - Temperature = 0.0, - Humidity = 0.0 - }); - }); - - System.Diagnostics.Debug.WriteLine("设备卡片初始化完成"); - } - catch (System.Exception ex) - { - System.Diagnostics.Debug.WriteLine($"初始化异常: {ex.Message}"); - } - } - - #region 配置对话框 - /// - /// 显示配置连接对话框 - /// - private void ShowConfigDialogAsync() - { - try - { - // 手动创建 ViewModel - var viewModel = new ConnectionConfigViewModel(); - - // 设置初始值 - viewModel.SelectedProtocol = SelectedProtocol; - viewModel.IpAddress = ConfigIpAddress; - viewModel.Port = ConfigPort; - viewModel.CpuType = ConfigCpuType; - viewModel.Rack = ConfigRack; - viewModel.Slot = ConfigSlot; - viewModel.SerialPort = ConfigSerialPort; - viewModel.BaudRate = ConfigBaudRate; - viewModel.SendTimeout = ConfigSendTimeout; - viewModel.ReceiveTimeout = ConfigReceiveTimeout; - - // 创建窗口 - var configWindow = new ConnectionConfigView(viewModel); - - // 设置父窗口 - configWindow.Owner = Application.Current.MainWindow; - - // 显示模态对话框 - bool? result = configWindow.ShowDialog(); - - // 如果用户点击确定,获取配置数据 - if (result == true && viewModel.ConnectionConfigData != null) - { - // 直接更新配置参数 - SelectedProtocol = viewModel.ConnectionConfigData.Protocol; - ConfigIpAddress = viewModel.ConnectionConfigData.IpAddress; - ConfigPort = viewModel.ConnectionConfigData.Port; - ConfigCpuType = viewModel.ConnectionConfigData.CpuType; - ConfigRack = viewModel.ConnectionConfigData.Rack; - ConfigSlot = viewModel.ConnectionConfigData.Slot; - ConfigSerialPort = viewModel.ConnectionConfigData.SerialPort; - ConfigBaudRate = viewModel.ConnectionConfigData.BaudRate; - ConfigSendTimeout = viewModel.ConnectionConfigData.SendTimeout; - ConfigReceiveTimeout = viewModel.ConnectionConfigData.ReceiveTimeout; - - System.Diagnostics.Debug.WriteLine($"配置更新成功: 协议={SelectedProtocol}, IP={ConfigIpAddress}, 端口={ConfigPort}"); - } - } - catch (System.Exception ex) - { - System.Diagnostics.Debug.WriteLine($"打开配置对话框异常: {ex.Message}"); - } - } - - /// - /// 配置更新事件处理 - /// - private void OnConfigUpdated(ConnectionConfigEvent.ConnectionConfigData config) - { - SelectedProtocol = config.Protocol; - ConfigIpAddress = config.IpAddress; - ConfigPort = config.Port; - ConfigCpuType = config.CpuType; - ConfigRack = config.Rack; - ConfigSlot = config.Slot; - ConfigSerialPort = config.SerialPort; - ConfigBaudRate = config.BaudRate; - ConfigSendTimeout = config.SendTimeout; - ConfigReceiveTimeout = config.ReceiveTimeout; - - System.Diagnostics.Debug.WriteLine($"配置更新: 协议={SelectedProtocol}, IP={ConfigIpAddress}, 端口={ConfigPort}"); - } - #endregion - - #region 连接命令实现 - /// - /// 执行连接/断开切换命令 - /// - private async Task ExecuteConnectAsync() - { - if (IsConnected) - { - // 如果已连接,则断开 - ExecuteDisconnect(); - } - else - { - // 如果未连接,则连接 - await ConnectToDeviceAsync(); - } - } - - /// - /// 连接到THC设备 - /// - private async Task ConnectToDeviceAsync() - { - try - { - System.Diagnostics.Debug.WriteLine("正在连接THC设备..."); - - // 使用配置对话框中设置的参数配置设备 - _thc1100.ConfigureDevice( - ipAddress: ConfigIpAddress, - cpuType: ConfigCpuType, - rack: ConfigRack, - slot: ConfigSlot - ); - System.Diagnostics.Debug.WriteLine($"配置参数: 协议={SelectedProtocol}, IP={_thc1100.IPAddress}, CPU={_thc1100.CpuType}, Rack={_thc1100.Rack}, Slot={_thc1100.Slot}"); - - // 连接THC设备 - bool connected = await _thc1100.ConnectAsync(); - - if (connected) - { - IsConnected = true; - System.Windows.MessageBox.Show("THC设备连接成功", "连接成功", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information); - - // 更新环境箱03的连接状态 - var chamber3 = GetChamberById(3); - if (chamber3 != null) - { - chamber3.IsConnected = true; - } - - // 读取初始数据 - await RefreshDeviceDataAsync(); - - // 启动定时刷新(每1秒) - StartPeriodicRefresh(); - } - else - { - System.Diagnostics.Debug.WriteLine("THC设备连接失败"); - MessageBox.Show("设备连接失败,请检查网络和设备状态!", "连接失败", - MessageBoxButton.OK, MessageBoxImage.Warning); - } - } - catch (System.Exception ex) - { - System.Diagnostics.Debug.WriteLine($"连接异常: {ex.Message}"); - MessageBox.Show($"连接异常: {ex.Message}", "错误", - MessageBoxButton.OK, MessageBoxImage.Error); - } - } - - /// - /// 断开THC设备连接 - /// - private void ExecuteDisconnect() - { - try - { - // 停止定时器 - _refreshCts?.Cancel(); - _refreshTimer?.Stop(); - - // 关闭设备连接 - _thc1100.Close(); - - // 更新连接状态 - IsConnected = false; - - // 更新环境箱03的连接状态 - var chamber3 = GetChamberById(3); - if (chamber3 != null) - { - chamber3.IsConnected = false; - } - - System.Diagnostics.Debug.WriteLine("THC设备已断开连接"); - } - catch (System.Exception ex) - { - System.Diagnostics.Debug.WriteLine($"断开连接异常: {ex.Message}"); - } - } - #endregion - - #region 定时刷新 - /// - /// 启动定时刷新 - /// - private void StartPeriodicRefresh() - { - _refreshCts?.Cancel(); - _refreshCts = new CancellationTokenSource(); - - _refreshTimer?.Stop(); - _refreshTimer = new DispatcherTimer - { - Interval = TimeSpan.FromSeconds(1) - }; - - _refreshTimer.Tick += async (s, e) => - { - try - { - System.Diagnostics.Debug.WriteLine($"[定时刷新] Tick触发,当前时间: {DateTime.Now:HH:mm:ss.fff}"); - System.Diagnostics.Debug.WriteLine($"[定时刷新] THC1100.IsConnected = {_thc1100.IsConnected}"); - - // 检查THC1100连接状态 - if (_thc1100.IsConnected) - { - var chamber3 = GetChamberById(3); - System.Diagnostics.Debug.WriteLine($"[定时刷新] chamber3 = {chamber3}, IsConnected = {chamber3?.IsConnected}"); - - if (chamber3 != null) - { - System.Diagnostics.Debug.WriteLine("[定时刷新] 开始读取温湿度数据..."); - try - { - var temp = await _thc1100.GetRealTimeTemperatureSetPointAsync(); - var humidity = await _thc1100.GetRealTimeHumidityMeasuredValueAsync(); - - System.Diagnostics.Debug.WriteLine($"[定时刷新] 读取完成 - 温度(DB53.DBD280): {temp}, 湿度(DB53.DBD1092): {humidity}"); - - Application.Current.Dispatcher.Invoke(() => - { - chamber3.Temperature = temp; - chamber3.Humidity = humidity; - System.Diagnostics.Debug.WriteLine($"[定时刷新] UI已更新 - Temperature={chamber3.Temperature}, Humidity={chamber3.Humidity}"); - }); - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine($"[定时刷新] 读取温湿度数据异常: {ex.Message}"); - } - } - } - else - { - System.Diagnostics.Debug.WriteLine("[定时刷新] THC1100未连接,跳过数据读取"); - } - - // 检查UMC1300连接状态 → 环境箱01 (Modbus TCP) - if (_umc1300.IsConnected) - { - var chamber1 = GetChamberById(1); - if (chamber1 != null) - { - try - { - var temp = await _umc1300.ReadTemperaturePVAsync(); - var humidity = await _umc1300.ReadHumidityPVAsync(); - - Application.Current.Dispatcher.Invoke(() => - { - chamber1.Temperature = temp; - chamber1.Humidity = humidity; - }); - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine($"[定时刷新] 读取UMC1300数据异常: {ex.Message}"); - } - } - } - - // 检查UMC1000Rtu连接状态 → 环境箱02 (Modbus RTU) - if (_umc1000Rtu != null && _umc1000Rtu.IsConnected) - { - var chamber2 = GetChamberById(2); - if (chamber2 != null) - { - try - { - var temp = await _umc1000Rtu.ReadTemperatureAsync(); - var humidity = await _umc1000Rtu.ReadHumidityAsync(); - - Application.Current.Dispatcher.Invoke(() => - { - chamber2.Temperature = temp; - chamber2.Humidity = humidity; - }); - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine($"[定时刷新] 读取UMC1000Rtu数据异常: {ex.Message}"); - } - } - } - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine($"[定时刷新] 定时器异常: {ex.Message}"); - } - }; - - _refreshTimer.Start(); - } - - /// - /// 停止定时刷新 - /// - private void StopPeriodicRefresh() - { - _refreshCts?.Cancel(); - _refreshTimer?.Stop(); - } - #endregion - - #region 数据刷新 - /// - /// 刷新设备数据 - /// - private async Task RefreshDeviceDataAsync() - { - try - { - // 如果未连接,不刷新数据 - if (!_thc1100.IsConnected) - return; - - var chamber3 = GetChamberById(3); - if (chamber3 == null) return; - - // 读取温湿度数据(使用用户指定的寄存器地址) - // 温度: DB53.DBD280, 湿度: DB53.DBD1092 - var temp = await _thc1100.GetRealTimeTemperatureSetPointAsync(); - var humidity = await _thc1100.GetRealTimeHumidityMeasuredValueAsync(); - - System.Diagnostics.Debug.WriteLine($"[初始刷新] 环境箱3 - 温度(DB53.DBD280): {temp}, 湿度(DB53.DBD1092): {humidity}"); - - // 更新UI(在UI线程执行) - Application.Current.Dispatcher.Invoke(() => - { - chamber3.Temperature = temp; - chamber3.Humidity = humidity; - }); - } - catch (System.Exception ex) - { - System.Diagnostics.Debug.WriteLine($"刷新数据异常: {ex.Message}"); - } - } - #endregion - - #region 辅助方法 - /// - /// 根据ID获取卡片 - /// - private ChamberMonitorItem GetChamberById(int id) - { - foreach (var chamber in Chambers) - { - if (chamber.Id == id) - return chamber; - } - return null; - } - - /// - /// 根据设备类型连接单个设备 - /// - private async Task ExecuteConnectDeviceAsync(ChamberMonitorItem item) - { - if (item == null) return; - - try - { - if (item.IsConnected) - { - // 断开连接 - System.Diagnostics.Debug.WriteLine($"[连接] 正在断开设备 {item.Name}"); - - // 根据设备自己的协议类型调用对应设备的Close方法 - switch (item.ProtocolType) - { - case "S7": - _thc1100.Close(); - break; - case "Modbus TCP": - _umc1300.Close(); - break; - case "Modbus RTU": - _umc1000Rtu?.Close(); - break; - } - - // 停止数据刷新 - StopPeriodicRefresh(); - - item.IsConnected = false; - System.Diagnostics.Debug.WriteLine($"[连接] 设备 {item.Name} 已断开连接"); - } - else - { - // 输出当前配置参数 - System.Diagnostics.Debug.WriteLine($"[连接] ========== 开始连接设备 {item.Name} =========="); - System.Diagnostics.Debug.WriteLine($"[连接] 当前协议类型: {SelectedProtocol}"); - System.Diagnostics.Debug.WriteLine($"[连接] IP地址: {ConfigIpAddress}"); - System.Diagnostics.Debug.WriteLine($"[连接] 端口: {ConfigPort}"); - System.Diagnostics.Debug.WriteLine($"[连接] CPU类型: {ConfigCpuType}"); - System.Diagnostics.Debug.WriteLine($"[连接] Rack: {ConfigRack}, Slot: {ConfigSlot}"); - System.Diagnostics.Debug.WriteLine($"[连接] 串口: {ConfigSerialPort}, 波特率: {ConfigBaudRate}"); - System.Diagnostics.Debug.WriteLine($"[连接] 发送超时: {ConfigSendTimeout}ms, 接收超时: {ConfigReceiveTimeout}ms"); - - // 根据设备自己的协议类型连接设备 - bool connected = false; - System.Diagnostics.Debug.WriteLine($"[连接] 设备协议类型: {item.ProtocolType}"); - - switch (item.ProtocolType) - { - case "S7": - // S7协议连接 - System.Diagnostics.Debug.WriteLine("[连接] 使用设备配置的S7协议"); - connected = await ConnectS7DeviceAsync(item); - break; - case "Modbus TCP": - // Modbus TCP连接 - System.Diagnostics.Debug.WriteLine("[连接] 使用设备配置的Modbus TCP协议"); - connected = await ConnectModbusTcpDeviceAsync(item); - break; - case "Modbus RTU": - // Modbus RTU连接 → UMC1000Rtu 温湿度 - System.Diagnostics.Debug.WriteLine("[连接] 使用设备配置的Modbus RTU协议"); - connected = await ConnectUMC1000RtuDeviceAsync(item); - break; - case "HTTP": - // HTTP连接 - System.Diagnostics.Debug.WriteLine("[连接] 使用设备配置的HTTP协议"); - connected = await ConnectHttpDeviceAsync(item); - break; - default: - System.Diagnostics.Debug.WriteLine($"[连接] 未知协议类型: {item.ProtocolType}"); - break; - } - - item.IsConnected = connected; - System.Diagnostics.Debug.WriteLine($"[连接] 设备 {item.Name} 连接结果: {(connected ? "成功" : "失败")}"); - System.Diagnostics.Debug.WriteLine($"[连接] ========== 连接尝试结束 =========="); - } - } - catch (System.Exception ex) - { - System.Diagnostics.Debug.WriteLine($"[连接] 设备 {item.Name} 连接异常: {ex.Message}"); - System.Diagnostics.Debug.WriteLine($"[连接] 异常堆栈: {ex.StackTrace}"); - item.IsConnected = false; - } - } - - /// - /// S7协议设备连接 - /// - private async Task ConnectS7DeviceAsync(ChamberMonitorItem item) - { - try - { - System.Diagnostics.Debug.WriteLine($"[ConnectS7DeviceAsync] 开始配置设备: IP={ConfigIpAddress}, CPU={ConfigCpuType}, Rack={ConfigRack}, Slot={ConfigSlot}"); - - _thc1100.ConfigureDevice(ConfigIpAddress, ConfigCpuType, ConfigRack, ConfigSlot); - bool result = await _thc1100.ConnectAsync(); - - System.Diagnostics.Debug.WriteLine($"[ConnectS7DeviceAsync] 连接结果: {result}, IsConnected属性值: {_thc1100.IsConnected}"); - - if (result) - { - System.Diagnostics.Debug.WriteLine("[ConnectS7DeviceAsync] 连接成功,启动定时刷新"); - StartPeriodicRefresh(); - } - - return result; - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine($"[ConnectS7DeviceAsync] 异常: {ex.Message}, 堆栈: {ex.StackTrace}"); - return false; - } - } - - /// - /// UMC1000Rtu 温湿度设备连接(Modbus RTU) - /// - private async Task ConnectUMC1000RtuDeviceAsync(ChamberMonitorItem item) - { - try - { - _umc1000Rtu = new UMC1000Rtu( - slaveId: ConfigSlaveId, - portName: ConfigSerialPort, - baudRate: ConfigBaudRate, - dataBits: ConfigDataBits, - stopBits: System.IO.Ports.StopBits.One, - parity: System.IO.Ports.Parity.None, - readTimeout: ConfigReceiveTimeout, - writeTimeout: ConfigSendTimeout); - - bool result = await _umc1000Rtu.ConnectAsync(); - - if (result) - { - StartPeriodicRefresh(); - } - - System.Diagnostics.Debug.WriteLine($"UMC1000Rtu Modbus RTU连接: {ConfigSerialPort}, 波特率:{ConfigBaudRate}, 从站:{ConfigSlaveId}, 结果: {result}"); - return result; - } - catch (System.Exception ex) - { - System.Diagnostics.Debug.WriteLine($"UMC1000Rtu连接异常: {ex.Message}"); - return false; - } - } - - /// - /// Modbus TCP设备连接(UMC1300) - /// - private async Task ConnectModbusTcpDeviceAsync(ChamberMonitorItem item) - { - try - { - _umc1300.ConfigureDevice(ConfigIpAddress, ConfigPort, ConfigSendTimeout, ConfigReceiveTimeout); - bool result = await _umc1300.ConnectAsync(); - - if (result) - { - StartPeriodicRefresh(); - } - - System.Diagnostics.Debug.WriteLine($"UMC1300 Modbus TCP连接: {ConfigIpAddress}:{ConfigPort}, 结果: {result}"); - return result; - } - catch (System.Exception ex) - { - System.Diagnostics.Debug.WriteLine($"UMC1300连接异常: {ex.Message}"); - return false; - } - } - - /// - /// HTTP设备连接 - /// - private async Task ConnectHttpDeviceAsync(ChamberMonitorItem item) - { - // 实现HTTP连接逻辑 - System.Diagnostics.Debug.WriteLine($"HTTP连接: {ConfigIpAddress}:{ConfigPort}"); - await Task.Delay(500); - return true; - } - #endregion - - #region 生命周期管理 - /// - /// 导航离开时清理资源 - /// - public override void OnNavigatedFrom(NavigationContext navigationContext) - { - base.OnNavigatedFrom(navigationContext); - - ExecuteDisconnect(); - _isInitialized = false; - } - #endregion - } - - /// - /// 环境箱 UI 状态及温湿度数据绑定模型 - /// - public class ChamberMonitorItem : BindableBase - { - private double _temperature; - private double _humidity; - private bool _isConnected; - - public int Id { get; set; } - public string Name { get; set; } = string.Empty; - public string ProtocolType { get; set; } = string.Empty; - - /// - /// 温度(支持通知刷新) - /// - public double Temperature - { - get => _temperature; - set => SetProperty(ref _temperature, value); - } - - /// - /// 湿度(支持通知刷新) - /// - public double Humidity - { - get => _humidity; - set => SetProperty(ref _humidity, value); - } - - /// - /// 连接状态:True-已连接(绿灯),False-断开(红灯) - /// - public bool IsConnected - { - get => _isConnected; - set - { - if (SetProperty(ref _isConnected, value)) - { - RaisePropertyChanged(nameof(ConnectButtonText)); - } - } - } - - /// - /// 连接按钮文本 - /// - public string ConnectButtonText => IsConnected ? "断开连接" : "连接设备"; - } -} diff --git a/MainModule/Views/ConnectionConfigView.xaml b/MainModule/Views/ConnectionConfigView.xaml deleted file mode 100644 index f3e896c..0000000 --- a/MainModule/Views/ConnectionConfigView.xaml +++ /dev/null @@ -1,285 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/MainModule/Views/MainView.xaml.cs b/MainModule/Views/MainView.xaml.cs deleted file mode 100644 index a2a7212..0000000 --- a/MainModule/Views/MainView.xaml.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -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 MainModule.Views -{ - /// - /// MainView.xaml 的交互逻辑 - /// - public partial class MainView : UserControl - { - public MainView() - { - InitializeComponent(); - } - - - } -} \ No newline at end of file diff --git a/SettingModule/SettingModule.cs b/SettingModule/SettingModule.cs deleted file mode 100644 index 56f2440..0000000 --- a/SettingModule/SettingModule.cs +++ /dev/null @@ -1,19 +0,0 @@ -using SettingModule.Views; -using System.Reflection; - -namespace SettingModule -{ - public class SettingModule : IModule - { - public void OnInitialized(IContainerProvider containerProvider) - { - IRegionManager regionManager = containerProvider.Resolve(); - regionManager.RegisterViewWithRegion("ShellViewManager", typeof(SettingView)); - } - - public void RegisterTypes(IContainerRegistry containerRegistry) - { - containerRegistry.RegisterForNavigation("SettingView"); - } - } -} diff --git a/SettingModule/SettingModule.csproj b/SettingModule/SettingModule.csproj deleted file mode 100644 index 8d75460..0000000 --- a/SettingModule/SettingModule.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - net8.0-windows - enable - true - enable - - - - - - - - - Code - - - Code - - - - diff --git a/SettingModule/ViewModels/SettingViewModel.cs b/SettingModule/ViewModels/SettingViewModel.cs deleted file mode 100644 index 4a152e0..0000000 --- a/SettingModule/ViewModels/SettingViewModel.cs +++ /dev/null @@ -1,28 +0,0 @@ -using UIShare.ViewModelBase; - -namespace SettingModule.ViewModels -{ - public class SettingViewModel : NavigateViewModelBase - { - #region 属性 - - - #endregion - #region 命令 - - - - #endregion - public SettingViewModel(IContainerProvider containerProvider) : base(containerProvider) - { - - - } - #region 命令处理 - - - - #endregion - - } -} diff --git a/SettingModule/Views/SettingView.xaml b/SettingModule/Views/SettingView.xaml deleted file mode 100644 index b553d29..0000000 --- a/SettingModule/Views/SettingView.xaml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/SettingModule/Views/SettingView.xaml.cs b/SettingModule/Views/SettingView.xaml.cs deleted file mode 100644 index 41c770b..0000000 --- a/SettingModule/Views/SettingView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -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 SettingModule.Views -{ - /// - /// SettingView.xaml 的交互逻辑 - /// - public partial class SettingView : UserControl - { - public SettingView() - { - InitializeComponent(); - } - } -} diff --git a/UIShare/Converters/BooleanToVisibilityConverter.cs b/UIShare/Converters/BooleanToVisibilityConverter.cs deleted file mode 100644 index db57ae8..0000000 --- a/UIShare/Converters/BooleanToVisibilityConverter.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Data; - -namespace UIShare.Converters -{ - public class BooleanToVisibilityConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - bool input = value is bool b && b; - bool invert = parameter?.ToString()?.ToLower() == "invert"; - - if (invert) - input = !input; - - return input ? Visibility.Visible : Visibility.Collapsed; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - bool output = value is Visibility v && v == Visibility.Visible; - bool invert = parameter?.ToString()?.ToLower() == "invert"; - - if (invert) - output = !output; - - return output; - } - } -} diff --git a/UIShare/Helpers/PasswordBoxHelper.cs b/UIShare/Helpers/PasswordBoxHelper.cs deleted file mode 100644 index e5eadd4..0000000 --- a/UIShare/Helpers/PasswordBoxHelper.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; - -namespace UIShare.Helpers -{ - public static class PasswordBoxHelper - { - public static readonly DependencyProperty PasswordProperty = - DependencyProperty.RegisterAttached( - "Password", - typeof(string), - typeof(PasswordBoxHelper), - new FrameworkPropertyMetadata( - string.Empty, - FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, - OnPasswordPropertyChanged)); - - public static void SetPassword(DependencyObject d, string value) - => d.SetValue(PasswordProperty, value); - - public static string GetPassword(DependencyObject d) - => (string)d.GetValue(PasswordProperty); - - private static void OnPasswordPropertyChanged( - DependencyObject d, - DependencyPropertyChangedEventArgs e) - { - if (d is PasswordBox pb) - { - pb.PasswordChanged -= PasswordChanged; - if (pb.Password != (string)e.NewValue) - { - pb.Password = (string)e.NewValue; - } - pb.PasswordChanged += PasswordChanged; - } - } - - private static void PasswordChanged(object sender, RoutedEventArgs e) - { - if (sender is PasswordBox pb) - { - SetPassword(pb, pb.Password); - } - } - } -} diff --git a/UIShare/PubEvent/LoginSuccessEvent.cs b/UIShare/PubEvent/LoginSuccessEvent.cs deleted file mode 100644 index 45201c8..0000000 --- a/UIShare/PubEvent/LoginSuccessEvent.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace UIShare.PubEvent -{ - public class LoginSuccessEvent:PubSubEvent - { - } -} diff --git a/UIShare/PubEvent/OverlayEvent.cs b/UIShare/PubEvent/OverlayEvent.cs deleted file mode 100644 index dd886db..0000000 --- a/UIShare/PubEvent/OverlayEvent.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace UIShare.PubEvent -{ - public class OverlayEvent : PubSubEvent - { - } -} diff --git a/UIShare/PubEvent/WaitingEvent.cs b/UIShare/PubEvent/WaitingEvent.cs deleted file mode 100644 index 1633c54..0000000 --- a/UIShare/PubEvent/WaitingEvent.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace UIShare.PubEvent -{ - public class WaitingEvent : PubSubEvent - { - } -} diff --git a/UIShare/Styles/CommonStyle.xaml b/UIShare/Styles/CommonStyle.xaml deleted file mode 100644 index e59a590..0000000 --- a/UIShare/Styles/CommonStyle.xaml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/UIShare/Styles/WindowStyle.xaml b/UIShare/Styles/WindowStyle.xaml deleted file mode 100644 index 393226b..0000000 --- a/UIShare/Styles/WindowStyle.xaml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - diff --git a/UIShare/UIShare.csproj b/UIShare/UIShare.csproj deleted file mode 100644 index 7ccaa94..0000000 --- a/UIShare/UIShare.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - net8.0-windows - enable - true - enable - - - - - - - - - - - - - diff --git a/UIShare/ViewModelBase/DialogViewModelBase.cs b/UIShare/ViewModelBase/DialogViewModelBase.cs deleted file mode 100644 index a6c15bd..0000000 --- a/UIShare/ViewModelBase/DialogViewModelBase.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Notifications.Wpf.Core; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace UIShare.ViewModelBase -{ - public abstract class DialogViewModelBase : BindableBase,IDialogAware - { - public DialogCloseListener RequestClose { get; set; } - public IEventAggregator _eventAggregator; - private INotificationManager _notificationManager; - public DialogViewModelBase(IContainerProvider containerProvider) - { - _eventAggregator = containerProvider.Resolve(); - _notificationManager = containerProvider.Resolve(); - } - #region Dialog - - public virtual bool CanCloseDialog() => true; - public virtual void OnDialogClosed() { } - public virtual void OnDialogOpened(IDialogParameters parameters) { } - #endregion - } -} diff --git a/UIShare/ViewModelBase/NavigateViewModelBase.cs b/UIShare/ViewModelBase/NavigateViewModelBase.cs deleted file mode 100644 index fcee644..0000000 --- a/UIShare/ViewModelBase/NavigateViewModelBase.cs +++ /dev/null @@ -1,60 +0,0 @@ -using Notifications.Wpf.Core; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace UIShare.ViewModelBase -{ - public abstract class NavigateViewModelBase : BindableBase, INavigationAware - { - public DialogCloseListener RequestClose { get; set; } - public IEventAggregator _eventAggregator; - public IDialogService _dialogService; - public IRegionManager _regionManager; - private INotificationManager _notificationManager; - public NavigateViewModelBase(IContainerProvider containerProvider) - { - _eventAggregator = containerProvider.Resolve(); - _dialogService = containerProvider.Resolve(); - _regionManager = containerProvider.Resolve(); - _notificationManager = containerProvider.Resolve(); - } - - protected void ShowInfoMessageBox(string Message,Action callback) - { - var dialogParams = new DialogParameters(); - dialogParams.Add("Title", "提示"); - dialogParams.Add("Message", Message); - dialogParams.Add("Icon", "info"); - dialogParams.Add("ShowOk", true); - _dialogService.ShowDialog("MessageBoxView", dialogParams, result => - { - callback(); - }); - } - protected void ShowErrorMessageBox(string Message,Action callback) - { - var dialogParams = new DialogParameters(); - dialogParams.Add("Title", "错误"); - dialogParams.Add("Message", Message); - dialogParams.Add("Icon", "info"); - dialogParams.Add("ShowOk", true); - _dialogService.ShowDialog("MessageBoxView", dialogParams, result => - { - callback(); - }); - } - #region Navigation - - public virtual void OnNavigatedTo(NavigationContext navigationContext) { } - - public virtual bool IsNavigationTarget(NavigationContext navigationContext) => true; - - public virtual void OnNavigatedFrom(NavigationContext navigationContext) { } - - #endregion - } - -} diff --git a/UpdateInfoModule/UpdateInfoModule.cs b/UpdateInfoModule/UpdateInfoModule.cs deleted file mode 100644 index d27816d..0000000 --- a/UpdateInfoModule/UpdateInfoModule.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using UpdateInfoModule.Views; - -namespace UpdateInfoModule -{ - public class UpdateInfoModule : IModule - { - public void OnInitialized(IContainerProvider containerProvider) - { - IRegionManager regionManager = containerProvider.Resolve(); - regionManager.RegisterViewWithRegion("ShellViewManager", typeof(UpdateInfoView)); - } - - public void RegisterTypes(IContainerRegistry containerRegistry) - { - containerRegistry.RegisterForNavigation("UpdateInfoView"); - } - } -} diff --git a/UpdateInfoModule/UpdateInfoModule.csproj b/UpdateInfoModule/UpdateInfoModule.csproj deleted file mode 100644 index 9c40ada..0000000 --- a/UpdateInfoModule/UpdateInfoModule.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - net8.0-windows - enable - true - enable - - - - - - - - - Code - - - - diff --git a/UpdateInfoModule/ViewModels/UpdateInfoViewModel.cs b/UpdateInfoModule/ViewModels/UpdateInfoViewModel.cs deleted file mode 100644 index 68bd2db..0000000 --- a/UpdateInfoModule/ViewModels/UpdateInfoViewModel.cs +++ /dev/null @@ -1,30 +0,0 @@ -using UIShare.ViewModelBase; - -namespace UpdateInfoModule.ViewModels -{ - public class UpdateInfoViewModel : NavigateViewModelBase - { - #region 属性 - - - #endregion - #region 命令 - - - - #endregion - - public UpdateInfoViewModel(IContainerProvider containerProvider) : base(containerProvider) - { - - - } - #region 命令处理 - - - - #endregion - - - } -} diff --git a/UpdateInfoModule/Views/UpdateInfoView.xaml b/UpdateInfoModule/Views/UpdateInfoView.xaml deleted file mode 100644 index d3a7199..0000000 --- a/UpdateInfoModule/Views/UpdateInfoView.xaml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/UpdateInfoModule/Views/UpdateInfoView.xaml.cs b/UpdateInfoModule/Views/UpdateInfoView.xaml.cs deleted file mode 100644 index fd8f576..0000000 --- a/UpdateInfoModule/Views/UpdateInfoView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -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 UpdateInfoModule.Views -{ - /// - /// UpdateInfoView.xaml 的交互逻辑 - /// - public partial class UpdateInfoView : UserControl - { - public UpdateInfoView() - { - InitializeComponent(); - } - } -}