| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- using Prism.Commands;
- using Prism.Events;
- using Prism.Ioc;
- using Prism.Mvvm;
- using Prism.Regions;
- using Prism.Services.Dialogs;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows;
- using TeamAAS_VP;
- using TeamAAS_VP.Core;
- using TeamAAS_VP.Interfaces;
- using TeamAAS_VP.Models;
- using TeamAAS_VP.Models.Calibration;
- using TeamAAS_VP.Resources.Languages;
- using TeamAAS_VP.Services;
- namespace TeamAAS_VP.ViewModels.Calibration
- {
- public class CalibrationResultViewModel : BindableBase, IConfirmNavigationRequest
- {
- IRegionManager _regionManager;
- IRegionNavigationService _regionNavigationService;
- IContainerProvider _container;
- IDialogService _dialogService;
- IEventAggregator _eventAggregator;
- IConfigService _configService;
- ICalibrationService _calibrationService;
- ISystemDatabaseService _systemDatabaseService;
- #region 属性
- private CalibrationInfo _SelectCalibration;
- public CalibrationInfo SelectCalibration
- {
- get { return _SelectCalibration; }
- set { SetProperty(ref _SelectCalibration, value); }
- }
- private CalibrationResult _Result;
- public CalibrationResult Result
- {
- get { return _Result; }
- set { SetProperty(ref _Result, value); }
- }
- private CalibrationTestResult _TestResult;
- public CalibrationTestResult TestResult
- {
- get { return _TestResult; }
- set { SetProperty(ref _TestResult, value); }
- }
- #endregion
- #region 命令
- private DelegateCommand _LoadedCommand;
- public DelegateCommand LoadedCommand =>
- _LoadedCommand ?? (_LoadedCommand = new DelegateCommand(ExecuteLoadedCommand));
- private DelegateCommand _NextCommand;
- public DelegateCommand NextCommand =>
- _NextCommand ?? (_NextCommand = new DelegateCommand(ExecuteNextCommand));
- private DelegateCommand _BackCommand;
- public DelegateCommand BackCommand =>
- _BackCommand ?? (_BackCommand = new DelegateCommand(ExecuteBackCommand));
- #endregion
- #region 事件
- #endregion
- public CalibrationResultViewModel(IRegionManager regionManager, IEventAggregator ea, IRegionNavigationService regionNavigationService, IContainerProvider container, IDialogService dialogService,
- IConfigService configService, ICalibrationService calibrationService, ISystemDatabaseService systemDatabaseService)
- {
- _regionManager = regionManager;
- _regionNavigationService = regionNavigationService;
- _container = container;
- _dialogService = dialogService;
- _eventAggregator = ea;
- _configService = configService;
- _calibrationService = calibrationService;
- _systemDatabaseService = systemDatabaseService;
- }
- #region 方法
- void ExecuteLoadedCommand()
- {
- if (_systemDatabaseService.GetCurrentUser().userPart == Enums.UserPart.Operator)
- {
- IsAllowEdit = false;
- }
- else
- {
- IsAllowEdit = true;
- }
-
- }
- /// <summary>
- /// 下一步
- /// </summary>
- void ExecuteNextCommand()
- {
- NavigationParameters param = new NavigationParameters();
- param.Add("SelectCalibration", SelectCalibration);
- _calibrationService.AddOrUpdateCalibration(SelectCalibration);
- _regionManager.RequestNavigate("CalibrationRegionContext", "CalibrationHome", param);
- }
- /// <summary>
- /// 上一步
- /// </summary>
- void ExecuteBackCommand()
- {
- NavigationParameters param = new NavigationParameters();
- param.Add("SelectCalibration", SelectCalibration);
- _regionManager.RequestNavigate("CalibrationRegionContext", "CalibrationVerification", param);
- }
- private void CalibrationEditVisionViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
- {
- //if (e.PropertyName == "SelectCalibration")
- //{
- // SelectCalibration = _container.Resolve<CalibrationHomeViewModel>().SelectCalibration;
- //}
- }
- #endregion
- #region 继承
- /// <summary>
- /// 确认导航请求时调用。此方法允许您在导航之前执行一些操作。
- /// </summary>
- /// <param name="navigationContext"></param>
- /// <param name="continuationCallback"></param>
- public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
- {
- continuationCallback(true);
- }
- /// <summary>
- /// 接收导航请求时调用。传入导航参数,包含有关导航目标的信息。
- /// </summary>
- /// <param name="navigationContext"></param>
- /// <exception cref="NotImplementedException"></exception>
- public async void OnNavigatedTo(NavigationContext navigationContext)
- {
- SelectCalibration = navigationContext.Parameters.GetValue<CalibrationInfo>("SelectCalibration");
- try
- {
- SelectCalibration = _container.Resolve<CalibrationHomeViewModel>().SelectCalibration;
- Result = SelectCalibration.CalibrationResult;
- TestResult = SelectCalibration.CalibrationTestResult;
- }
- catch (Exception ex)
- {
- LogHelper.WriteLogError(Lang.相机校准校准结果界面加载时出错, ex);
- MessageBox.Show(ex.Message);
- }
- }
- /// <summary>
- /// 是否允许导航到此视图模型。
- /// </summary>
- /// <param name="navigationContext"></param>
- /// <returns></returns>
- public bool IsNavigationTarget(NavigationContext navigationContext)
- {
- return true;
- }
- /// <summary>
- /// 导航离开此视图模型时调用。您可以在此处执行清理操作或保存状态。
- /// </summary>
- /// <param name="navigationContext"></param>
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
- }
- #endregion
- private bool _IsAllowEdit = false;
- public bool IsAllowEdit
- {
- get { return _IsAllowEdit; }
- set { SetProperty(ref _IsAllowEdit, value); }
- }
- private void LoginChange(Models.User user)
- {
- if (user.userPart == Enums.UserPart.Operator)
- {
- IsAllowEdit = false;
- }
- else
- {
- IsAllowEdit = true;
- }
- }
- }
- }
|