123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- 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<People> _PeopleList;
- public IEnumerable<People> 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<PeopleGender> PeopleGenderList { get; set; }
- public List<PeopleAge> PeopleAgeList { get; set; }
- public List<PeoplePlace> 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<PeopleGender> getGender()
- {
- return new PeopleGender[]
- {
- new PeopleGender()
- {
- title="Ж"
- },
- new PeopleGender()
- {
- title="М"
- }
- };
- }
- public IEnumerable<PeopleAge> 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<PeoplePlace> 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<People> 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="Ремзавод"
- },
- };
- }
- }
- }
- }
|