using FurnaceUI.Models; using MECF.Framework.UI.Client.CenterViews.Editors.Recipe; using OpenSEMI.ClientBase.Command; using System.Collections.ObjectModel; using System.Linq; using System.Windows.Input; namespace FurnaceUI.Views.Recipes { public class RecipeStepSelectDialogViewModel : FurnaceUIViewModelBase { #region ctor public RecipeStepSelectDialogViewModel(RecipeDataBase CurrentRecipe) { Recipe = CurrentRecipe; } #endregion public RecipeDataBase Recipe { get; set; } private ObservableCollection _newSteps = new ObservableCollection(); public ObservableCollection NewSteps { get { if (Recipe != null && Recipe.Steps != null) { _newSteps.Clear(); Recipe.Steps.Where(x => !x.Name.ToLower().Contains("standby") && !x.Name.ToLower().Contains("end")).ToList().ForEach(s => _newSteps.Add(s)); return _newSteps; } else { return null; } } } public Step SelectedStep { get { return _selectedStep; } set { _selectedStep = value; NotifyOfPropertyChange(() => SelectedStep); } } private Step _selectedStep; private ICommand _saveCommand; public ICommand SaveCommand { get { if (this._saveCommand == null) this._saveCommand = new BaseCommand(() => this.Save(), () => CanSave()); return this._saveCommand; } } private bool CanSave() { return SelectedStep != null; } private void Save() { this.TryClose(true); } } }