RecipeStepSelectDialogViewModel.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. using MECF.Framework.UI.Client.ClientBase;
  11. using OpenSEMI.ClientBase;
  12. namespace FurnaceUI.Views.Recipes
  13. {
  14. public class RecipeStepSelectDialogViewModel : FurnaceUIViewModelBase
  15. {
  16. public RecipeDataBase Recipe { get; set; }
  17. public Step SelectedStep { 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. private bool isSaveEnabled;
  36. public bool IsSaveEnabled
  37. {
  38. get => isSaveEnabled;
  39. set
  40. {
  41. isSaveEnabled = value;
  42. NotifyOfPropertyChange(nameof(IsSaveEnabled));
  43. }
  44. }
  45. public RecipeStepSelectDialogViewModel(RecipeDataBase CurrentRecipe)
  46. {
  47. Recipe = CurrentRecipe;
  48. IsSaveEnabled = false;
  49. }
  50. public void SelectStepCmd(object obj)
  51. {
  52. SelectedStep = (Step)obj;
  53. if (SelectedStep != null)
  54. IsSaveEnabled = true;
  55. }
  56. public void CancelCmd()
  57. {
  58. ((Window)GetView()).DialogResult = false;
  59. }
  60. public void SaveCmd()
  61. {
  62. if (DialogButton.No == DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No,
  63. DialogType.CONFIRM,
  64. $"Make sure to Copy the selected step?"))
  65. {
  66. return;
  67. }
  68. ((Window)GetView()).DialogResult = true;
  69. }
  70. }
  71. }