mr.solder5 5 anos atrás
pai
commit
2604726dc5

+ 2 - 2
InteractiveKiosk/AuthorizationWindow.xaml

@@ -7,10 +7,10 @@
         mc:Ignorable="d"
         Title="Окно авторизации" Height="451" Width="800" WindowStartupLocation="CenterScreen">
     <Grid>
-        <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"/>
+        <TextBox Name="username" GotFocus="Username_GotFocus" LostFocus="Username_LostFocus" HorizontalAlignment="Left" Height="23" Margin="276,178,0,0" TextWrapping="Wrap" Text="Логин" VerticalAlignment="Top" Width="120" TextChanged="username_TextChanged"/>
         <TextBlock HorizontalAlignment="Left" Margin="126,179,0,0" TextWrapping="Wrap" Text="Имя пользователя:" VerticalAlignment="Top" Height="23" Width="106"/>
         <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"/>
+        <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" TextChanged="password_TextChanged"/>
         <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>

+ 28 - 4
InteractiveKiosk/AuthorizationWindow.xaml.cs

@@ -32,6 +32,32 @@ namespace InteractiveKiosk
         //    tb.GotFocus -= TextBox_GotFocus;
         //}
 
+        private void username_TextChanged(object sender, RoutedEventArgs e)
+        {
+            if (username.Text == "Логин")
+            {
+                username.Foreground = Brushes.Gray;
+            }
+            else if (username.Text == "")
+            {
+                username.Foreground = Brushes.Black;
+            }
+
+        }
+
+        private void password_TextChanged(object sender, RoutedEventArgs e)
+        {
+            if (password.Text == "Пароль")
+            {
+                password.Foreground = Brushes.Gray;
+            }
+            else if (password.Text == "")
+            {
+                password.Foreground = Brushes.Black;
+            }
+
+        }
+
         private const string defaultText = "Логин";
         private const string defaultText1 = "Пароль";
 
@@ -39,8 +65,6 @@ namespace InteractiveKiosk
         {
             username.Text = username.Text == defaultText ?
             string.Empty : username.Text;
-            username.Foreground = Brushes.Gray;
-
         }
 
         private void Password_GotFocus(object sender, RoutedEventArgs e)
@@ -51,9 +75,9 @@ namespace InteractiveKiosk
 
         private void Username_LostFocus(object sender, RoutedEventArgs e)
         {
-            username.Text = username.Text == string.Empty ? 
+            username.Text = username.Text == string.Empty ?
             defaultText : username.Text;
-            username.Foreground = Brushes.Gray;
+            
         }
         private void Password_LostFocus(object sender, RoutedEventArgs e)
         {