|
@@ -63,6 +63,7 @@ namespace WpfApp1.model
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
```
|
|
```
|
|
***
|
|
***
|
|
**Class3**
|
|
**Class3**
|
|
@@ -144,11 +145,21 @@ namespace WpfApp1.model
|
|
Click="ExitButton_Click"
|
|
Click="ExitButton_Click"
|
|
Height="50"/>
|
|
Height="50"/>
|
|
</StackPanel>
|
|
</StackPanel>
|
|
|
|
+
|
|
|
|
|
|
<WrapPanel
|
|
<WrapPanel
|
|
Orientation="Horizontal"
|
|
Orientation="Horizontal"
|
|
Grid.Column="1"
|
|
Grid.Column="1"
|
|
MinHeight="50">
|
|
MinHeight="50">
|
|
|
|
+ <Label
|
|
|
|
+ Content="Поиск"
|
|
|
|
+ VerticalAlignment="Center"/>
|
|
|
|
+ <TextBox
|
|
|
|
+ Width="200"
|
|
|
|
+ VerticalAlignment="Center"
|
|
|
|
+ x:Name="SearchFilterTextBox"
|
|
|
|
+ KeyUp="SearchFilter_KeyUp"/>
|
|
|
|
+
|
|
<Label
|
|
<Label
|
|
Content="Название:"
|
|
Content="Название:"
|
|
VerticalAlignment="Center"/>
|
|
VerticalAlignment="Center"/>
|
|
@@ -170,6 +181,7 @@ namespace WpfApp1.model
|
|
<Label
|
|
<Label
|
|
Content="Цена:"
|
|
Content="Цена:"
|
|
VerticalAlignment="Center"/>
|
|
VerticalAlignment="Center"/>
|
|
|
|
+
|
|
<ComboBox
|
|
<ComboBox
|
|
Name="carpriceFilterComboBox"
|
|
Name="carpriceFilterComboBox"
|
|
SelectionChanged="carpriceFilterComboBox_SelectionChanged"
|
|
SelectionChanged="carpriceFilterComboBox_SelectionChanged"
|
|
@@ -185,9 +197,26 @@ ItemsSource="{Binding CarpriceList}">
|
|
</DataTemplate>
|
|
</DataTemplate>
|
|
</ComboBox.ItemTemplate>
|
|
</ComboBox.ItemTemplate>
|
|
</ComboBox>
|
|
</ComboBox>
|
|
|
|
+ <Label
|
|
|
|
+ Content="Возраст:"
|
|
|
|
+ VerticalAlignment="Center"/>
|
|
|
|
+ <RadioButton
|
|
|
|
+ GroupName="Age"
|
|
|
|
+ Tag="1"
|
|
|
|
+ Content="по возрастанию"
|
|
|
|
+ IsChecked="True"
|
|
|
|
+ Checked="RadioButton_Checked"
|
|
|
|
+ VerticalAlignment="Center"/>
|
|
|
|
+ <RadioButton
|
|
|
|
+ GroupName="Age"
|
|
|
|
+ Tag="2"
|
|
|
|
+ Content="по убыванию"
|
|
|
|
+ Checked="RadioButton_Checked"
|
|
|
|
+ VerticalAlignment="Center"/>
|
|
</WrapPanel>
|
|
</WrapPanel>
|
|
</Grid>
|
|
</Grid>
|
|
</Window>
|
|
</Window>
|
|
|
|
+
|
|
```
|
|
```
|
|
***
|
|
***
|
|
**MainWindow.xaml.cs**
|
|
**MainWindow.xaml.cs**
|
|
@@ -196,6 +225,8 @@ ItemsSource="{Binding CarpriceList}">
|
|
using System;
|
|
using System;
|
|
using System.ComponentModel;
|
|
using System.ComponentModel;
|
|
using System.Windows;
|
|
using System.Windows;
|
|
|
|
+using System.Windows.Controls;
|
|
|
|
+using System.Windows.Input;
|
|
using WpfApp1.model;
|
|
using WpfApp1.model;
|
|
|
|
|
|
namespace WpfApp1
|
|
namespace WpfApp1
|
|
@@ -206,6 +237,21 @@ namespace WpfApp1
|
|
|
|
|
|
public partial class MainWindow : Window, INotifyPropertyChanged
|
|
public partial class MainWindow : Window, INotifyPropertyChanged
|
|
{
|
|
{
|
|
|
|
+ private string searchFilter = "";
|
|
|
|
+
|
|
|
|
+ private void SearchFilter_KeyUp(object sender, KeyEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ searchFilter = SearchFilterTextBox.Text;
|
|
|
|
+ Invalidate();
|
|
|
|
+ }
|
|
|
|
+ private bool sortAsc = true;
|
|
|
|
+
|
|
|
|
+ private void RadioButton_Checked(object sender, RoutedEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ sortAsc = (sender as RadioButton).Tag.ToString() == "1";
|
|
|
|
+ Invalidate();
|
|
|
|
+ }
|
|
|
|
+
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
private void Invalidate()
|
|
private void Invalidate()
|
|
{
|
|
{
|
|
@@ -220,9 +266,21 @@ namespace WpfApp1
|
|
{
|
|
{
|
|
get
|
|
get
|
|
{
|
|
{
|
|
- return _CarList
|
|
|
|
|
|
+ var res = _CarList;
|
|
|
|
+
|
|
|
|
+ res = res
|
|
.Where(c => (c.name == selectedname || selectedname == "Все автомобили"))
|
|
.Where(c => (c.name == selectedname || selectedname == "Все автомобили"))
|
|
.Where(c => (selectedprice == null || (c.price >= selectedprice.priceFrom && c.price < selectedprice.priceTo)));
|
|
.Where(c => (selectedprice == null || (c.price >= selectedprice.priceFrom && c.price < selectedprice.priceTo)));
|
|
|
|
+
|
|
|
|
+ if (searchFilter != "")
|
|
|
|
+ res = res.Where(c => c.name.IndexOf(
|
|
|
|
+ searchFilter,
|
|
|
|
+ StringComparison.OrdinalIgnoreCase) >= 0);
|
|
|
|
+ if (sortAsc) res = res.OrderBy(c => c.year);
|
|
|
|
+ else res = res.OrderByDescending(c => c.year);
|
|
|
|
+
|
|
|
|
+ return res;
|
|
|
|
+
|
|
}
|
|
}
|
|
set
|
|
set
|
|
{
|
|
{
|
|
@@ -407,10 +465,11 @@ namespace WpfApp1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
```
|
|
```
|
|
***
|
|
***
|
|
**Вот что получилось**
|
|
**Вот что получилось**
|
|
|
|
|
|
-![](./img/net.png)
|
|
|
|
-![](./img/net1.png)
|
|
|
|
-![](./img/net2.png)
|
|
|
|
|
|
+![](./img/net3.png)
|
|
|
|
+![](./img/net4.png)
|