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

83 lines
2.2 KiB
C#

using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using HighWayIot.Config;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
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);
}
}
}
}