终端一体化运控平台
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

RecipeSettingsViewModel.cs 2.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.Toolkit.Mvvm.ComponentModel;
  7. using System.Collections.Concurrent;
  8. using System.Collections.ObjectModel;
  9. using System.Windows;
  10. using BPASmartClient.Helper;
  11. using Microsoft.Toolkit.Mvvm.Input;
  12. using BPASmartClient.DosingSystem.Model;
  13. using BPASmartClient.DosingSystem.View;
  14. namespace BPASmartClient.DosingSystem.ViewModel
  15. {
  16. public class RecipeSettingsViewModel : ObservableObject
  17. {
  18. public RecipeSettingsViewModel()
  19. {
  20. //Json<LocaPar>.Read();
  21. Recipes = Json<LocaPar>.Data.Recipes;
  22. NewRecipe = new Action(() =>
  23. {
  24. NewRecipeView nrv = new NewRecipeView();
  25. nrv.ShowDialog();
  26. });
  27. SaveRecipe = new Action(() => { Json<LocaPar>.Save(); });
  28. RemoveCommand = new RelayCommand<object>((o) =>
  29. {
  30. if (o is string str)
  31. {
  32. var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str);
  33. if (res != null) Json<LocaPar>.Data.Recipes.Remove(res);
  34. }
  35. });
  36. DetailsCommand = new RelayCommand<object>((o) =>
  37. {
  38. if (o != null && o is string str)
  39. {
  40. ActionManage.GetInstance.CancelRegister("Details");
  41. NewRecipeView nrv = new NewRecipeView();
  42. ActionManage.GetInstance.Send("Details", Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str));
  43. nrv.ShowDialog();
  44. }
  45. });
  46. }
  47. public Action NewRecipe { get; set; }
  48. public Action SaveRecipe { get; set; }
  49. public RelayCommand<object> EditCommand { get; set; }
  50. public RelayCommand<object> DetailsCommand { get; set; }
  51. public RelayCommand<object> RemoveCommand { get; set; }
  52. public ObservableCollection<RecipeModel> Recipes { get; set; }
  53. }
  54. }