Selaa lähdekoodia

Переделочка

Imagara 2 vuotta sitten
vanhempi
commit
14d875793d

+ 1 - 1
MyTests/App.xaml

@@ -2,7 +2,7 @@
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:local="clr-namespace:MyTests"
-             StartupUri="RegAuth.xaml">
+             StartupUri="MainWindow.xaml">
 
     <Application.Resources>
         <ResourceDictionary Source="Styles/Style.xaml"/>

+ 0 - 16
MyTests/Authorization.xaml

@@ -1,16 +0,0 @@
-<Page x:Class="MyTests.Authorization"
-      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"
-      mc:Ignorable="d" 
-      d:DesignHeight="450" d:DesignWidth="800"
-      Height="475" Width="475">
-    <Grid Background="#2F3136">
-        <Button Content="Войти" Margin="0,250,15,0" VerticalAlignment="Top" Width="93" Click="Auth" Height="26" FontSize="18"/>
-        <TextBox x:Name="Login" LostFocus="LostLogin" GotFocus="LoginFocus" Margin="0,150,15,0" TextWrapping="Wrap" Text ="Логин" VerticalAlignment="Top" Width="145" Height="25" FontSize="16" />
-        <PasswordBox x:Name="Password" LostFocus="LostPassword" GotFocus="PasswordFocus" Margin="0,210,15,0" Password ="Password" VerticalAlignment="Top" Width="126"/>
-    </Grid>
-</Page>
- 

+ 0 - 92
MyTests/Authorization.xaml.cs

@@ -1,92 +0,0 @@
-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
-{
-    public partial class Authorization : Page
-    {
-        public Authorization()
-        {
-            InitializeComponent();
-        }
-
-        private void Auth(object sender, RoutedEventArgs e)
-        {
-            if (!emptiness(Login.Text, Password.Password))
-                MessageBox.Show("Поля не могут быть пустыми.");
-            else if (cnt.db.Users.Select(item => item.Login + item.Password).Contains(Login.Text + Password.Password))
-            {
-                Session.User = cnt.db.Users.First(item => item.Login == Login.Text);
-                MainWindow RegAuth = new MainWindow();
-                RegAuth.Show();
-                var windows = Application.Current.Windows;
-                for (int i = windows.Count - 1; i >= 0; i--)
-                {
-                    if (windows[i].ToString() == "MyTests.RegAuth")
-                        windows[i].Close();
-                }
-            }
-            else
-                MessageBox.Show("Неверный логин или пароль");
-        }
-
-        private void LoginFocus(object sender, RoutedEventArgs e)
-        {
-            Login.Text = "";
-        }
-
-        private void LostLogin(object sender, RoutedEventArgs e)
-        {
-            if (Login.Text.Trim() == "")
-                Login.Text = "Логин";
-        }
-
-        private void PasswordFocus(object sender, RoutedEventArgs e)
-        {
-            Password.Password = "";
-        }
-
-        private void LostPassword(object sender, RoutedEventArgs e)
-        {
-            if(Password.Password.Trim() == "")
-            Password.Password = "123456";
-        }
-
-        public bool emptiness(string login, string password) //Проверка на пустоту
-        {
-            if (login == "" || password == "")
-                return false;
-            else
-                return true;
-        }
-
-        public bool LoginTestEptiness(string login) //Проверка на пустоту
-        {
-            if (login == "")
-                return false;
-            else
-                return true;
-        }
-
-        public bool PasswordTestEptiness(string password) //Проверка на пустоту
-        {
-            if (password == "")
-                return false;
-            else
-                return true;
-        }
-    }
-}

+ 5 - 3
MyTests/EDM.edmx

@@ -4,7 +4,7 @@
   <edmx:Runtime>
     <!-- SSDL content -->
     <edmx:StorageModels>
