Forráskód Böngészése

Redesigned profile

Imagara 2 éve
szülő
commit
c34d3e75e1

+ 9 - 9
MyTests/ImagesManip.cs

@@ -37,14 +37,14 @@ namespace MyTests
             #endregion
         }
 
-        //public static BitmapImage NewImage(Parts part)
-        //{
-        //    MemoryStream ms = new MemoryStream(part.Image);
-        //    BitmapImage image = new BitmapImage();
-        //    image.BeginInit();
-        //    image.StreamSource = ms;
-        //    image.EndInit();
-        //    return image;
-        //}
+        public static BitmapImage NewImage(Users user)
+        {
+            MemoryStream ms = new MemoryStream(user.Image);
+            BitmapImage image = new BitmapImage();
+            image.BeginInit();
+            image.StreamSource = ms;
+            image.EndInit();
+            return image;
+        }
     }
 }

+ 68 - 62
MyTests/Pages/ProfilePage.xaml

@@ -5,71 +5,77 @@
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
       xmlns:local="clr-namespace:MyTests.Pages"
       mc:Ignorable="d" 
-      d:DesignHeight="419"
-      d:DesignWidth="692"
-      Title="ProfilePage"
+      d:DesignHeight="450" 
+      d:DesignWidth="800"
+      Title="PartInfoPage"
       Background="{StaticResource color1}">
-    <Grid Margin="25"
-          Background="{StaticResource color2}">
-        <Grid.ColumnDefinitions>
-            <ColumnDefinition Width="55*"/>
-            <ColumnDefinition Width="159*"/>
-        </Grid.ColumnDefinitions>
-        <Grid Grid.Column="0">
-            <StackPanel Orientation="Vertical" 
-                        Grid.Column="0"
-                        VerticalAlignment="Top"
-                        Margin="5">
-                <TextBlock Text="Name"
-                           HorizontalAlignment="Center"
-                           FontSize="20">
-                </TextBlock>
-                <Image 
-                    Name="ProfileImg"
-                    Height="auto"
-                    Width="auto"
-                    VerticalAlignment="Top"
-                    HorizontalAlignment="Center"
-                    Margin="0,0,0,15"
-                    Source="/MyTests;component/Resources/StandartImage.png"/>
-                <Button Content="Изменить"
-                        HorizontalAlignment="Center" 
-                        Height="30"
-                        Width="150"
-                        VerticalAlignment="Top"
-                        Click="EditImageButton_Click"/>
-            </StackPanel>
+
+    <Grid Background="{StaticResource color2}"
+          Margin="10">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="215*"/>
+            <RowDefinition Height="173*"/>
+            <RowDefinition Height="42*"/>
+        </Grid.RowDefinitions>
+
+        <Grid Grid.Row="0">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="57*"/>
+                <ColumnDefinition Width="143*"/>
+            </Grid.ColumnDefinitions>
+
+            <Image Name="PartImage"
+                   Grid.Column="0"
+                   Margin="10"
+                   Source="/MyTests;component/Resources/StandartImage.png">
+                   <!--MouseDown="Img_MouseDown"-->
+            </Image>
+
+            <Grid Grid.Column="1"
+                  Margin="10"
+                  Background="{StaticResource color3}">
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="49"/>
+                    <RowDefinition/>
+                </Grid.RowDefinitions>
+                <TextBox Grid.Row="0"
+                         Name="EmailBox"
+                         Text="Email"
+                         FontSize="22"
+                         Background="{x:Null}"
+                         BorderBrush="{x:Null}"
+                         MinWidth="50">
+                </TextBox>
+
+                <Label Grid.Row="1"
+                       Content="Инфо: "
+                       FontSize="22">
+                </Label>
+            </Grid>
         </Grid>
-        <Grid Grid.Column="1">
-            <Grid.RowDefinitions>
-                <RowDefinition Height="95*"/>
-                <RowDefinition Height="274*"/>
-            </Grid.RowDefinitions>
-            <StackPanel Orientation="Vertical"
-                        Margin="10,10,10,0"
-                        Background="{StaticResource color3}"
-                        VerticalAlignment="Top" Height="74">
-                <Label Name="EmailBox"
-                       Content="Email:"
-                       FontSize="20"/>
-                <Label Name="InfoBox"
-                       Content="Info:"
-                       FontSize="20"/>
+
+        <ListBox Grid.Row="1"
+                 Background="{StaticResource color3}"
+                 BorderBrush="{StaticResource color3}">
+        </ListBox>
+
+        <Grid Grid.Row="2">
+            <StackPanel Orientation="Horizontal" 
+                        HorizontalAlignment="Center">
+                <Button Width="120"
+                        Margin="5,0,5,0"
+                        Content="Назад"
+                        FontSize="20"
+                        Click="BackButton">
+                </Button>
+                <Button Width="120"
+                        Margin="5,0,5,0"
+                        Content="Сохранить"
+                        FontSize="20"
+                        Click="SaveButton">
+                </Button>
             </StackPanel>
