终端一体化运控平台
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

64 rindas
2.0 KiB

  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. }