-      <Schema Namespace="Хранилище MyTestsDataBaseModel" Provider="System.Data.SqlClient" ProviderManifestToken="2012" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
+    <Schema Namespace="Хранилище MyTestsDataBaseModel" Provider="System.Data.SqlClient" ProviderManifestToken="2012" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
         <EntityType Name="Answers">
           <Key>
             <PropertyRef Name="IdUserAnswer" />
@@ -42,6 +42,7 @@
           <Property Name="Email" Type="nvarchar" MaxLength="50" Nullable="false" />
           <Property Name="Info" Type="nvarchar" MaxLength="50" />
           <Property Name="Image" Type="varbinary(max)" />
+          <Property Name="Post" Type="nvarchar" MaxLength="10" />
         </EntityType>
         <Association Name="FK_Answers_Questions">
           <End Role="Questions" Type="Self.Questions" Multiplicity="1" />
@@ -113,8 +114,7 @@
             <End Role="Tests" EntitySet="Tests" />
           </AssociationSet>
         </EntityContainer>
-      </Schema>
-    </edmx:StorageModels>
+      </Schema></edmx:StorageModels>
     <!-- CSDL content -->
     <edmx:ConceptualModels>
       <Schema Namespace="MyTestsDataBaseModel" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
@@ -163,6 +163,7 @@
           <Property Name="Image" Type="Binary" MaxLength="Max" FixedLength="false" />
           <NavigationProperty Name="Answers" Relationship="Self.FK_Answers_Users" FromRole="Users" ToRole="Answers" />
           <NavigationProperty Name="Tests" Relationship="Self.FK_Tests_Users" FromRole="Users" ToRole="Tests" />
+          <Property Name="Post" Type="String" MaxLength="10" FixedLength="false" Unicode="true" />
         </EntityType>
         <Association Name="FK_Answers_Questions">
           <End Role="Questions" Type="Self.Questions" Multiplicity="1" />
@@ -273,6 +274,7 @@
           <EntitySetMapping Name="Users">
             <EntityTypeMapping TypeName="MyTestsDataBaseModel.Users">
               <MappingFragment StoreEntitySet="Users">
+                <ScalarProperty Name="Post" ColumnName="Post" />
                 <ScalarProperty Name="IdUser" ColumnName="IdUser" />
                 <ScalarProperty Name="Login" ColumnName="Login" />
                 <ScalarProperty Name="Password" ColumnName="Password" />

+ 4 - 4
MyTests/EDM.edmx.diagram

@@ -5,10 +5,10 @@
     <!-- Diagram content (shape and connector positions) -->
     <edmx:Diagrams>
       <Diagram DiagramId="d43acb8abf174d81b935ee8c6a0e239d" Name="Diagram1">
-        <EntityTypeShape EntityType="MyTestsDataBaseModel.Answers" Width="1.5" PointX="7.5" PointY="3.875" IsExpanded="true" />
-        <EntityTypeShape EntityType="MyTestsDataBaseModel.Questions" Width="1.5" PointX="5.25" PointY="5.5" IsExpanded="true" />
-        <EntityTypeShape EntityType="MyTestsDataBaseModel.Tests" Width="1.5" PointX="3" PointY="5.5" IsExpanded="true" />
-        <EntityTypeShape EntityType="MyTestsDataBaseModel.Users" Width="1.5" PointX="0.75" PointY="2.375" IsExpanded="true" />
+        <EntityTypeShape EntityType="MyTestsDataBaseModel.Answers" Width="1.5" PointX="5.625" PointY="2.5" IsExpanded="true" />
+        <EntityTypeShape EntityType="MyTestsDataBaseModel.Questions" Width="1.5" PointX="5.625" PointY="5.875" IsExpanded="true" />
+        <EntityTypeShape EntityType="MyTestsDataBaseModel.Tests" Width="1.5" PointX="2.875" PointY="5.5" IsExpanded="true" />
+        <EntityTypeShape EntityType="MyTestsDataBaseModel.Users" Width="1.5" PointX="2.625" PointY="2.125" IsExpanded="true" />
         <AssociationConnector Association="MyTestsDataBaseModel.FK_Answers_Questions" ManuallyRouted="false" />
         <AssociationConnector Association="MyTestsDataBaseModel.FK_Answers_Users" ManuallyRouted="false" />
         <AssociationConnector Association="MyTestsDataBaseModel.FK_Questions_Tests" ManuallyRouted="false" />

