using Aucma.Scada.UI.Common; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using System.Collections.ObjectModel; using System.Linq; using System.Windows; namespace Aucma.Scada.UI.ViewModel.AssemblyPlan { public partial class SearchCriteriaViewModel : ObservableObject { private AppConfig appConfig = AppConfig.Instance; public SearchCriteriaViewModel() { init(); } private ObservableCollection _configurations = new ObservableCollection(); public ObservableCollection Configurations { get => _configurations; set => SetProperty(ref _configurations, value); } [RelayCommand] private void SaveSearchCriteria() { var info = _configurations.ToList(); string items = string.Empty; foreach (var configuration in info) { items += configuration.ToString() + "%"; } appConfig.searchItems = string.Empty; appConfig.searchItems = items; init(); } [RelayCommand] private void CloseWindow(object parameter) { var window = parameter as Window; if (window != null) { window.Close(); } } private void init() { Configurations = new ObservableCollection(); var searchItems = appConfig.searchItems; var split = searchItems.Split('%'); foreach (var item in split) { Configurations.Add(item); } } } }