using System.ComponentModel;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using exam.Model;
namespace exam
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : Window, INotifyPropertyChanged
{
private IEnumerable _clothes = null;
public List ClothesCategoriesList { get; set; }
public string selectedCategory = "";
public IEnumerable ClothesList
{
get
{
return _clothes
.Where(c => (selectedCategory == "Все категории" || c.Category == selectedCategory));
}
set
{
_clothes = value;
}
}
public MainWindow()
{
InitializeComponent();
DataContext = this;
Globals.dataProvider = new JsonDataProvider();
ClothesList = Globals.dataProvider.GetClothes();
ClothesCategoriesList = Globals.dataProvider.GetClothesCategories().ToList();
ClothesCategoriesList.Insert(0, new ClothesCategory { Title = "Все категории" });
}
private void ExitButton_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
private void CategoryFilterComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
selectedCategory = (CategoryFilterComboBox.SelectedItem as ClothesCategory).Title;
Invalidate();
}
public event PropertyChangedEventHandler PropertyChanged;
private void Invalidate()
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("ClothesList"));
}
}
}