Imagara 2 vuotta sitten
vanhempi
commit
8823d7210c

+ 2 - 0
MyTests/MyTests.csproj

@@ -199,6 +199,8 @@
       <DependentUpon>EDM.edmx</DependentUpon>
       <LastGenOutput>EDM.cs</LastGenOutput>
     </Content>
+    <Resource Include="Resources\Approval.png" />
+    <Resource Include="Resources\Search.png" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>

+ 36 - 4
MyTests/Pages/TestsCatalog.xaml

@@ -18,6 +18,12 @@
                 Margin="5">
             <StackPanel Orientation="Horizontal"
                         HorizontalAlignment="Center">
+                <Button Height="45"
+                        Width="45"
+                        Content="+"
+                        FontSize="30"
+                        Click="AddTest_Click">
+                </Button>
                 <StackPanel Orientation="Horizontal"
                             Grid.Row="0"
                             HorizontalAlignment="Center">
@@ -35,9 +41,9 @@
                 </StackPanel>
                 <Button Height="45"
                         Width="45"
-                        Content="+"
-                        FontSize="30"
-                        Click="AddTest_Click">
+                        Click="FindTests_Click">
+                    <Image Source="/MyTests;component/Resources/search.png"
+                           Margin="10"/>
                 </Button>
             </StackPanel>
 
@@ -46,9 +52,35 @@
 
         <ListBox Name="TestsListBox"
                  Grid.Row="1"
-                 Background="{StaticResource color2}"
+                 Background="{StaticResource color1}"
                  BorderBrush="{Binding TestsListBox}">
             <ScrollViewer VerticalScrollBarVisibility="Visible"/>
+            <ListBox.ItemTemplate>
+                <DataTemplate>
+                    <Border Width="785"
+                            Height="45"
+                            CornerRadius="10"
+                          Background="{StaticResource color2}">
+                        <StackPanel Orientation="Horizontal">
+                            <Image Width="35"
+                               Height="35"
+                               Margin="5"
+                               HorizontalAlignment="Left"
+                               Source="/MyTests;component/Resources/approval.png">
+                            </Image>
+                            <StackPanel>
+                                <StackPanel Orientation="Horizontal">
+                                    <Label Content="Тестовый тест"/>
+                                    <Label Content="by ima"/>
+                                </StackPanel>
+                                <Label Content="Вопросов: 15"
+                                   Margin="0,-7,0,0">
+                                </Label>
+                            </StackPanel>
+                        </StackPanel>
+                    </Border>
+                </DataTemplate>
+            </ListBox.ItemTemplate>
         </ListBox>
     </Grid>
 </Page>

+ 14 - 3
MyTests/Pages/TestsCatalog.xaml.cs

@@ -23,7 +23,8 @@ namespace MyTests.Pages
         public TestsCatalog()
         {
             InitializeComponent();
-            LoadingTests();
+
+            //LoadingTests();
         }
 
         private void AddTest_Click(object sender, RoutedEventArgs e)
@@ -74,12 +75,17 @@ namespace MyTests.Pages
         void LoadingTests()
         {
             TestsListBox.Items.Clear();
-            foreach (Tests test in cnt.db.Tests.Where(item => item.IdUser == Session.userId).ToList())
+            var list = cnt.db.Tests.Where(item => item.IdUser == Session.userId).ToList();
+            if(TestNameBox.Text != "Название теста")
+                list = list.Where(item => item.Name == TestNameBox.Text).ToList();
+            if(AuthorTestBox.Text != "Автор")
+                list = list.Where(item => item.Users.Login == AuthorTestBox.Text).ToList();
+            foreach (Tests test in list)
             {
                 try
                 {
                     BitmapImage img = test.Image == null ?
-                        new BitmapImage(new Uri("../Resources/StandartProfile.png", UriKind.RelativeOrAbsolute)) :
+                        new BitmapImage(new Uri("../Resources/Approval.png", UriKind.RelativeOrAbsolute)) :
                         ImagesManip.NewImage(cnt.db.Users.Where(item => item.IdUser == Session.userId).FirstOrDefault());
                     AddTest(test.Name, img, cnt.db.Questions.Where(item => item.IdTest == test.IdTest).Count());
                 }
@@ -89,5 +95,10 @@ namespace MyTests.Pages
                 }
             }
         }
+
+        private void FindTests_Click(object sender, RoutedEventArgs e)
+        {
+            LoadingTests();
+        }
     }
 }

BIN
MyTests/Resources/Search.png


BIN
MyTests/Resources/approval.png