generated from wenjy/SlnMesnac
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
138 lines
4.2 KiB
C#
138 lines
4.2 KiB
C#
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using SlnMesnac.Serilog;
|
|
using SlnMesnac.WPF.Attribute;
|
|
using SlnMesnac.WPF.Page;
|
|
using SlnMesnac.WPF.Page.Generate;
|
|
using SlnMesnac.WPF.Page.ProductDetails;
|
|
using SlnMesnac.WPF.ViewModel.Base;
|
|
using System;
|
|
using System.Windows;
|
|
|
|
namespace SlnMesnac.WPF.ViewModel
|
|
{
|
|
[RegisterAsSingletonAttribute]
|
|
public partial class MainWindowViewModel : BaseViewModel
|
|
{
|
|
public readonly SerilogHelper _logger;
|
|
private readonly GenerateControl _generateControl;
|
|
private readonly IndexControl _indexControl;
|
|
private readonly DetailsEditControl _detailsEditControl;
|
|
#region 参数定义
|
|
/// <summary>
|
|
/// PLC设备状态
|
|
/// </summary>
|
|
[ObservableProperty]
|
|
private int plcStatus = 0;
|
|
|
|
/// <summary>
|
|
/// 登录人员
|
|
/// </summary>
|
|
[ObservableProperty]
|
|
private string otherInfo;
|
|
|
|
/// <summary>
|
|
/// 系统标题
|
|
/// </summary>
|
|
[ObservableProperty]
|
|
private string systemTitle = string.Empty;
|
|
|
|
[ObservableProperty]
|
|
public System.Windows.Controls.UserControl userContent = new System.Windows.Controls.UserControl();
|
|
|
|
/// <summary>
|
|
/// 箱壳扫码器状态
|
|
/// </summary>
|
|
[ObservableProperty]
|
|
private int _shellScannerStatus = 0;
|
|
|
|
/// <summary>
|
|
/// 内胆扫码器状态
|
|
/// </summary>
|
|
[ObservableProperty]
|
|
private int _boldScannerStatus = 0;
|
|
|
|
#endregion
|
|
|
|
|
|
public MainWindowViewModel(SerilogHelper logger,GenerateControl generateControl,IndexControl indexControl, DetailsEditControl detailsEditControl)
|
|
{
|
|
|
|
_logger = logger;
|
|
_generateControl = generateControl;
|
|
_indexControl = indexControl;
|
|
_detailsEditControl = detailsEditControl;
|
|
this.UserContent = _detailsEditControl;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 窗体控制
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
[RelayCommand]
|
|
[RequirePermission("FormControl")]
|
|
private void FormControl(object obj)
|
|
{
|
|
try
|
|
{
|
|
string controlType = obj as string;
|
|
switch (controlType)
|
|
{
|
|
// 关闭当前窗口
|
|
case "Exit":
|
|
//Environment.Exit(0);
|
|
Application.Current.Shutdown();
|
|
break;
|
|
case "Generate":
|
|
UserContent = _generateControl;
|
|
break;
|
|
// 还原 或者 最大化当前窗口
|
|
case "Normal":
|
|
if (Application.Current.MainWindow.WindowState == WindowState.Normal)
|
|
{
|
|
Application.Current.MainWindow.WindowState = WindowState.Maximized;
|
|
break;
|
|
}
|
|
if (Application.Current.MainWindow.WindowState == WindowState.Maximized)
|
|
{
|
|
Application.Current.MainWindow.WindowState = WindowState.Normal;
|
|
break;
|
|
}
|
|
break;
|
|
|
|
// 最小化当前窗口
|
|
case "Minimized":
|
|
Application.Current.MainWindow.WindowState = WindowState.Minimized;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.Error("窗体控制逻辑异常", ex);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 界面跳转
|
|
/// </summary>
|
|
[RelayCommand]
|
|
private void ControlOnClick(object obj)
|
|
{
|
|
try
|
|
{
|
|
string info = obj as string;
|
|
//UserContent = inStoreInfoControl;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.Error("界面跳转逻辑异常", ex);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|