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 wpf_template.models; using System.Threading.Tasks; using System; namespace wpf_template { public partial class MainWindow : Window, INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private void Invalidate() { if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("PeopleList")); } public string selectedGender = "Пол"; public PeopleAge? selectedAge = null; public string selectedPlace = "Место"; private IEnumerable _PeopleList; public IEnumerable PeopleList { get { return _PeopleList .Where(c => (c.Gender == selectedGender || selectedGender == "Пол")) .Where(c => (selectedAge == null || (c.Age >= selectedAge.AgeFrom && c.Age < selectedAge.AgeTo))) .Where(c => (c.Place == selectedPlace || selectedPlace == "Место")); } set { _PeopleList = value; } } public List PeopleGenderList { get; set; } public List PeopleAgeList { get; set; } public List PeoplePlaceList { get; set; } public MainWindow() { InitializeComponent(); DataContext = this; Globals.dataProvider = new LocalDataProvider(); PeopleList = Globals.dataProvider.getPeople(); PeopleGenderList = Globals.dataProvider.getGender().ToList(); PeopleGenderList.Insert(0, new PeopleGender { title = "Пол" }); PeopleAgeList = Globals.dataProvider.getAge().ToList(); PeoplePlaceList = Globals.dataProvider.getPlace().ToList(); PeoplePlaceList.Insert(0, new PeoplePlace { title = "Место" }); } private void ExitButton_Click(object sender, RoutedEventArgs e) { Application.Current.Shutdown(); } private void GenderFilterComboBox_SelectionChanged_1(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { selectedGender = (GenderFilterComboBox.SelectedItem as PeopleGender).title; Invalidate(); } private void AgeFilterComboBox_SelectionChanged_2(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { selectedAge = AgeFilterComboBox.SelectedItem as PeopleAge; Invalidate(); } private void PlaceFilterComboBox_SelectionChanged_3(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { selectedPlace = (PlaceFilterComboBox.SelectedItem as PeoplePlace).title; Invalidate(); } public class LocalDataProvider : IDataProvider { public IEnumerable getGender() { return new PeopleGender[] { new PeopleGender() { title="Ж" }, new PeopleGender() { title="М" } }; } public IEnumerable getAge() { return new PeopleAge[] { new PeopleAge() { title="Все возраста", AgeFrom=0, AgeTo=99 }, new PeopleAge() { title="Подростки", AgeFrom=15, AgeTo=18 }, new PeopleAge() { title="Молодые", AgeFrom=18, AgeTo=30 }, new PeopleAge() { title="В Возврасте", AgeFrom=30, AgeTo=99 } }; } public IEnumerable getPlace() { return new PeoplePlace[] { new PeoplePlace() { title="Набережная" }, new PeoplePlace() { title="Йолка" }, new PeoplePlace() { title="Бульвар" }, new PeoplePlace() { title="ЙОТК" }, new PeoplePlace() { title="Планета" }, new PeoplePlace() { title="Ремзавод" }, new PeoplePlace() { title="Медведево" }, new PeoplePlace() { title="Пляж" }, }; } public IEnumerable getPeople() { return new People[]{ new People { Age=19, Name="Марина", Gender="Ж", Price=500, Place="Набережная" }, new People { Price=9600, Name="Вика", Age=21, Gender="Ж", Place="Йолка" }, new People { Price=50, Name="Кристина", Age=17, Gender="Ж", Place="Планета" }, new People { Price=2000, Name="Анджелика", Age=16, Gender="Ж", Place="Бульвар" }, new People { Price=1500, Name="Костя", Age=15, Gender="М", Place="Бульвар" }, new People { Price=5000, Name="Вероника", Age=25, Gender="Ж", Place="Набережная" }, new People { Price=1000, Name="Савелий", Age=20, Gender="М", Place="Пляж" }, new People { Price=1500, Name="Александр", Age=39, Gender="М", Place="ЙОТК" }, new People { Price=500, Name="Евгений", Age=18, Gender="М", Place="Медведево" }, new People { Price=2500, Name="Давид", Age=18, Gender="М", Place="Ремзавод" }, }; } } } }