67 lines
2.1 KiB
C#
67 lines
2.1 KiB
C#
using Cowain.Bake.BLL;
|
|
using Cowain.Bake.Common.Core;
|
|
using Cowain.Bake.Common.Enums;
|
|
using Cowain.Bake.Model;
|
|
using HandyControl.Controls;
|
|
using Prism.Commands;
|
|
using Prism.Mvvm;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using Unity;
|
|
|
|
|
|
namespace Cowain.Bake.UI.Home.ViewModels
|
|
{
|
|
public class SetScannerViewModel : BindableBase
|
|
{
|
|
List<TDeviceConfig> _scanCodeConfigs;
|
|
IUnityContainer _unityContainer;
|
|
|
|
private List<string> scannersName;
|
|
public List<string> ScannersName
|
|
{
|
|
get => scannersName;
|
|
set => SetProperty(ref scannersName, value);
|
|
}
|
|
|
|
private List<bool> isCheckScnner;
|
|
public List<bool> IsCheckScnner
|
|
{
|
|
get => isCheckScnner;
|
|
set => SetProperty(ref isCheckScnner, value);
|
|
}
|
|
public SetScannerViewModel(IUnityContainer unityContainer)
|
|
{
|
|
_unityContainer = unityContainer;
|
|
_scanCodeConfigs = _unityContainer.Resolve<DeviceConfigService>().GetConfig(EDeviceType.SCANNER).OrderBy(x=>x.Id).ToList();
|
|
scannersName = _scanCodeConfigs.Select(x => x.Desc).ToList();
|
|
IsCheckScnner = _scanCodeConfigs.Select(x => x.Enable).ToList();
|
|
}
|
|
|
|
public DelegateCommand<object> SubmitCommand => new DelegateCommand<object>((x) =>
|
|
{
|
|
bool status = false;
|
|
if (MessageBoxResult.OK != HandyControl.Controls.MessageBox.Ask("确认是否重新选择扫码枪!", "操作提示"))
|
|
{
|
|
return;
|
|
}
|
|
|
|
int index = 0;
|
|
foreach (var item in _scanCodeConfigs)
|
|
{
|
|
status = IsCheckScnner[index++];
|
|
_unityContainer.Resolve<DeviceConfigService>().UpdateEnable(item.Id, status);
|
|
|
|
item.Enable = status;
|
|
CommonCoreHelper.Instance.BlockStatusColor.Add(item);
|
|
}
|
|
|
|
HandyControl.Controls.MessageBox.Show("选择成功,请重启上位机!");
|
|
});
|
|
}
|
|
}
|