|
|
using Admin.Core.Common;
|
|
|
using Admin.Core.Wpf.Views;
|
|
|
using AutoMapper.Configuration;
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
namespace Admin.Core.Wpf.ViewModels
|
|
|
{
|
|
|
public class MainWindowViewModel : ObservableObject
|
|
|
{
|
|
|
private IndexPage firstPage = new IndexPage();//首页
|
|
|
public MainWindowViewModel()
|
|
|
{
|
|
|
UserContent = firstPage;
|
|
|
ExecCommand = new AsyncRelayCommand(ExecMethod);
|
|
|
}
|
|
|
|
|
|
#region 点击方法
|
|
|
public IAsyncRelayCommand ExecCommand { get; }
|
|
|
|
|
|
|
|
|
public async Task ExecMethod()
|
|
|
{
|
|
|
//await Task.Run(async () =>
|
|
|
//{
|
|
|
// //var r=await _quipmentCategoryServices.QueryAsync();
|
|
|
|
|
|
// //foreach (var item in r)
|
|
|
// //{
|
|
|
// // MessageBox.Show(item.Name);
|
|
|
// //}
|
|
|
|
|
|
// //WeakReferenceMessenger.Default.Send("数据采集成功");
|
|
|
//});
|
|
|
MessageBox.Show("sa");
|
|
|
await Task.CompletedTask;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 更换界面
|
|
|
|
|
|
public System.Windows.Controls.UserControl _content;
|
|
|
|
|
|
public System.Windows.Controls.UserControl UserContent
|
|
|
{
|
|
|
get => _content;
|
|
|
set => SetProperty(ref _content, value);
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region plc 状态
|
|
|
/// <summary>
|
|
|
/// UI plc 展示状态-文字
|
|
|
/// </summary>
|
|
|
public string _plcUIStatus;
|
|
|
public string PlcUIStatusWb
|
|
|
{
|
|
|
//get { return plcUIStatusWb; }
|
|
|
//set { plcUIStatusWb = value; RaisePropertyChanged("PlcUIStatusWb"); }
|
|
|
get => _plcUIStatus;
|
|
|
set => SetProperty(ref _plcUIStatus, value);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// UI plc 展示状态-颜色
|
|
|
/// </summary>
|
|
|
public string _plcUIColor;
|
|
|
public string PlcUIColor
|
|
|
{
|
|
|
//get { return plcUIColor; }
|
|
|
//set { plcUIColor = value; RaisePropertyChanged("PlcUIColor"); }
|
|
|
get => _plcUIColor;
|
|
|
set => SetProperty(ref _plcUIColor, value);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// UI plc 展示状态-图标
|
|
|
/// </summary>
|
|
|
public string _plcUIIcon;
|
|
|
public string PlcUIIcon
|
|
|
{
|
|
|
//get { return plcUIIcon; }
|
|
|
//set { plcUIIcon = value; RaisePropertyChanged("plcUIIcon"); }
|
|
|
get => _plcUIIcon;
|
|
|
set => SetProperty(ref _plcUIIcon, value);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// PLC连接状态-true:连接成功;false:失败
|
|
|
/// </summary>
|
|
|
/// <param name="type"></param>
|
|
|
public void PlcState(bool type)
|
|
|
{
|
|
|
if (type)
|
|
|
{
|
|
|
PlcUIStatusWb = "PLC连接成功";
|
|
|
PlcUIColor = "White";
|
|
|
PlcUIIcon = "Assets/Images/正常.png";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
PlcUIStatusWb = "PLC状态异常";
|
|
|
PlcUIColor = "Red";
|
|
|
PlcUIIcon = "Assets/Images/失败-01.png";
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
}
|