|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- using BPASmartClient.CustomResource.Pages.Model;
- using BPA.Helper;
- using BPASmartClient.JXJFoodSmallStation.Model;
- using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
- using BPA.Helper;
-
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.JXJFoodSmallStation.ViewModel
- {
- internal class SelectRecipesViewModel:NotifyBase
- {
- public SelectRecipesViewModel()
- {
- AllRecipes = new();
- SelectRecipes.Clear();
- foreach (var item in Json<LocalRecipeDataColl>.Data.SelectedRecipes)
- {
- SelectRecipes.Add(item);
- }
-
- if (Json<LocalRecipeDataColl>.Data.RemoteRecipes != null)
- {
- foreach (var item in Json<LocalRecipeDataColl>.Data.RemoteRecipes)
- {
- AllRecipes.Add(new RecipeDataWithCheck()
- {
- Recipe = item,
- IsSelected = SelectRecipes.Any(p => p.RecipeCode == item.RecipeCode)
- });
- }
- }
-
-
- ConfirmCommand = new(() =>
- {
- RefreshSelected();
- ActionManage.GetInstance.Send("CloseSelectRecipesView");
- });
-
- CancelCommand = new(() =>
- {
- ActionManage.GetInstance.Send("CloseSelectRecipesView");
- });
-
- AllSelectCommand = new(() =>
- {
- foreach (var item in AllRecipes)
- {
- item.IsSelected = true;
- }
- });
-
- AllCancelCommand = new(() =>
- {
- foreach (var item in AllRecipes)
- {
- item.IsSelected = false;
- }
- });
-
- }
-
- private void RefreshSelected()
- {
- SelectRecipes.Clear();
- foreach (var item in AllRecipes)
- {
- if (item.IsSelected==true)
- {
- SelectRecipes.Add(item.Recipe);
- }
- }
- }
-
- public ObservableCollection<RecipeDataWithCheck> AllRecipes {get; set; }
-
- public static ObservableCollection<RecipeData> SelectRecipes { get; set; } = new ObservableCollection<RecipeData>();
-
- /// <summary>
- /// 取消筛选,即关闭本窗口。
- /// </summary>
- public BPARelayCommand CancelCommand { get; set; }
- /// <summary>
- /// 全选。
- /// </summary>
- public BPARelayCommand AllSelectCommand { get; set; }
- /// <summary>
- /// 全部取消选择。
- /// </summary>
- public BPARelayCommand AllCancelCommand { get; set; }
- /// <summary>
- /// 确认选择。
- /// </summary>
- public BPARelayCommand ConfirmCommand { get; set; }
-
-
- internal class RecipeDataWithCheck:NotifyBase
- {
- public RecipeData Recipe { get; set; }
- private bool _IsSelected;
-
- public bool IsSelected
- {
- get { return _IsSelected; }
- set { _IsSelected = value; OnPropertyChanged(); }
- }
-
- }
- }
- }
|