using Prism.Commands;
using Prism.Ioc;
using Prism.Mvvm;
using Prism.Unity;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using TeamAAS_VP.Core.PLCs;
using TeamAAS_VP.Core.Robots;
using TeamAAS_VP.Interfaces;
using TeamAAS_VP.Resources.Languages;
namespace TeamAAS_VP.Controls
{
///
/// PlcRobotManual.xaml 的交互逻辑
///
public partial class PlcRobotManual : UserControl, INotifyPropertyChanged
{
IConfigService _configService;
public PlcRobotManual()
{
InitializeComponent();
DataContext = this;
}
#region 属性
private ObservableCollection _AdditionalAxisList;
public ObservableCollection AdditionalAxisList
{
get { return _AdditionalAxisList; }
set { SetProperty(ref _AdditionalAxisList, value); }
}
private XYZU_Robot _Robot;
public XYZU_Robot Robot
{
get { return _Robot; }
set
{
SetProperty(ref _Robot, value);
try
{
if (value != null)
{
if (_configService == null)
_configService = ((PrismApplication)(App.Current)).Container.Resolve();
this.Distance = _configService.GetRobotStepDistance(value.Id);
}
}
catch (Exception)
{
}
}
}
private double _Distance = 1;
public double Distance
{
get { return _Distance; }
set
{
SetProperty(ref _Distance, value);
try
{
if (Robot == null)
{
return;
}
if (_configService == null)
_configService = ((PrismApplication)(App.Current)).Container.Resolve();
_configService.UpdateRobotStepDistance(Robot.Id, value);
}
catch (Exception)
{
}
}
}
#endregion
#region 命令
private DelegateCommand _MotorCommand;
public DelegateCommand MotorCommand =>
_MotorCommand ?? (_MotorCommand = new DelegateCommand(ExecuteMotorCommand).ObservesCanExecute(() => CanExecute).ObservesProperty(() => Robot).ObservesProperty(() => Robot.CanExecute));
private DelegateCommand _ResetCommand;
public DelegateCommand ResetCommand =>
_ResetCommand ?? (_ResetCommand = new DelegateCommand(ExecuteResetCommand).ObservesCanExecute(() => CanExecute).ObservesProperty(() => Robot).ObservesProperty(() => Robot.CanExecute));
private DelegateCommand