110 lines
3.7 KiB
C#
110 lines
3.7 KiB
C#
using Prism.Commands;
|
|
using Prism.Mvvm;
|
|
using System.Collections.ObjectModel;
|
|
using System.Windows.Input;
|
|
using XP.Common.Localization.Interfaces;
|
|
using XP.Common.Logging.Interfaces;
|
|
|
|
namespace XP.Scan.ViewModels
|
|
{
|
|
public class XPScanViewModel : BindableBase
|
|
{
|
|
private readonly ILoggerService _logger;
|
|
private readonly ILocalizationService _localizationService;
|
|
private AcquisitionMode _selectedAcquisitionMode;
|
|
private int _mergeLevel = 1;
|
|
private int _acquisitionCount = 10;
|
|
private double _rotationAngle = 0;
|
|
private double _acquisitionProgress = 0;
|
|
private bool _canStartAcquisition = true;
|
|
private bool _canStopAcquisition = false;
|
|
|
|
// 本地化文本属性
|
|
public string LabelScanMode => _localizationService.GetString("Scan_Text_ScanMode");
|
|
public string LabelFrameMerge => _localizationService.GetString("Scan_Text_FrameMerge");
|
|
public string LabelNums => _localizationService.GetString("Scan_Text_Nums");
|
|
public string LabelAngles => _localizationService.GetString("Scan_Text_Angles");
|
|
public string LabelProgress => _localizationService.GetString("Scan_Text_Progress");
|
|
public string LabelStart => _localizationService.GetString("Scan_Button_Start");
|
|
public string LabelStop => _localizationService.GetString("Scan_Button_Stop");
|
|
|
|
public ObservableCollection<AcquisitionMode> AcquisitionModes { get; set; }
|
|
|
|
public AcquisitionMode SelectedAcquisitionMode
|
|
{
|
|
get => _selectedAcquisitionMode;
|
|
set => SetProperty(ref _selectedAcquisitionMode, value);
|
|
}
|
|
|
|
public int MergeLevel
|
|
{
|
|
get => _mergeLevel;
|
|
set => SetProperty(ref _mergeLevel, value);
|
|
}
|
|
|
|
public int AcquisitionCount
|
|
{
|
|
get => _acquisitionCount;
|
|
set => SetProperty(ref _acquisitionCount, value);
|
|
}
|
|
|
|
public double RotationAngle
|
|
{
|
|
get => _rotationAngle;
|
|
set => SetProperty(ref _rotationAngle, value);
|
|
}
|
|
|
|
public double AcquisitionProgress
|
|
{
|
|
get => _acquisitionProgress;
|
|
set => SetProperty(ref _acquisitionProgress, value);
|
|
}
|
|
|
|
public bool CanStartAcquisition
|
|
{
|
|
get => _canStartAcquisition;
|
|
set => SetProperty(ref _canStartAcquisition, value);
|
|
}
|
|
|
|
public bool CanStopAcquisition
|
|
{
|
|
get => _canStopAcquisition;
|
|
set => SetProperty(ref _canStopAcquisition, value);
|
|
}
|
|
|
|
public ICommand StartAcquisitionCommand { get; }
|
|
public ICommand StopAcquisitionCommand { get; }
|
|
|
|
private void StartAcquisition()
|
|
{
|
|
_logger.Info("开始采集 | Start acquisition");
|
|
CanStartAcquisition = false;
|
|
CanStopAcquisition = true;
|
|
}
|
|
|
|
private void StopAcquisition()
|
|
{
|
|
_logger.Info("停止采集 | Stop acquisition");
|
|
CanStartAcquisition = true;
|
|
CanStopAcquisition = false;
|
|
}
|
|
|
|
public XPScanViewModel(ILoggerService loggerService, ILocalizationService localizationService)
|
|
{
|
|
_logger = loggerService.ForModule<XPScanViewModel>();
|
|
_localizationService = localizationService;
|
|
|
|
AcquisitionModes = new ObservableCollection<AcquisitionMode>
|
|
{
|
|
new AcquisitionMode { Id = 1, Name = "QucikScan" },
|
|
new AcquisitionMode { Id = 2, Name = "QualityScan" }
|
|
};
|
|
|
|
SelectedAcquisitionMode = AcquisitionModes[0];
|
|
|
|
StartAcquisitionCommand = new DelegateCommand(StartAcquisition);
|
|
StopAcquisitionCommand = new DelegateCommand(StopAcquisition);
|
|
}
|
|
}
|
|
}
|