+ 5 - 31
MyTests/MainWindow.xaml

@@ -35,7 +35,7 @@
                             FontWeight="Bold" 
                             Click="ButtonMininize_Click"/>
 
-                    <Button Visibility="Visible"
+                    <Button Visibility="Collapsed"
                             Width="20" Height="20"
                             Content="☐"
                             Background="Transparent"
@@ -56,35 +56,9 @@
                 </StackPanel>
             </Grid>
         </Border>
-        <Grid Grid.Row="1">
-            <Grid.ColumnDefinitions>
-                <ColumnDefinition Width="124"/>
-                <ColumnDefinition/>
-            </Grid.ColumnDefinitions>
-
-            <StackPanel Background="{StaticResource color2}" 
-                    Grid.Column="0">
-                <Button Height="30"
-                    Margin="5"
-                    Content="Создать тест"
-                    Click="CreateTestClick">
-                </Button>
-                <Button Height="30"
-                    Margin="5"
-                    Content="Тесты"
-                    Click="TestsCatalogClick">
-
-                </Button>
-                <Button Height="30"
-                    Margin="5"
-                    Content="Профиль"
-                    Click="ProfileClick">
-                </Button>
-            </StackPanel>
-            <Frame Name="MainFrame" 
-                   Grid.Column="1"
-                   NavigationUIVisibility="Hidden">
-            </Frame>
-        </Grid>
+        <Frame Name="MainFrame" 
+               Grid.Row="1"
+               NavigationUIVisibility="Hidden">
+        </Frame>
     </Grid>
 </Window>

+ 3 - 22
MyTests/MainWindow.xaml.cs