-            <!--<ListBox Grid.Row="1"
-                     Name="TestsListBox"
-                     Margin="10"
-                     Background="{StaticResource color3}"
-                     BorderBrush="{StaticResource color3}">
-                <ScrollViewer Name="scroll"
-                              VerticalScrollBarVisibility="Visible">
-                </ScrollViewer>
-            </ListBox>-->
-            <ListBox Name="list" DisplayMemberPath="Title" Grid.Row="1">
-                <local:Phone Title="iPhone 6S" Company="Apple" Price="54990" />
-                <local:Phone Title="Lumia 950" Company="Microsoft" Price="39990" />
-                <local:Phone Title="Nexus 5X" Company="Google" Price="29990" />
-            </ListBox>
+
         </Grid>
     </Grid>
 </Page>

+ 17 - 14
MyTests/Pages/ProfilePage.xaml.cs

@@ -15,23 +15,14 @@ using System.Windows.Shapes;
 
 namespace MyTests.Pages
 {
-    /// <summary>
-    /// Логика взаимодействия для ProfilePage.xaml
-    /// </summary>
     public partial class ProfilePage : Page
     {
         public ProfilePage()
         {
             InitializeComponent();
             TestsLoading();
-            //if (cnt.db.Dispatcher.Where(item => item.IdDispatcher == profile.DispatcherId).Select(item => item.ProfileImgSource).FirstOrDefault() != null)
-            //    ProfileImg.Source = new BitmapImage(new Uri(cnt.db.Dispatcher.Where(item => item.IdDispatcher == profile.DispatcherId).Select(item => item.ProfileImgSource).FirstOrDefault()));
-            //NameSurnameBox.Content = cnt.db.Dispatcher.Where(item => item.IdDispatcher == profile.DispatcherId).Select(item => item.Name + " " + item.Surname).FirstOrDefault();
-            //DateTime Birthday = cnt.db.Dispatcher.Where(item => item.IdDispatcher == profile.DispatcherId).Select(item => item.Birthday).FirstOrDefault();
-            //BirthdayBox.Content = Birthday.ToLongDateString();
-            //string phone = cnt.db.Dispatcher.Where(item => item.IdDispatcher == profile.DispatcherId).Select(item => item.PhoneNumber).FirstOrDefault();
-            //PhoneNumBox.Content = "+7(" + phone.Substring(0, 3) + ")" + phone.Substring(3, 3) + "-" + phone.Substring(6, 2) + "-" + phone.Substring(8, 2);
             //EmailBox.Content = cnt.db.Dispatcher.Where(item => item.IdDispatcher == profile.DispatcherId).Select(item => item.Email).FirstOrDefault();
+            //PhoneNumBox.Content = "+7(" + phone.Substring(0, 3) + ")" + phone.Substring(3, 3) + "-" + phone.Substring(6, 2) + "-" + phone.Substring(8, 2);
         }
         private void EditImageButton_Click(object sender, RoutedEventArgs e)
         {
@@ -54,18 +45,30 @@ namespace MyTests.Pages
             {
                 try
                 {
-
-                    AddTest(test.Name, test.Image, cnt.db.Questions.Where(item => item.IdTest == test.IdTest).Count());
+                    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();
                 }
             }
-        } 
+        }
         private void AddTest(string name, BitmapImage image, int questCount)
         {
-           
+            MessageBox.Show($"{name}, quests:, {questCount}");
+        }
+
+        private void SaveButton(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        private void BackButton(object sender, RoutedEventArgs e)
+        {
+
         }
     }
     class Test

+ 8 - 1
MyTests/Styles/Style.xaml

@@ -27,11 +27,18 @@
         <Setter Property="BorderBrush" Value="Black"/>
         <Setter Property="Background" Value="#33363C"/>
     </Style>
-    
+
+    <Style TargetType="PasswordBox">
+        <Setter Property="Foreground" Value="White"/>
+        <Setter Property="BorderBrush" Value="Black"/>
+        <Setter Property="Background" Value="#33363C"/>
+    </Style>
+
     <Style TargetType="TextBlock">
         <Setter Property="Foreground" Value="White"/>
         <Setter Property="Background" Value="{x:Null}"/>
     </Style>
+    
 
     <Style TargetType="ComboBox">
         <Setter Property="Foreground" Value="White"/>