Valera před 7 měsíci
rodič
revize
14e8a79081
3 změnil soubory, kde provedl 63 přidání a 4 odebrání
  1. binární
      img/net3.png
  2. binární
      img/net4.png
  3. 63 4
      readme.md

binární
img/net3.png


binární
img/net4.png


+ 63 - 4
readme.md

@@ -63,6 +63,7 @@ namespace WpfApp1.model
         }
     }
 }
+
 ```
 ***
 **Class3**
@@ -144,11 +145,21 @@ namespace WpfApp1.model
             Click="ExitButton_Click"
             Height="50"/>
         </StackPanel>
+        
 
         <WrapPanel
         Orientation="Horizontal"
         Grid.Column="1"
         MinHeight="50">
+            <Label 
+    Content="Поиск" 
+    VerticalAlignment="Center"/>
+            <TextBox
+    Width="200"
+    VerticalAlignment="Center"
+    x:Name="SearchFilterTextBox" 
+    KeyUp="SearchFilter_KeyUp"/>
+            
             <Label 
     Content="Название:"
     VerticalAlignment="Center"/>
@@ -170,6 +181,7 @@ namespace WpfApp1.model
             <Label 
 Content="Цена:"
 VerticalAlignment="Center"/>
+            
             <ComboBox
 Name="carpriceFilterComboBox"
 SelectionChanged="carpriceFilterComboBox_SelectionChanged"
@@ -185,9 +197,26 @@ ItemsSource="{Binding CarpriceList}">
                     </DataTemplate>
                 </ComboBox.ItemTemplate>
             </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>
     </Grid>
 </Window>
+
 ```
 ***
 **MainWindow.xaml.cs**
@@ -196,6 +225,8 @@ ItemsSource="{Binding CarpriceList}">
 using System;
 using System.ComponentModel;
 using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
 using WpfApp1.model;
 
 namespace WpfApp1
@@ -206,6 +237,21 @@ namespace WpfApp1
 
     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;
         private void Invalidate()
         {
@@ -220,9 +266,21 @@ namespace WpfApp1
         {
             get
             {
-                return _CarList
+                var res = _CarList;
+
+                res = res
                     .Where(c => (c.name == selectedname || selectedname == "Все автомобили"))
                     .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
             {
@@ -407,10 +465,11 @@ namespace WpfApp1
         }
     }
 }
+
+
 ```
 ***
 **Вот что получилось**
 
-![](./img/net.png)
-![](./img/net1.png)
-![](./img/net2.png)
+![](./img/net3.png)
+![](./img/net4.png)