@@ -15,17 +15,15 @@ using System.Windows.Shapes;
 
 namespace MyTests
 {
-    /// <summary>
-    /// Логика взаимодействия для MainWindow.xaml
-    /// </summary>
     public partial class MainWindow : Window
     {
         public MainWindow()
         {
             InitializeComponent();
-            MainFrame.Content = new Pages.TestsCatalog();
+            MainFrame.Content = new Pages.LoginPage();
         }
 
+        #region Menu Bar
         private void Border_MouseDown(object sender, MouseButtonEventArgs e)
         {
             if (e.LeftButton == MouseButtonState.Pressed)
@@ -49,24 +47,7 @@ namespace MyTests
         {
             Application.Current.Shutdown();
         }
+        #endregion
 
-        private void ProfileClick(object sender, RoutedEventArgs e)
-        {
-            MainFrame.Content = new Pages.ProfilePage(Session.User);
-        }
-
-        private void TestsCatalogClick(object sender, RoutedEventArgs e)
-        {
-            MainFrame.Content = new Pages.TestsCatalog();
-        }
-        private void CreateTestClick(object sender, RoutedEventArgs e)
-        {
-            //MainFrame.Content = new СatalogPage();
-        }
-
-        private void XEXE_TextChanged(object sender, TextChangedEventArgs e)
-        {
-
-        }
     }
 }

+ 21 - 21
MyTests/MyTests.csproj

@@ -67,9 +67,6 @@
     <Compile Include="Answers.cs">
       <DependentUpon>EDM.tt</DependentUpon>
     </Compile>
-    <Compile Include="Authorization.xaml.cs">
-      <DependentUpon>Authorization.xaml</DependentUpon>
-    </Compile>
     <Compile Include="EDM.Context.cs">
       <AutoGen>True</AutoGen>
       <DesignTime>True</DesignTime>
@@ -88,9 +85,18 @@
     <Compile Include="Pages\CurTestPage.xaml.cs">
       <DependentUpon>CurTestPage.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Pages\MainPage.xaml.cs">
+      <DependentUpon>MainPage.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Pages\ProfilePage.xaml.cs">
       <DependentUpon>ProfilePage.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Pages\LoginPage.xaml.cs">
+      <DependentUpon>LoginPage.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Pages\RegistrationPage.xaml.cs">
+      <DependentUpon>RegistrationPage.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Pages\ResultTestPage.xaml.cs">
       <DependentUpon>ResultTestPage.xaml</DependentUpon>
     </Compile>
@@ -103,12 +109,6 @@
     <Compile Include="Questions.cs">
       <DependentUpon>EDM.tt</DependentUpon>
     </Compile>
-    <Compile Include="RegAuth.xaml.cs">
-      <DependentUpon>RegAuth.xaml</DependentUpon>
-    </Compile>
-    <Compile Include="Registration.xaml.cs">
-      <DependentUpon>Registration.xaml</DependentUpon>
-    </Compile>
     <Compile Include="Session.cs" />
     <Compile Include="Styles\Style.cs" />
     <Compile Include="Tests.cs">
@@ -117,10 +117,6 @@
     <Compile Include="Users.cs">
       <DependentUpon>EDM.tt</DependentUpon>
     </Compile>
-    <Page Include="Authorization.xaml">
-      <Generator>MSBuild:Compile</Generator>
-      <SubType>Designer</SubType>
-    </Page>
     <Page Include="ConfirmationWindow.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -154,29 +150,33 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Pages\ProfilePage.xaml">
+    <Page Include="Pages\MainPage.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Pages\ResultTestPage.xaml">
+    <Page Include="Pages\ProfilePage.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Pages\TestPage.xaml">
-      <SubType>Designer</SubType>
+    <Page Include="Pages\LoginPage.xaml">
       <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
     </Page>
-    <Page Include="Pages\TestsCatalog.xaml">
+    <Page Include="Pages\RegistrationPage.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="RegAuth.xaml">
-      <Generator>MSBuild:Compile</Generator>
+    <Page Include="Pages\ResultTestPage.xaml">
       <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Registration.xaml">
+    <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>

+ 74 - 0
MyTests/Pages/LoginPage.xaml

@@ -0,0 +1,74 @@
+<Page x:Class="MyTests.Pages.LoginPage"
+      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.ColumnDefinitions>
+            <ColumnDefinition/>
+            <ColumnDefinition Width="2*"/>
+            <ColumnDefinition/>
+        </Grid.ColumnDefinitions>
+        <Grid.RowDefinitions>
+            <RowDefinition/>
+            <RowDefinition Height="2.75*"/>
+            <RowDefinition/>
+        </Grid.RowDefinitions>
+        <Border Grid.Row="1" 
+                Grid.Column="1"
+                BorderBrush="Black"
+                BorderThickness="1.5"
+                CornerRadius="15"
+                Background="{StaticResource color2}">
+            <StackPanel Orientation="Vertical"
+                        Margin="10"
+                        VerticalAlignment="Center"
+                        HorizontalAlignment="Center">
+                <Label Content="Логин:" 
+                       Foreground="{StaticResource TextColor}"
+                       Height="40" 
+                       Width="240"
+                       FontSize="20"/>
+                <TextBox Name="LogBox" 
+                             Foreground="{StaticResource TextColor}"
+                             TextWrapping="Wrap" 
+                             VerticalAlignment="Top" 
+                             Height="40" 
+                             Width="240"
+                             FontSize="20"/>
+                <Label Content="Пароль:"
+                           Foreground="{StaticResource TextColor}"
+                           Height="40" 
+                           Width="240"
+                           FontSize="20"/>
+                <PasswordBox Name="PassBox"
+                                 Foreground="{StaticResource TextColor}"
+                                 Height="40" 
+                                 Width="240"
+                                 FontSize="20"/>
+                <StackPanel Orientation="Horizontal"
+                                Margin="0,20,0,0">
+                    <Button Name="RegButton" 
+                                Content="Регистрация"
+                                Height="40" 
+                                Width="150" 
+                                Margin="0,0,30,0"
+                                FontSize="20"
+                                Click="RegButton_Click"/>
+                    <Button x:Name="LogButton" 
+                                Content="Вход"
+                                Height="40" 
+                                Width="150"
+                                FontSize="20"
+                                IsDefault="True"
+                                Click="LogButton_Click">
+                    </Button>
+                </StackPanel>
+            </StackPanel>
+        </Border>
+    </Grid>
+</Page>

+ 58 - 0
MyTests/Pages/LoginPage.xaml.cs

@@ -0,0 +1,58 @@
+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>
+    /// Логика взаимодействия для RegistrationPage.xaml
+    /// </summary>
+    public partial class LoginPage : Page
+    {
+        bool Test = true;
+        public LoginPage()
+        {
+            InitializeComponent();
+        }
+        private void RegButton_Click(object sender, RoutedEventArgs e)
+        {
+            NavigationService.Navigate(new Pages.RegistrationPage());
+        }
+
+        private void LogButton_Click(object sender, RoutedEventArgs e)
+        {
+            if (Test)
+                NavigationService.Navigate(new Pages.MainPage());
+            else
+            {
+                try
+                {
+                    if (!Functions.IsValidLogAndPass(LogBox.Text, PassBox.Password))
+                        new ErrorWindow("Поля не могут быть пустыми").Show();
+                    else if (!Functions.LoginCheck(LogBox.Text, PassBox.Password))
+                        new ErrorWindow("Неверный логин или пароль").Show();
+                    else
+                    {
+                        //Profile.userId = cnt.db.User.Where(item => item.NickName == LogBox.Text).Select(item => item.Id).FirstOrDefault();
+                        NavigationService.Navigate(new Pages.MainPage());
+                    }
+                }
+                catch
+                {
+                    new ErrorWindow("Ошибка входа").ShowDialog();
+                }
+            }
+        }
+    }
+}

