You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Aucma.Scada/Aucma.Scada.UI/viewModel/AssemblyPlan/SearchCriteriaViewModel.cs

75 lines
2.0 KiB
C#

using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using HighWayIot.Config;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
namespace Aucma.Scada.UI.viewModel.AssemblyPlan
{
public class SearchCriteriaViewModel : ViewModelBase
{
private AppConfig appConfig = AppConfig.Instance;
public SearchCriteriaViewModel()
{
SaveSearchCriteriaCommand = new RelayCommand(SaveSearchCriteria);
CloseWindowCommand = new RelayCommand<object>(t => CloseWindow(t));
init();
}
private ObservableCollection<string> _configurations = new ObservableCollection<string>();
public ObservableCollection<string> Configurations
{
get { return _configurations; }
set
{
_configurations = value;
RaisePropertyChanged(nameof(Configurations));
}
}
public RelayCommand SaveSearchCriteriaCommand { get; set; }
public RelayCommand<object> CloseWindowCommand { get; set; }
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();
}
private void CloseWindow(object parameter)
{
var window = parameter as Window;
if (window != null)
{
window.Close();
}
}
private void init()
{
Configurations = new ObservableCollection<string>();
var searchItems = appConfig.searchItems;
var split = searchItems.Split('%');
foreach (var item in split)
{
Configurations.Add(item);
}
}
}
}