12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- 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
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window, INotifyPropertyChanged
- {
- private IEnumerable<Clothes> _clothes = null;
- public List <ClothesCategory> ClothesCategoriesList { get; set; }
- public string selectedCategory = "";
- public IEnumerable<Clothes> 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"));
- }
- }
- }
|