+ 40 - 0
MyTests/Pages/MainPage.xaml

@@ -0,0 +1,40 @@
+<Page x:Class="MyTests.Pages.MainPage"
+      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"
+      Height="450" Width="800">
+    <Grid Background="{StaticResource color1}">
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="124"/>
+            <ColumnDefinition/>
+        </Grid.ColumnDefinitions>
+
+        <StackPanel Background="{StaticResource color2}" 
+                    Grid.Column="0">
+            <Button Name="CreateTest"
+                    Height="30"
+                    Margin="5"
+                    Content="Создать тест"
+                    Click="CreateTestClick">
+            </Button>
+            <Button Height="30"
+                    Margin="5"
+                    Content="Тесты"
+                    Click="TestsCatalogClick">
+            </Button>
+            <Button Height="30"
+                    Margin="5"
+                    Content="Профиль"
+                    Click="ProfileClick">
+            </Button>
+        </StackPanel>
+        <Frame Name="MainContentFrame" 
+                   Grid.Column="1"
+                   NavigationUIVisibility="Hidden">
+        </Frame>
+    </Grid>
+</Page>

+ 41 - 0
MyTests/Pages/MainPage.xaml.cs

@@ -0,0 +1,41 @@
+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>
+    /// Логика взаимодействия для MainPage.xaml
+    /// </summary>
+    public partial class MainPage : Page
+    {
+        public MainPage()
+        {
+            InitializeComponent();
+        }
+        private void ProfileClick(object sender, RoutedEventArgs e)
+        {
+            MainContentFrame.Content = new Pages.ProfilePage(Session.User);
+        }
+
+        private void TestsCatalogClick(object sender, RoutedEventArgs e)
+        {
+            MainContentFrame.Content = new Pages.TestsCatalog();
+        }
+        private void CreateTestClick(object sender, RoutedEventArgs e)
+        {
+            //MainContentFrame.Content = new СatalogPage();
+        }
+    }
+}

+ 15 - 12
MyTests/Pages/ProfilePage.xaml.cs

