| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Services.Dialogs;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows;
- using TeamAAS_VP.Core;
- using TeamAAS_VP.Interfaces;
- using TeamAAS_VP.Models;
- using TeamAAS_VP.Resources.Languages;
- namespace TeamAAS_VP.ViewModels.Setting
- {
- public class AddPlcViewModel : BindableBase, IDialogAware
- {
- private PlcInfo _SelectedPlc;
- public PlcInfo SelectedPlc
- {
- get { return _SelectedPlc; }
- set { SetProperty(ref _SelectedPlc, value); }
- }
- private DelegateCommand _ConfirmCommand;
- public DelegateCommand ConfirmCommand =>
- _ConfirmCommand ?? (_ConfirmCommand = new DelegateCommand(ExecuteConfirmCommand));
- void ExecuteConfirmCommand()
- {
- if (string.IsNullOrEmpty(SelectedPlc.Name))
- {
- return;
- }
- if (!FileHelper.CheckFileName(SelectedPlc.Name))
- {
- MessageBox.Show(Lang.AddCameraVM_message1, "AAS", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
- IDialogParameters parameters = new DialogParameters();
- parameters.Add("PLC", SelectedPlc);
- Tuple<bool, PlcInfo> rest = new Tuple<bool, PlcInfo>(false, SelectedPlc);
- 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("PLC", SelectedPlc);
- Tuple<bool, PlcInfo> rest = new Tuple<bool, PlcInfo>(false, SelectedPlc);
- RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel, parameters));
- }
- public AddPlcViewModel()
- {
- }
- public string Title { get; set; } = Lang.添加PLC;
- public event Action<IDialogResult> RequestClose;
- public bool CanCloseDialog()
- {
- return true;
- }
- public void OnDialogClosed()
- {
- }
- public void OnDialogOpened(IDialogParameters parameters)
- {
- Title = Lang.增加PLC;
- SelectedPlc = new PlcInfo() { Id = Guid.NewGuid() };
- }
- }
- }
|