using Aucma.Core.SheetMetal.Common; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; namespace Aucma.Core.SheetMetal.ViewModels { public partial class SearchCriteriaViewModel : ObservableObject { private AppConfigHelper appConfig =new AppConfigHelper(); public SearchCriteriaViewModel() { } #region 关闭当前页 [RelayCommand] private void CloseWindow(object parameter) { var window = parameter as Window; if (window != null) { window.Close(); } } #endregion #region 保存数据 [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(); } #endregion #region MyRegion private ObservableCollection _configurations = new ObservableCollection(); public ObservableCollection Configurations { get => _configurations; set => SetProperty(ref _configurations, value); } #endregion #region 初始化 private void Init() { Configurations = new ObservableCollection(); var searchItems = appConfig.searchItems; var split = searchItems.Split('%'); foreach (var item in split) { Configurations.Add(item); } } #endregion } }