@@ -13,20 +13,23 @@ namespace MyTests.Pages
         public ProfilePage(Users _user)
         {
             InitializeComponent();
-            user = _user;
-            UserName.Content = user.Login;
-            if (user.Image == null)
-                ProfileImage.Source = new BitmapImage(new Uri("../Resources/StandartImage.png", UriKind.RelativeOrAbsolute));
-            else
-                ProfileImage.Source = ImagesManip.NewImage(user);
-            EmailBox.Text = user.Email;
-            InfoBox.Text = user.Info;
-            if (user != Session.User)
+            if(_user != null)
             {
-                EmailBox.IsEnabled = false;
-                InfoBox.IsEnabled = false;
+                user = _user;
+                UserName.Content = user.Login;
+                if (user.Image == null)
+                    ProfileImage.Source = new BitmapImage(new Uri("../Resources/StandartImage.png", UriKind.RelativeOrAbsolute));
+                else
+                    ProfileImage.Source = ImagesManip.NewImage(user);
+                EmailBox.Text = user.Email;
+                InfoBox.Text = user.Info;
+                if (user != Session.User)
+                {
+                    EmailBox.IsEnabled = false;
+                    InfoBox.IsEnabled = false;
+                }
+                TestsLoading();
             }
-            TestsLoading();
         }
         private void EditImage_Click(object sender, RoutedEventArgs e)
         {

+ 72 - 0
MyTests/Pages/RegistrationPage.xaml

@@ -0,0 +1,72 @@
+<Page x:Class="MyTests.Pages.RegistrationPage"
+      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.ColumnDefinitions>
+            <ColumnDefinition/>
+            <ColumnDefinition Width="2*"/>
+            <ColumnDefinition/>
+        </Grid.ColumnDefinitions>
+        <Grid.RowDefinitions>
+            <RowDefinition/>
+            <RowDefinition Height="2.75*"/>
+            <RowDefinition/>
+        </Grid.RowDefinitions>
+        <Border Grid.Row="1" 
+                Grid.Column="1"
+                BorderBrush="Black"
+                BorderThickness="1.5"
+                CornerRadius="15"
+                Background="{StaticResource color2}">
+            <StackPanel Orientation="Vertical"
+                        Margin="10"
+                        VerticalAlignment="Center"
+                        HorizontalAlignment="Center">
+                <Label Content="Логин:" 
+                       Foreground="{StaticResource TextColor}"
+                       Height="40" 
+                       Width="240"
+                       FontSize="20"/>
+                <TextBox Name="LogBox" 
+                             Foreground="{StaticResource TextColor}"
+                             TextWrapping="Wrap" 
+                             VerticalAlignment="Top" 
+                             Height="40" 
+                             Width="240"
+                             FontSize="20"/>
+                <Label Content="Пароль:"
+                           Foreground="{StaticResource TextColor}"
+                           Height="40" 
+                           Width="240"
+                           FontSize="20"/>
+                <PasswordBox Name="PassBox"
+                                 Foreground="{StaticResource TextColor}"
+                                 Height="40" 
+                                 Width="240"
+                                 FontSize="20"/>
+                <StackPanel Orientation="Horizontal"
+                                Margin="0,20,0,0">
+                    <Button Content="Регистрация"
+                                Height="40" 
+                                Width="150" 
+                                Margin="0,0,30,0"
+                                FontSize="20"
+                                Click="BackButton_Click"/>
+                    <Button Content="Вход"
+                                Height="40" 
+                                Width="150"
+                                FontSize="20"
+                                IsDefault="True"
+                                Click="RegButton_Click">
+                    </Button>
+                </StackPanel>
+            </StackPanel>
+        </Border>
+    </Grid>
+</Page>

+ 39 - 0
MyTests/Pages/RegistrationPage.xaml.cs

@@ -0,0 +1,39 @@
+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>
+    /// Логика взаимодействия для RegistrationPage.xaml
+    /// </summary>
+    public partial class RegistrationPage : Page
+    {
+        bool Test = true;
+        public RegistrationPage()
+        {
+            InitializeComponent();
+        }
+        private void RegButton_Click(object sender, RoutedEventArgs e)
+        {
+            //Регистрая тут
+            NavigationService.Navigate(new Pages.LoginPage());
+        }
+
+        private void BackButton_Click(object sender, RoutedEventArgs e)
+        {
+            NavigationService.Navigate(new Pages.LoginPage());
+        }
+    }
+}

