终端一体化运控平台
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.
 
 
 

88 linhas
3.2 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.DosingHKProject.Model;
  13. using BPASmartClient.DosingHKProject.View;
  14. using BPASmartClient.CustomResource.UserControls;
  15. using BPASmartClient.CustomResource.UserControls.Model;
  16. using BPASmartClient.CustomResource.UserControls.Enum;
  17. using System.Windows.Media;
  18. using BPASmartClient.CustomResource.UserControls.MessageShow;
  19. using BPASmartClient.CustomResource.Pages.Model;
  20. using BPASmartClient.Model;
  21. using BPASmartClient.DosingProject;
  22. namespace BPASmartClient.DosingHKProject.ViewModel
  23. {
  24. public class RecipeSettingsViewModel : ObservableObject
  25. {
  26. public RecipeSettingsViewModel()
  27. {
  28. Recipes = Json<LocaPar>.Data.Recipes;
  29. NewMaterital = new RelayCommand(() =>
  30. {
  31. NewMaterialView newMateritalView = new NewMaterialView();
  32. newMateritalView.ShowDialog();
  33. });
  34. NewRecipe = new RelayCommand(() =>
  35. {
  36. NewRecipeView nrv = new NewRecipeView();
  37. nrv.ShowDialog();
  38. MessageNotify.GetInstance.ShowUserLog("新建配方");
  39. });
  40. SaveRecipe = new RelayCommand(() =>
  41. {
  42. Json<LocaPar>.Save();
  43. MessageNotify.GetInstance.ShowUserLog("保存配方");
  44. NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方保存成功!");
  45. });
  46. RemoveCommand = new RelayCommand<object>((o) =>
  47. {
  48. if (o is string str)
  49. {
  50. var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str);
  51. if (res != null) Json<LocaPar>.Data.Recipes.Remove(res);
  52. MessageNotify.GetInstance.ShowUserLog($"删除名称——{res.RecipeName}");
  53. }
  54. });
  55. DetailsCommand = new RelayCommand<object>((o) =>
  56. {
  57. if (o != null && o is string str)
  58. {
  59. ActionManage.GetInstance.CancelRegister("Details");
  60. NewRecipeView nrv = new NewRecipeView();
  61. var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str);
  62. ActionManage.GetInstance.Send("Details", res);
  63. nrv.ShowDialog();
  64. MessageNotify.GetInstance.ShowUserLog($"编辑配方名称——{res.RecipeName}");
  65. }
  66. });
  67. }
  68. public RelayCommand NewMaterital { get; set; }
  69. public RelayCommand NewRecipe { get; set; }
  70. public RelayCommand SaveRecipe { get; set; }
  71. public RelayCommand<object> EditCommand { get; set; }
  72. public RelayCommand<object> DetailsCommand { get; set; }
  73. public RelayCommand<object> RemoveCommand { get; set; }
  74. public ObservableCollection<RecipeModel> Recipes { get; set; }
  75. }
  76. }