70 lines
2.1 KiB
C#
70 lines
2.1 KiB
C#
using BOB.Models;
|
|
using Common.PubEvent;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Input;
|
|
|
|
namespace BOB.ViewModels
|
|
{
|
|
public class SingleStepEditViewModel:BindableBase
|
|
{
|
|
#region 属性
|
|
private StepModel _SelectedStep;
|
|
public StepModel SelectedStep
|
|
{
|
|
get => _SelectedStep;
|
|
set => SetProperty(ref _SelectedStep, value);
|
|
}
|
|
private ProgramModel _Program;
|
|
public ProgramModel Program
|
|
{
|
|
get => _Program;
|
|
set => SetProperty(ref _Program, value);
|
|
}
|
|
#endregion
|
|
private GlobalVariables _globalVariables;
|
|
private IEventAggregator _eventAggregator;
|
|
public ICommand CancelEditCommand { get; set; }
|
|
public ICommand SaveStepCommand { get; set; }
|
|
public SingleStepEditViewModel(GlobalVariables globalVariables,IEventAggregator eventAggregator)
|
|
{
|
|
_globalVariables= globalVariables;
|
|
_eventAggregator= eventAggregator;
|
|
_eventAggregator.GetEvent<EditSetpEvent>().Subscribe(EditSingleSetp);
|
|
CancelEditCommand = new DelegateCommand(CancelEdit);
|
|
SaveStepCommand = new DelegateCommand(SaveStep);
|
|
_eventAggregator.GetEvent<DeletedStepEvent>().Subscribe(DisposeSelectedStep);
|
|
Program = _globalVariables.Program;
|
|
}
|
|
|
|
private void DisposeSelectedStep(Guid id)
|
|
{
|
|
if (SelectedStep == null) return;
|
|
if(id== SelectedStep.ID)
|
|
SelectedStep = null;
|
|
}
|
|
|
|
private void CancelEdit()
|
|
{
|
|
SelectedStep = null;
|
|
}
|
|
|
|
private void SaveStep()
|
|
{
|
|
if (SelectedStep == null || (SelectedStep.Method == null && SelectedStep.SubProgram == null))
|
|
{
|
|
return;
|
|
}
|
|
|
|
}
|
|
|
|
private void EditSingleSetp()
|
|
{
|
|
SelectedStep = new StepModel(_globalVariables.SelectedStep);
|
|
}
|
|
}
|
|
}
|