+ 2 - 2
MyTests/Pages/TestsCatalog.xaml.cs

@@ -20,6 +20,7 @@ namespace MyTests.Pages
         public TestsCatalog()
         {
             InitializeComponent();
+            TestsListBox.Items.Clear();
             LoadingTests();
         }
 
@@ -28,8 +29,7 @@ namespace MyTests.Pages
 
         }
         void LoadingTests()
-        {
-            TestsListBox.Items.Clear();
+        {            
             var list = cnt.db.Tests.ToList();
             if (TestNameBox.Text != "Название теста")
                 list = list.Where(item => item.Name == TestNameBox.Text).ToList();

+ 0 - 25
MyTests/RegAuth.xaml

@@ -1,25 +0,0 @@
-<Window x:Class="MyTests.RegAuth"
-        ResizeMode="NoResize" WindowStyle="SingleBorderWindow"
-        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-        xmlns:local="clr-namespace:MyTests"
-        mc:Ignorable="d"
-        Title="RegAuth" Height="475" Width="475">
-    <Grid Background="#2F3136">
-        <Grid.RowDefinitions>
-            <RowDefinition Height="50*"/>
-            <RowDefinition Height="25*"/>
-        </Grid.RowDefinitions>
-        <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
-            <Button Content="Регистрация" Width="140" Height="75" FontSize="20" Margin="40, 0, 40, 0" Click="WindowRegistration"></Button>
-            <Button Content="Вход"  Width="140" Height="75" FontSize="25" Margin="40, 0, 40, 0" Click="WindowEntry"></Button>
-        </StackPanel>
-        <Frame
-            Name="MainFrame"
-            NavigationUIVisibility="Hidden"
-            Grid.Row="0">
-        </Frame>
-    </Grid>
-</Window>

+ 0 - 32
MyTests/RegAuth.xaml.cs

@@ -1,32 +0,0 @@
-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.Imaging;
-using System.Windows.Shapes;
-
-namespace MyTests
-{
-    public partial class RegAuth : Window
-    {
-        public RegAuth()
-        {
-            InitializeComponent();
-        }
-
-        private void WindowRegistration(object sender, RoutedEventArgs e) //Регистрация
-        {
-            MainFrame.Content = new Registration();
-        }
-        private void WindowEntry(object sender, RoutedEventArgs e) //Авторизация
-        {
-            MainFrame.Content = new Authorization();
-        }
-    }
-}

+ 0 - 18
MyTests/Registration.xaml

@@ -1,18 +0,0 @@
-<Page x:Class="MyTests.Registration"
-      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"
-      mc:Ignorable="d" 
-      d:DesignHeight="450" d:DesignWidth="800"
-      Title="Registration" Height="475" Width="475">
-
-    <Grid Background="#2F3136">
-        <TextBox x:Name="Login" LostFocus="LoginLostFocus" GotFocus="LoginFocus" HorizontalAlignment="Center" Height="30" Margin="174,19,175,0" TextWrapping="Wrap" Text="Логин" VerticalAlignment="Top" Width="126" TextAlignment="Center" FontSize="14"/>
-        <TextBox x:Name="Password" LostFocus="PasswordLostFocus" GotFocus="PasswordFocus" HorizontalAlignment="Center" Height="30" Margin="174,72,175,0" TextWrapping="Wrap" Text="Пароль" VerticalAlignment="Top" Width="126" TextAlignment="Center" FontSize="14"/>
-        <TextBox x:Name="Email" LostFocus="EmailLostFocus" GotFocus="EmailNameFocus" HorizontalAlignment="Center" Height="30" Margin="174,122,175,0" TextWrapping="Wrap" Text="Почта" VerticalAlignment="Top" Width="126" TextAlignment="Center" FontSize="14"/>
-        <TextBox x:Name="Info" LostFocus="InfoLostFocus" GotFocus="InfoNameFocus" HorizontalAlignment="Center" Height="43" Margin="174,171,175,0" TextWrapping="Wrap" Text="Личная информация" VerticalAlignment="Top" Width="126" TextAlignment="Center" FontSize="14"/>
-        <Button Content="Сохранить" HorizontalAlignment="Center" Margin="174,234,175,0" VerticalAlignment="Top" Width="126" Click="Save" Height="43" FontSize="15"/>
-    </Grid>
-</Page>

+ 0 - 121
MyTests/Registration.xaml.cs

@@ -1,121 +0,0 @@
-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;
-using System.Text.RegularExpressions;
-
-namespace MyTests
-{
-    public partial class Registration : Page
-    {
-        public Registration()
-        {
-            InitializeComponent();
-        }
-
-        private void Save(object sender, RoutedEventArgs e)
-        {
-            try
-            {
-                if (Login.Text == "" || Password.Text == "")
-                    MessageBox.Show("Поля не могут быть пустыми.");
-                else if (RegistrLogin(Login.Text))
-                    MessageBox.Show("Данный логин уже занят");
-                else
-                {
-                    try
-                    {
-                        Users newUser = new Users()
-                        {
-                            IdUser = cnt.db.Users.Select(p => p.IdUser).DefaultIfEmpty(0).Max() + 1,
-                            Login = Login.Text,
-                            Password = Password.Text,
-                            Email = Email.Text,
-                            Info = Info.Text
-                        };
-                        cnt.db.Users.Add(newUser);
-                        cnt.db.SaveChanges();
-                        MessageBox.Show("Вы успешно зарегистрировались");
-                        Session.User = cnt.db.Users.Where(item => item.Login == Login.Text && item.Password == Password.Text).FirstOrDefault();
-
-                        MainWindow RegAuth = new MainWindow();
-                        RegAuth.Show();
-                    }
-                    catch (Exception ex)
-                    {
-                        MessageBox.Show(ex.ToString());
-                    }
-                }
-            }
-            catch (Exception ex)
-            {
-                MessageBox.Show(ex.ToString());
-            }
-
-        }
-
-        public bool RegistrLogin(string Login)
-        {
-            //if (cnt.db.Users.Select(item => item.Login).Contains(Login))
-            //    return true;
-            //else
-                return false;
-        }
-
-        #region  FOCUS 
-        private void LoginFocus(object sender, RoutedEventArgs e)
-        {
-            Login.Text = "";
-        }
-
-        private void LoginLostFocus(object sender, RoutedEventArgs e)
-        {
-            if (Login.Text.Trim() == "")
-                Login.Text = "Логин";
-        }
-
-        private void PasswordFocus(object sender, RoutedEventArgs e)
-        {
-            Password.Text = "";
-        }
-
-        private void PasswordLostFocus(object sender, RoutedEventArgs e)
-        {
-            if (Password.Text.Trim() == "")
-                Password.Text = "123456";
-        }
-
-        private void EmailNameFocus(object sender, RoutedEventArgs e)
-        {
-            Email.Text = "";
-        }
-
-        private void EmailLostFocus(object sender, RoutedEventArgs e)
-        {
-            if (Email.Text.Trim() == "")
-                Email.Text = "Почта";
-        }
-
-        private void InfoNameFocus(object sender, RoutedEventArgs e)
-        {
-            Info.Text = "";
-        }
-
-        private void InfoLostFocus(object sender, RoutedEventArgs e)
-        {
-            if (Info.Text.Trim() == "")
-                Info.Text = "Личная информация";
-        }
-        #endregion
-    }
-}