RecipeStepSelectDialogViewModel.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using FurnaceUI.Models;
  2. using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
  3. using OpenSEMI.ClientBase.Command;
  4. using System.Collections.ObjectModel;
  5. using System.Linq;
  6. using System.Windows.Input;
  7. namespace FurnaceUI.Views.Recipes
  8. {
  9. public class RecipeStepSelectDialogViewModel : FurnaceUIViewModelBase
  10. {
  11. #region ctor
  12. public RecipeStepSelectDialogViewModel(RecipeDataBase CurrentRecipe)
  13. {
  14. Recipe = CurrentRecipe;
  15. }
  16. #endregion
  17. public RecipeDataBase Recipe { get; set; }
  18. private ObservableCollection<Step> _newSteps = new ObservableCollection<Step>();
  19. public ObservableCollection<Step> NewSteps
  20. {
  21. get
  22. {
  23. if (Recipe != null && Recipe.Steps != null)
  24. {
  25. _newSteps.Clear();
  26. Recipe.Steps.Where(x => !x.Name.ToLower().Contains("standby") && !x.Name.ToLower().Contains("end")).ToList().ForEach(s => _newSteps.Add(s));
  27. return _newSteps;
  28. }
  29. else
  30. {
  31. return null;
  32. }
  33. }
  34. }
  35. public Step SelectedStep
  36. {
  37. get { return _selectedStep; }
  38. set
  39. {
  40. _selectedStep = value;
  41. NotifyOfPropertyChange(() => SelectedStep);
  42. }
  43. }
  44. private Step _selectedStep;
  45. private ICommand _saveCommand;
  46. public ICommand SaveCommand
  47. {
  48. get
  49. {
  50. if (this._saveCommand == null)
  51. this._saveCommand = new BaseCommand(() => this.Save(), () => CanSave());
  52. return this._saveCommand;
  53. }
  54. }
  55. private bool CanSave()
  56. {
  57. return SelectedStep != null;
  58. }
  59. private void Save()
  60. {
  61. this.TryClose(true);
  62. }
  63. }
  64. }