You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- using BPASmart.Model.配方;
- using BPASmartClient.Helper;
- using BPASmartClient.RecipeManagement.View;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using Microsoft.Toolkit.Mvvm.Input;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPASmart.RecipeManagement.ViewModel
- {
- public class RecipeManagerViewModel:ObservableObject
- {
- public ObservableCollection<Recipes> RecipeList { get; set; } = Json<LocalRecipes>.Data.locaRecipes;
-
- public RelayCommand CreateRecipeCommand { get; set; }
- public RelayCommand<object> EditRecipeCommand { get; set; }
- public RelayCommand<object> DeleteRecipeCommand { get; set; }
-
- private void EditRecipe(object o)
- {
- if (o == null) return;
- if (o is int item && item >= 0)
- {
- Globle.GlobleData.ChangeRecipes = new Recipes();
- Globle.GlobleData.ChangeRecipes = RecipeList[item];
- RecipesConfigure recipesConfigure = new RecipesConfigure();
- recipesConfigure.ShowDialog();
- }
- }
-
- private void DeleteRecipe(object o)
- {
- if (o == null) return;
- if (o is int i && i >= 0)
- {
- RecipeList.RemoveAt(i);
- Json<LocalRecipes>.Save();
- }
- }
-
- public RecipeManagerViewModel()
- {
- CreateRecipeCommand = new RelayCommand(() =>
- {
- Globle.GlobleData.ChangeRecipes = null;
- RecipesConfigure recipesConfigure = new RecipesConfigure();
- recipesConfigure.ShowDialog();
- });
-
- EditRecipeCommand = new RelayCommand<object>(EditRecipe);
-
- DeleteRecipeCommand = new RelayCommand<object>(DeleteRecipe);
-
- }
- }
- }
|