RecipeStepSelectDialogViewModel.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using FurnaceUI.Models;
  9. using System.Collections.ObjectModel;
  10. namespace FurnaceUI.Views.Recipes
  11. {
  12. public class RecipeStepSelectDialogViewModel : FurnaceUIViewModelBase
  13. {
  14. public RecipeDataBase Recipe { get; set; }
  15. public Step SelectedStep { get; set; }
  16. private ObservableCollection<Step> _newSteps = new ObservableCollection<Step>();
  17. public ObservableCollection<Step> NewSteps
  18. {
  19. get
  20. {
  21. if (Recipe != null && Recipe.Steps != null)
  22. {
  23. _newSteps.Clear();
  24. Recipe.Steps.Where(x => !x.Name.ToLower().Contains("standby") && !x.Name.ToLower().Contains("end")).ToList().ForEach(s => _newSteps.Add(s));
  25. return _newSteps;
  26. }
  27. else
  28. {
  29. return null;
  30. }
  31. }
  32. }
  33. private bool isSaveEnabled;
  34. public bool IsSaveEnabled
  35. {
  36. get => isSaveEnabled;
  37. set
  38. {
  39. isSaveEnabled = value;
  40. NotifyOfPropertyChange(nameof(IsSaveEnabled));
  41. }
  42. }
  43. public RecipeStepSelectDialogViewModel(RecipeDataBase CurrentRecipe)
  44. {
  45. Recipe = CurrentRecipe;
  46. IsSaveEnabled = false;
  47. }
  48. public void SelectStepCmd(object obj)
  49. {
  50. SelectedStep = (Step)obj;
  51. if (SelectedStep != null)
  52. IsSaveEnabled = true;
  53. }
  54. public void CancelCmd()
  55. {
  56. ((Window)GetView()).DialogResult = false;
  57. }
  58. public void SaveCmd()
  59. {
  60. ((Window)GetView()).DialogResult = true;
  61. }
  62. }
  63. }