mr.solder5 5 years ago
parent
commit
a8f7ed0e8c

+ 3 - 2
InteractiveKiosk/AuthorizationWindow.xaml

@@ -7,9 +7,10 @@
         mc:Ignorable="d"
         Title="Окно авторизации" Height="451" Width="800" WindowStartupLocation="CenterScreen">
     <Grid>
-        <TextBox Name="username" GotFocus="TextBox_GotFocus" LostFocus="TextBox_LostFocus" HorizontalAlignment="Left" Height="23" Margin="276,179,0,0" TextWrapping="Wrap" Text="Логин" VerticalAlignment="Top" Width="120"/>
+        <TextBox Name="username" GotFocus="Username_GotFocus" LostFocus="Username_LostFocus" HorizontalAlignment="Left" Height="23" Margin="276,179,0,0" TextWrapping="Wrap" Text="Логин" VerticalAlignment="Top" Width="120"/>
         <TextBlock HorizontalAlignment="Left" Margin="126,179,0,0" TextWrapping="Wrap" Text="Имя пользователя:" VerticalAlignment="Top" Height="23" Width="106"/>
-        <PasswordBox Name="password" HorizontalAlignment="Left" Margin="276,217,0,0" VerticalAlignment="Top" Width="120" Height="23"/>
+        <PasswordBox Name="password2" HorizontalAlignment="Left" Margin="390,280,0,0" VerticalAlignment="Top" Width="120" Height="23"/>
+        <TextBox Name="password" GotFocus="Password_GotFocus" LostFocus="Password_LostFocus" HorizontalAlignment="Left" Height="23" Margin="276,216,0,0" TextWrapping="Wrap" Text="Пароль" VerticalAlignment="Top" Width="120"/>
         <TextBlock HorizontalAlignment="Left" Margin="126,217,0,0" TextWrapping="Wrap" Text="Пароль:" VerticalAlignment="Top" Height="23" Width="106"/>
         <Button Content="Вход" Click = "LoginButton" HorizontalAlignment="Left" Margin="228,271,0,0" VerticalAlignment="Top" Width="75" />
     </Grid>

+ 21 - 9
InteractiveKiosk/AuthorizationWindow.xaml.cs

@@ -24,6 +24,7 @@ namespace InteractiveKiosk
         {
             InitializeComponent();
         }
+
         //public void TextBox_GotFocus(object sender, RoutedEventArgs e)
         //{
         //    TextBox tb = (TextBox)sender;
@@ -34,30 +35,41 @@ namespace InteractiveKiosk
         private const string defaultText = "Логин";
         private const string defaultText1 = "Пароль";
 
-        private void TextBox_GotFocus(object sender, RoutedEventArgs e)
+        private void Username_GotFocus(object sender, RoutedEventArgs e)
         {
-            username.Text = username.Text == defaultText ? 
+            username.Text = username.Text == defaultText ?
             string.Empty : username.Text;
-            password.Password = password.Password == defaultText1 ?
-            string.Empty : password.Password;
+            username.Foreground = Brushes.Gray;
+
+        }
+
+        private void Password_GotFocus(object sender, RoutedEventArgs e)
+        {
+            password.Text = password.Text == defaultText1 ?
+            string.Empty : password.Text;
         }
 
-        private void TextBox_LostFocus(object sender, RoutedEventArgs e)
+        private void Username_LostFocus(object sender, RoutedEventArgs e)
         {
             username.Text = username.Text == string.Empty ? 
             defaultText : username.Text;
-            password.Password = password.Password == string.Empty ?
-            defaultText1 : password.Password;
+            username.Foreground = Brushes.Gray;
+        }
+        private void Password_LostFocus(object sender, RoutedEventArgs e)
+        {
+            password.Text = password.Text == string.Empty ?
+            defaultText1 : password.Text;
         }
 
+
         private void LoginButton(object sender, RoutedEventArgs e)
         {
-            if (username.Text == "" || password.Password == "")
+            if (username.Text == "" || password.Text == "")
             {
                 MessageBox.Show("Введено неверное значение!");
                 return;
             }
-            if (db.ParkManagers.Select(item => item.Username + " " + item.Password).Contains(username.Text + " " + password.Password))
+            if (db.ParkManagers.Select(item => item.Username + " " + item.Password).Contains(username.Text + " " + password.Text))
             {
                 MessageBox.Show("Добро пожаловать, вы авторизированы");
                 //MenuWindow mw = new MenuWindow();

+ 1 - 0
InteractiveKiosk/InteractiveKiosk.csproj

@@ -120,6 +120,7 @@
     <Compile Include="ScheduleForConstruction.cs">
       <DependentUpon>DataBase.tt</DependentUpon>
     </Compile>
+    <Compile Include="System\Drawing\Color.cs" />
     <Compile Include="TypeOfAttractions.cs">
       <DependentUpon>DataBase.tt</DependentUpon>
     </Compile>

+ 6 - 0
InteractiveKiosk/System/Drawing/Color.cs

@@ -0,0 +1,6 @@
+namespace System.Drawing
+{
+    internal class Color
+    {
+    }
+}