| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Services.Dialogs;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using TeamAAS_VP.Core;
- using TeamAAS_VP.Interfaces;
- using TeamAAS_VP.Models;
- using TeamAAS_VP.Models.Scanner;
- namespace TeamAAS_VP.ViewModels.Setting
- {
- public class AddScannerViewModel : BindableBase, IDialogAware
- {
- private readonly IConfigService _configService;
- private ScannerInfo _Scanner;
- /// <summary>
- /// 扫码枪
- /// </summary>
- public ScannerInfo Scanner
- {
- get { return _Scanner ; }
- set
- {
- SetProperty(ref _Scanner, value);
- }
- }
- private DelegateCommand _ConfirmCommand;
- public DelegateCommand ConfirmCommand =>
- _ConfirmCommand ?? (_ConfirmCommand = new DelegateCommand(ExecuteConfirmCommand));
- void ExecuteConfirmCommand()
- {
- if (string.IsNullOrEmpty(Scanner.ScannerName))
- {
- return;
- }
- if (!FileHelper.CheckFileName(Scanner.ScannerName))
- {
- string lbuffer1 = System.Windows.Application.Current.Resources["CalibrationHomeViewModel.Info2"] as string;
- MessageBox.Show($"{lbuffer1}");
- return;
- }
- IDialogParameters parameters = new DialogParameters();
- parameters.Add("Scanner", Scanner);
- Tuple<bool, ScannerInfo> rest = new Tuple<bool, ScannerInfo>(false, Scanner);
- RequestClose?.Invoke(new DialogResult(ButtonResult.OK, parameters));
- }
- private DelegateCommand _CancelCommand;
- public DelegateCommand CancelCommand =>
- _CancelCommand ?? (_CancelCommand = new DelegateCommand(ExecuteCancelCommand));
- void ExecuteCancelCommand()
- {
- IDialogParameters parameters = new DialogParameters();
- parameters.Add("Scanner", Scanner);
- Tuple<bool, ScannerInfo> rest = new Tuple<bool, ScannerInfo>(false, Scanner);
- RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel, parameters));
- }
- public AddScannerViewModel()
- {
- }
- public string Title { get; set; } = "添加扫码枪";
- public event Action<IDialogResult> RequestClose;
- public bool CanCloseDialog()
- {
- return true;
- }
- public void OnDialogClosed()
- {
- }
- public void OnDialogOpened(IDialogParameters parameters)
- {
- Title = System.Windows.Application.Current.Resources["AddRobotViewModel.Info1"] as string;
- Scanner = new ScannerInfo() { Id = Guid.NewGuid() };
- }
- }
- }
|