diff --git a/SlnMesnac.WPF/App.xaml b/SlnMesnac.WPF/App.xaml
index e613bdf..48f0a12 100644
--- a/SlnMesnac.WPF/App.xaml
+++ b/SlnMesnac.WPF/App.xaml
@@ -4,6 +4,11 @@
xmlns:local="clr-namespace:SlnMesnac.WPF"
StartupUri="MainWindow.xaml">
-
+
+
+
+
+
+
diff --git a/SlnMesnac.WPF/App.xaml.cs b/SlnMesnac.WPF/App.xaml.cs
index 7bad7db..78c0506 100644
--- a/SlnMesnac.WPF/App.xaml.cs
+++ b/SlnMesnac.WPF/App.xaml.cs
@@ -1,4 +1,5 @@
-using Microsoft.AspNetCore.Hosting;
+using Lierda.WPFHelper;
+using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Serilog;
@@ -8,6 +9,7 @@ using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
using System.Windows;
@@ -18,11 +20,23 @@ namespace SlnMesnac.WPF
///
public partial class App : Application
{
+ private System.Threading.Mutex mutex;
+ private LierdaCracker cracker = new LierdaCracker();
public static IServiceProvider ServiceProvider;
// Startup事件
protected override async void OnStartup(StartupEventArgs e)
{
+ bool ret;
+ mutex = new System.Threading.Mutex(true, System.Diagnostics.Process.GetCurrentProcess().ProcessName, out ret);
+ if (!ret)
+ {
+ MessageBox.Show("应用程序已开启,禁止重复运行");
+ Environment.Exit(0);
+ }
+
+ cracker.Cracker(100); //设置GC回收间隔
+
base.OnStartup(e);
var host = CreateHostBuilder(e.Args).Build();//生成宿主。
@@ -32,8 +46,15 @@ namespace SlnMesnac.WPF
var appConfig = host.Services.GetService();
var logPath = $"{appConfig.logPath}/Logs/{DateTime.UtcNow:yyyy-MM-dd}/";
Log.Information($"系统初始化完成,日志存放路径:{appConfig.logPath}");
+
+
}
+ ///
+ /// CreateHostBuilder
+ ///
+ ///
+ ///
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSerilog()
@@ -47,8 +68,11 @@ namespace SlnMesnac.WPF
{
base.OnExit(e);
+ Log.Information($"系统退出,当前时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
// 释放资源
// ...
}
+
+
}
}
diff --git a/SlnMesnac.WPF/MainWindow.xaml b/SlnMesnac.WPF/MainWindow.xaml
index 1c3a2e8..6c6a0a4 100644
--- a/SlnMesnac.WPF/MainWindow.xaml
+++ b/SlnMesnac.WPF/MainWindow.xaml
@@ -5,8 +5,263 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SlnMesnac.WPF"
mc:Ignorable="d"
- Title="MainWindow" Height="450" Width="800">
-
+ Title="MainWindow" Height="1080" Width="1920"
+ WindowState="Maximized" WindowStyle="None" ResizeMode="NoResize" Topmost="False">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
diff --git a/SlnMesnac.WPF/MainWindow.xaml.cs b/SlnMesnac.WPF/MainWindow.xaml.cs
index e09e3df..2139374 100644
--- a/SlnMesnac.WPF/MainWindow.xaml.cs
+++ b/SlnMesnac.WPF/MainWindow.xaml.cs
@@ -1,4 +1,5 @@
-using System;
+using SlnMesnac.WPF.ViewModel;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -23,6 +24,8 @@ namespace SlnMesnac.WPF
public MainWindow()
{
InitializeComponent();
+
+ this.DataContext = new MainWindowViewModel();
}
}
}
diff --git a/SlnMesnac.WPF/SlnMesnac.WPF.csproj b/SlnMesnac.WPF/SlnMesnac.WPF.csproj
index d3832b7..f8dc1a1 100644
--- a/SlnMesnac.WPF/SlnMesnac.WPF.csproj
+++ b/SlnMesnac.WPF/SlnMesnac.WPF.csproj
@@ -1,7 +1,7 @@
- Exe
+ WinExe
net6.0-windows
enable
true
@@ -9,6 +9,7 @@
+
@@ -27,4 +28,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SlnMesnac.WPF/Templates/icon/Icon.png b/SlnMesnac.WPF/Templates/icon/Icon.png
new file mode 100644
index 0000000..1560465
Binary files /dev/null and b/SlnMesnac.WPF/Templates/icon/Icon.png differ
diff --git a/SlnMesnac.WPF/Templates/image/background.jpg b/SlnMesnac.WPF/Templates/image/background.jpg
new file mode 100644
index 0000000..860c0b0
Binary files /dev/null and b/SlnMesnac.WPF/Templates/image/background.jpg differ
diff --git a/SlnMesnac.WPF/Templates/style/resourceStyle.xaml b/SlnMesnac.WPF/Templates/style/resourceStyle.xaml
new file mode 100644
index 0000000..e7155f2
--- /dev/null
+++ b/SlnMesnac.WPF/Templates/style/resourceStyle.xaml
@@ -0,0 +1,424 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs b/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs
new file mode 100644
index 0000000..99e12d1
--- /dev/null
+++ b/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs
@@ -0,0 +1,152 @@
+using GalaSoft.MvvmLight;
+using GalaSoft.MvvmLight.Command;
+using Microsoft.AspNetCore.Razor.TagHelpers;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using Microsoft.IdentityModel.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace SlnMesnac.WPF.ViewModel
+{
+ public class MainWindowViewModel: ViewModelBase
+ {
+
+ private readonly ILogger _logger;
+
+ #region 参数定义
+ ///
+ /// PLC设备状态
+ ///
+ private int _PlcStatus = 0;
+ public int PlcStatus
+ {
+ get { return _PlcStatus; }
+ set { _PlcStatus = value; RaisePropertyChanged(nameof(PlcStatus)); }
+ }
+ ///
+ /// 箱壳扫码器状态
+ ///
+ private int _ShellScannerStatus = 0;
+ public int ShellScannerStatus
+ {
+ get { return _ShellScannerStatus; }
+ set { _ShellScannerStatus = value; RaisePropertyChanged(nameof(ShellScannerStatus)); }
+ }
+
+ ///
+ /// 内胆扫码器状态
+ ///
+ private int _BoldScannerStatus = 0;
+ public int BoldScannerStatus
+ {
+ get { return _BoldScannerStatus; }
+ set { _BoldScannerStatus = value; RaisePropertyChanged(nameof(BoldScannerStatus)); }
+ }
+
+ public System.Windows.Controls.UserControl _content;
+
+ public System.Windows.Controls.UserControl UserContent
+ {
+ get { return _content; }
+
+ set
+ {
+ _content = value;
+ RaisePropertyChanged(nameof(UserContent));
+ }
+ }
+ #endregion
+
+ #region 事件定义
+ ///
+ /// 界面跳转按钮事件
+ ///
+ public RelayCommand