using BPASmartClient.CustomResource.Pages.Model; using BPASmartClient.CustomResource.UserControls; using BPASmartClient.CustomResource.UserControls.MessageShow; using BPA.Helper; using BPA.Helper; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; namespace BPASmartClient.CustomResource.Pages.ViewModel { public class VariableViewModel : NotifyBase { public ObservableCollection Variables { get; set; } = new ObservableCollection(); public ObservableCollection FryOneVariables { get; set; } = new ObservableCollection(); public ObservableCollection FryTwoVariables { get; set; } = new ObservableCollection(); public ObservableCollection FryThreeVariables { get; set; } = new ObservableCollection(); public ObservableCollection FryFourVariables { get; set; } = new ObservableCollection(); public ObservableCollection FryFiveVariables { get; set; } = new ObservableCollection(); public List DeviceName { get; set; } = new List { "滚筒输送线", "炒锅1", "炒锅2", "炒锅3", "炒锅4", "炒锅5" }; public BPARelayCommand SaveDataCommand { get; set; } public VariableViewModel() { Json.Read(); try { if (Json.Data.VariablesInfo.Count>0) { Variables = Json.Data.VariablesInfo["滚筒输送线"]; FryOneVariables = Json.Data.VariablesInfo["炒锅1"]; FryTwoVariables = Json.Data.VariablesInfo["炒锅2"]; FryThreeVariables = Json.Data.VariablesInfo["炒锅3"]; FryFourVariables = Json.Data.VariablesInfo["炒锅4"]; FryFiveVariables = Json.Data.VariablesInfo["炒锅5"]; } } catch (Exception) { } SaveDataCommand = new BPARelayCommand(() => { Json.Data.VariablesInfo["滚筒输送线"] = Variables; Json.Data.VariablesInfo["炒锅1"] = FryOneVariables; Json.Data.VariablesInfo["炒锅2"]=FryTwoVariables; Json.Data.VariablesInfo["炒锅3"] = FryThreeVariables; Json.Data.VariablesInfo["炒锅4"]= FryFourVariables; Json.Data.VariablesInfo["炒锅5"] = FryFiveVariables; Json.Save(); MessageBox.Show("保存成功","提示",MessageBoxButton.OK,MessageBoxImage.Information); }); } } }