Quellcode durchsuchen

Small save
Started working with tests

Imagara vor 3 Jahren
Ursprung
Commit
6120905204

+ 3 - 2
MyTests/MainWindow.xaml

@@ -19,7 +19,7 @@
                 MouseDown="Border_MouseDown" 
                 Grid.Row="0">
             <Grid HorizontalAlignment="Stretch">
-                <Label Content="PartsWarehouse"
+                <Label Content="MyTests"
                        Foreground="Gray"
                        FontWeight="SemiBold"/>
 
@@ -81,7 +81,8 @@
                 </Button>
             </StackPanel>
             <Frame Name="MainFrame" 
-                   Grid.Column="1">
+                   Grid.Column="1"
+                   NavigationUIVisibility="Hidden">
             </Frame>
         </Grid>
     </Grid>

+ 1 - 1
MyTests/MainWindow.xaml.cs

@@ -57,7 +57,7 @@ namespace MyTests
 
         private void TestsCatalogClick(object sender, RoutedEventArgs e)
         {
-            //MainFrame.Content = new СatalogPage();
+            MainFrame.Content = new Pages.TestsCatalog();
         }
         private void CreateTestClick(object sender, RoutedEventArgs e)
         {

+ 14 - 0
MyTests/MyTests.csproj

@@ -85,6 +85,12 @@
     <Compile Include="Pages\ProfilePage.xaml.cs">
       <DependentUpon>ProfilePage.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Pages\TestPage.xaml.cs">
+      <DependentUpon>TestPage.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Pages\TestsCatalog.xaml.cs">
+      <DependentUpon>TestsCatalog.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Questions.cs">
       <DependentUpon>EDM.tt</DependentUpon>
     </Compile>
@@ -129,6 +135,14 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Pages\TestPage.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Pages\TestsCatalog.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Styles\Style.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 0 - 1
MyTests/Pages/ProfilePage.xaml

@@ -28,7 +28,6 @@
                    Grid.Column="0"
                    Margin="10"
                    Source="/MyTests;component/Resources/StandartImage.png">
-                   <!--MouseDown="Img_MouseDown"-->
             </Image>
 
             <Grid Grid.Column="1"

+ 13 - 0
MyTests/Pages/TestPage.xaml

@@ -0,0 +1,13 @@
+<Page x:Class="MyTests.Pages.TestPage"
+      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+      xmlns:local="clr-namespace:MyTests.Pages"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" 
+      d:DesignWidth="800">
+    <Grid Background="{StaticResource color1}">
+        
+    </Grid>
+</Page>

+ 28 - 0
MyTests/Pages/TestPage.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+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;
+
+namespace MyTests.Pages
+{
+    /// <summary>
+    /// Логика взаимодействия для TestPage.xaml
+    /// </summary>
+    public partial class TestPage : Page
+    {
+        public TestPage()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 54 - 0
MyTests/Pages/TestsCatalog.xaml

@@ -0,0 +1,54 @@
+<Page x:Class="MyTests.Pages.TestsCatalog"
+      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+      xmlns:local="clr-namespace:MyTests.Pages"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" 
+      d:DesignWidth="800">
+    <Grid Background="{StaticResource color1}">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="32*"/>
+            <RowDefinition Height="193*"/>
+        </Grid.RowDefinitions>
+
+        <Border CornerRadius="15" 
+                Background="{StaticResource color2}" 
+                Margin="5">
+            <StackPanel Orientation="Horizontal"
+                        HorizontalAlignment="Center">
+                <StackPanel Orientation="Horizontal"
+                            Grid.Row="0"
+                            HorizontalAlignment="Center">
+                    <TextBox Name="TestNameBox"
+                             Margin="5"
+                             Width="200"
+                             Text="Название теста">
+                    </TextBox>
+
+                    <TextBox Name="AuthorTestBox"
+                             Margin="5"
+                             Width="200"
+                             Text="Автор">
+                    </TextBox>
+                </StackPanel>
+                <Button Height="45"
+                        Width="45"
+                        Content="+"
+                        FontSize="30"
+                        Click="AddTest_Click">
+                </Button>
+            </StackPanel>
+
+
+        </Border>
+
+        <ListBox Name="TestsListBox"
+                 Grid.Row="1"
+                 Background="{StaticResource color2}"
+                 BorderBrush="{Binding TestsListBox}">
+            <ScrollViewer VerticalScrollBarVisibility="Visible"/>
+        </ListBox>
+    </Grid>
+</Page>

+ 93 - 0
MyTests/Pages/TestsCatalog.xaml.cs

@@ -0,0 +1,93 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+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;
+
+namespace MyTests.Pages
+{
+    /// <summary>
+    /// Логика взаимодействия для TestsCatalog.xaml
+    /// </summary>
+    public partial class TestsCatalog : Page
+    {
+        public TestsCatalog()
+        {
+            InitializeComponent();
+            LoadingTests();
+        }
+
+        private void AddTest_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+        private void AddTest(string author, BitmapImage imageSource, int test)
+        {
+            Grid testGrid = new Grid
+            {
+                Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x40, 0x44, 0x4B)),
+                Height = 45,
+                Width = 590,
+                Margin = new Thickness(10, 5, 10, 5)
+            };
+
+            Image testImage = new Image
+            {
+                Source = imageSource,
+                Width = 35,
+                Height = 35,
+                Margin = new Thickness(5),
+                HorizontalAlignment = HorizontalAlignment.Left
+            };
+
+            testGrid.Children.Add(testImage);
+
+            Label authorLabel = new Label();
+            authorLabel.Content = author;
+            authorLabel.Foreground = Brushes.White;
+            authorLabel.FontWeight = FontWeights.Bold;
+            authorLabel.HorizontalAlignment = HorizontalAlignment.Left;
+            authorLabel.VerticalAlignment = VerticalAlignment.Top;
+            authorLabel.Margin = new Thickness(40, 0, 0, 0);
+
+            testGrid.Children.Add(authorLabel);
+
+            Label testLabel = new Label();
+            testLabel.Content = test;
+            testLabel.Foreground = Brushes.White;
+            testLabel.HorizontalAlignment = HorizontalAlignment.Left;
+            testLabel.VerticalAlignment = VerticalAlignment.Bottom;
+            testLabel.Margin = new Thickness(40, 0, 0, 0);
+            testGrid.Children.Add(testLabel);
+
+            TestsListBox.Items.Add(testGrid);
+        }
+        void LoadingTests()
+        {
+            TestsListBox.Items.Clear();
+            foreach (Tests test in cnt.db.Tests.Where(item => item.IdUser == Session.userId).ToList())
+            {
+                try
+                {
+                    BitmapImage img = test.Image == null ?
+                        new BitmapImage(new Uri("../Resources/StandartProfile.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());
+                }
+                catch (Exception ex)
+                {
+                    new ErrorWindow(ex.ToString()).ShowDialog();
+                }
+            }
+        }
+    }
+}