mr.solder5 5 yıl önce
ebeveyn
işleme
175441501e

+ 157 - 38
InteractiveKiosk/AuthorizationWindow.xaml

@@ -5,47 +5,71 @@
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:InteractiveKiosk"
         mc:Ignorable="d"
-        Title="Окно авторизации" Height="300" Width="520" AllowsTransparency="True" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" Icon="Logo.png" WindowStyle="None" Background="Transparent">
+        Title="Окно авторизации" Height="300" Width="400" AllowsTransparency="True" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" Icon="Logo.png" WindowStyle="None" Background="Transparent">
     <Window.Resources>
-        <Style x:Key="LoginButton" TargetType="Button">
-            <Setter Property="OverridesDefaultStyle" Value="True"/>
+        <Style x:Key="TextBox" TargetType="TextBox">
             <Setter Property="Background" Value="White"/>
+            <Setter Property="VerticalContentAlignment" Value="Center"/>
+            <Setter Property="Height" Value="23"/>
+            <Setter Property="Foreground" Value="Black"/>
+            <Setter Property="FontSize" Value="13"/>
+            <Setter Property="Padding" Value="10,0,0,0"/>
+            <Setter Property="BorderBrush" Value="Black"/>
             <Setter Property="Template">
                 <Setter.Value>
-                    <ControlTemplate TargetType="Button">
-                        <Border Name="Border" BorderThickness="0" BorderBrush="Black" Background="{TemplateBinding Background}">
-                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                        </Border>
+                    <ControlTemplate TargetType="TextBox">
+                        <Grid x:Name="root" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}" SnapsToDevicePixels="True">
+                            <Border x:Name="Background" BorderThickness="1" CornerRadius="2" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"/>
+                            <ScrollViewer x:Name="PART_ContentHost" BorderThickness="0" Padding="{TemplateBinding Padding}" IsTabStop="False" Background="{x:Null}" TextElement.Foreground="{TemplateBinding Foreground}"/>
+                        </Grid>
+                        <ControlTemplate.Triggers>
+                            <Trigger Property="IsFocused" Value="True">
+                                <Setter Property="BorderBrush" Value="Black"/>
+                                <Setter Property="Background" Value="White"/>
+                            </Trigger>
+                        </ControlTemplate.Triggers>
+                    </ControlTemplate>
+                </Setter.Value>
+            </Setter>
+        </Style>
+
+        <Style x:Key="Password" TargetType="PasswordBox">
+            <Setter Property="Background" Value="White"/>
+            <Setter Property="VerticalContentAlignment" Value="Center"/>
+            <Setter Property="Height" Value="23"/>
+            <Setter Property="Foreground" Value="Black"/>
+            <Setter Property="FontSize" Value="13"/>
+            <Setter Property="BorderBrush" Value="Black"/>
+            <Setter Property="Padding" Value="10,0,0,0"/>
+            <EventSetter Event="PasswordChanged" Handler="OnPasswordChanged"/>
+            <Setter Property="Template">
+                <Setter.Value>
+                    <ControlTemplate TargetType="PasswordBox">
+                        <Grid x:Name="root" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}" SnapsToDevicePixels="True">
+                            <Border x:Name="Background" BorderThickness="1" CornerRadius="2" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"/>
+                            <ScrollViewer x:Name="PART_ContentHost" BorderThickness="0" Padding="{TemplateBinding Padding}" IsTabStop="False" Background="{x:Null}" TextElement.Foreground="{TemplateBinding Foreground}"/>
+                        </Grid>
                         <ControlTemplate.Triggers>
-                            <EventTrigger RoutedEvent="PreviewMouseDown">
-                                <BeginStoryboard>
-                                    <Storyboard>
-                                        <ThicknessAnimation Storyboard.TargetProperty="Margin" Duration="0:0:0.100" To="2, 2, 0, 0"/>
-                                    </Storyboard>
-                                </BeginStoryboard>
-                            </EventTrigger>
-                            <EventTrigger RoutedEvent="PreviewMouseUp">
-                                <BeginStoryboard>
-                                    <Storyboard>
-                                        <ThicknessAnimation Storyboard.TargetProperty="Margin" Duration="0:0:0.100" To="0, 0, 0, 0"/>
-                                    </Storyboard>
-                                </BeginStoryboard>
-                            </EventTrigger>
+                            <Trigger Property="IsFocused" Value="True">
+                                <Setter Property="BorderBrush" Value="Black"/>
+                                <Setter Property="Background" Value="White"/>
+                            </Trigger>
                         </ControlTemplate.Triggers>
                     </ControlTemplate>
                 </Setter.Value>
             </Setter>
         </Style>
+
     </Window.Resources>
     <Grid Name="Authorization" Background="Transparent" MouseDown="Authorization_MouseDown">
-        <Polygon Fill="White" Opacity="0.3" Points="107,0,115,7,249,7,257,0" Margin="80,0,0,0"></Polygon>
+        <Polygon Fill="White" Opacity="0.3" Points="107,0,115,7,249,7,257,0" Margin="0,0,98,0" HorizontalAlignment="Right" Width="392"></Polygon>
         <Border CornerRadius="20" BorderBrush="Black" BorderThickness="0">
             <Border.Background>
                 <ImageBrush ImageSource="file.jpg"/>
             </Border.Background>
         </Border>
-        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
-            <Image Name="MinButton" Height="20" Width="20" Margin="10,-255,-15,0" MouseDown="MinButton_MouseDown">
+        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Width="69">
+            <Image Name="MinButton" Height="23" Width="20" Margin="10,-255,-13,0" MouseDown="MinButton_MouseDown">
                 <Image.Style>
                     <Style TargetType="{x:Type Image}">
                         <Setter Property="Source" Value="Resources/min(inactive).png"/>
@@ -58,7 +82,7 @@
                     </Style>
                 </Image.Style>
             </Image>
-            <Image Name="ExitButton" Height="20" Width="20" Margin="20,-255,20,0" MouseDown="ExitButton_MouseDown">
+            <Image Name="ExitButton" Height="23" Width="20" Margin="20,-255,20,0" MouseDown="ExitButton_MouseDown">
                 <Image.Style>
                     <Style TargetType="{x:Type Image}">
                         <Setter Property="Source" Value="Resources/exit(inactive).png"/>
@@ -72,25 +96,17 @@
                 </Image.Style>
             </Image>
         </StackPanel>
-        <TextBox Name="username" GotFocus="Username_GotFocus" LostFocus="Username_LostFocus" HorizontalAlignment="Left" Height="23" Margin="256,27,0,0" TextWrapping="Wrap" Text="Логин" VerticalAlignment="Top" Width="120" TextChanged="username_TextChanged"/>
-        <TextBlock HorizontalAlignment="Left" Margin="122,27,0,0" TextWrapping="Wrap" Text="Имя пользователя:" VerticalAlignment="Top" Height="23" Width="106"/>
-        <PasswordBox Name="password2" HorizontalAlignment="Left" Margin="90,244,0,0" VerticalAlignment="Top" Width="120" Height="23"/>
-        <TextBox Name="password" GotFocus="Password_GotFocus" LostFocus="Password_LostFocus" HorizontalAlignment="Left" Height="23" Margin="256,75,0,0" TextWrapping="Wrap" Text="Пароль" VerticalAlignment="Top" Width="120" TextChanged="password_TextChanged" />
-        <TextBlock HorizontalAlignment="Left" Margin="122,75,0,0" TextWrapping="Wrap" Text="Пароль:" VerticalAlignment="Top" Height="23" Width="106"/>
-        <CheckBox Content="Показать пароль" HorizontalAlignment="Left" Margin="256,122,0,0" VerticalAlignment="Top"/>
-        <ListBox Name="listbox" HorizontalAlignment="Left" Height="100" Margin="10,65,0,0" VerticalAlignment="Top" Width="100"/>
-        <Border Height="30" Width="100" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="256, 230, 0, 0" CornerRadius="2" BorderThickness="1" Background="Black">
+
+        <Border Name="LogButton" Height="23" Width="106" BorderThickness="1" Background="Black" Margin="250,201,44,76">
             <Border.Style>
                 <Style TargetType="{x:Type Border}">
                     <Setter Property="BorderBrush" Value="Black"/>
                     <Style.Triggers>
-                        <Trigger Property="IsMouseOver" Value="True">
-                            <Setter Property="BorderBrush" Value="Black"/>
-                        </Trigger>
+
                         <EventTrigger RoutedEvent="PreviewMouseDown">
                             <BeginStoryboard>
                                 <Storyboard>
-                                    <ColorAnimation Storyboard.TargetProperty="BorderBrush.Color" Duration="0:0:0.100" To="Black"/>
+                                    <ColorAnimation Storyboard.TargetProperty="BorderBrush.Color" Duration="0:0:0.100" To="Gray"/>
                                 </Storyboard>
                             </BeginStoryboard>
                         </EventTrigger>
@@ -104,7 +120,110 @@
                     </Style.Triggers>
                 </Style>
             </Border.Style>
-            <Button Content="Вход" Click="LoginButton" Style="{StaticResource LoginButton}" FontFamily="Arial Black"></Button>
+
+            <Button Content="Войти" FontSize="15" Foreground="Black" >
+                <Button.Style>
+                    <Style TargetType="Button">
+                        <Setter Property="OverridesDefaultStyle" Value="True"/>
+                        <Setter Property="Background" Value="White"/>
+                        <Setter Property="Template">
+                            <Setter.Value>
+                                <ControlTemplate TargetType="Button">
+                                    <Border Name="Border" BorderThickness="0" BorderBrush="Black" Background="{TemplateBinding Background}">
+                                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                                    </Border>
+                                    <ControlTemplate.Triggers>
+                                        <Trigger Property="IsMouseOver" Value="True">
+                                            <Setter Property="Background" Value="Gray"/>
+                                        </Trigger>
+                                        <EventTrigger RoutedEvent="PreviewMouseDown">
+                                            <BeginStoryboard>
+                                                <Storyboard>
+                                                    <ThicknessAnimation Storyboard.TargetProperty="Margin" Duration="0:0:0.100" To="2, 2, 0, 0"/>
+                                                    <ColorAnimation Storyboard.TargetProperty="Background.Color" To="Gray" Duration="0:0:0.0002"/>
+                                                </Storyboard>
+                                            </BeginStoryboard>
+                                        </EventTrigger>
+                                        <EventTrigger RoutedEvent="PreviewMouseUp">
+                                            <BeginStoryboard>
+                                                <Storyboard>
+                                                    <ThicknessAnimation Storyboard.TargetProperty="Margin" Duration="0:0:0.100" To="0, 0, 0, 0"/>
+                                                    <ColorAnimation Storyboard.TargetProperty="Background.Color" To="White" Duration="0:0:0.0002"/>
+                                                </Storyboard>
+                                            </BeginStoryboard>
+                                        </EventTrigger>
+                                    </ControlTemplate.Triggers>
+                                </ControlTemplate>
+                            </Setter.Value>
+                        </Setter>
+                    </Style>
+                </Button.Style>
+            </Button>
         </Border>
+        <TextBox x:Name="Login" Style="{StaticResource TextBox}" Margin="173,98,44,179"/>
+        <TextBlock IsHitTestVisible="False" FontSize="14" Text="Логин" VerticalAlignment="Top" Foreground="Gray" Margin="183,100,56,0">
+            <TextBlock.Style>
+                <Style TargetType="{x:Type TextBlock}">
+                    <Setter Property="Visibility" Value="Collapsed"/>
+                    <Style.Triggers>
+                        <DataTrigger Binding="{Binding Text, ElementName=Login}" Value="">
+                            <Setter Property="Visibility" Value="Visible"/>
+                        </DataTrigger>
+                    </Style.Triggers>
+                </Style>
+            </TextBlock.Style>
+        </TextBlock>
+        <PasswordBox x:Name="Password" Style="{StaticResource Password}" Margin="173,136,44,141"/>
+        <TextBlock Name="Watermark" IsHitTestVisible="False" FontSize="14" Text="Пароль" VerticalAlignment="Top" Foreground="Gray" Margin="183,138,56,0">
+        </TextBlock>
+        <TextBlock HorizontalAlignment="Left" Margin="44,97,0,0" TextWrapping="Wrap" Text="Имя пользователя:" VerticalAlignment="Top" Height="23" Width="106"/>
+        <TextBlock HorizontalAlignment="Left" Margin="44,135,0,0" TextWrapping="Wrap" Text="Пароль:" VerticalAlignment="Top" Height="23" Width="106"/>
+        <ToggleButton Name="Check" Content="Показать пароль" Height="23" Width="140" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="44,201,0,0" Foreground="Black" Checked="PasswordChecked">
+            <ToggleButton.Template>
+                <ControlTemplate TargetType="{x:Type ToggleButton}">
+                    <StackPanel Orientation="Horizontal">
+                        <Border Height="23" Width="25" CornerRadius="2" HorizontalAlignment="Left" BorderThickness="1" Background="Transparent">
+                            <Border.Style>
+                                <Style TargetType="{x:Type Border}">
+                                    <Setter Property="BorderBrush" Value="Black"/>
+                                    <Style.Triggers>
+                                        <Trigger Property="IsMouseOver" Value="True">
+                                            <Setter Property="BorderBrush" Value="Gray"/>
+                                        </Trigger>
+                                        <EventTrigger RoutedEvent="PreviewMouseDown">
+                                            <BeginStoryboard>
+                                                <Storyboard>
+                                                    <ColorAnimation Storyboard.TargetProperty="BorderBrush.Color" To="Black" Duration="0:0:0.100"/>
+                                                </Storyboard>
+                                            </BeginStoryboard>
+                                        </EventTrigger>
+                                        <EventTrigger RoutedEvent="PreviewMouseUp">
+                                            <BeginStoryboard>
+                                                <Storyboard>
+                                                    <ColorAnimation Storyboard.TargetProperty="BorderBrush.Color" To="White" Duration="0:0:0.100"/>
+                                                </Storyboard>
+                                            </BeginStoryboard>
+                                        </EventTrigger>
+                                    </Style.Triggers>
+                                </Style>
+                            </Border.Style>
+                            <Image Margin="4">
+                                <Image.Style>
+                                    <Style>
+                                        <Style.Triggers>
+                                            <DataTrigger Binding="{Binding IsChecked, RelativeSource={RelativeSource AncestorType={x:Type ToggleButton}}}" Value="True">
+                                                <Setter Property="Image.Source" Value="Resources/checked.png"/>
+                                            </DataTrigger>
+                                        </Style.Triggers>
+                                    </Style>
+                                </Image.Style>
+                            </Image>
+                        </Border>
+                        <ContentPresenter Content="{TemplateBinding Content}" Margin="10,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"/>
+                    </StackPanel>
+                </ControlTemplate>
+            </ToggleButton.Template>
+        </ToggleButton>
+
     </Grid>
 </Window>

+ 22 - 60
InteractiveKiosk/AuthorizationWindow.xaml.cs

@@ -26,66 +26,6 @@ namespace InteractiveKiosk
             InitializeComponent();
         }
 
-        //public void TextBox_GotFocus(object sender, RoutedEventArgs e)
-        //{
-        //    TextBox tb = (TextBox)sender;
-        //    tb.Text = string.Empty;
-        //    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 = "Пароль";
-
-        private void Username_GotFocus(object sender, RoutedEventArgs e)
-        {
-            username.Text = username.Text == defaultText ?
-            string.Empty : username.Text;
-        }
-
-        private void Password_GotFocus(object sender, RoutedEventArgs e)
-        {
-            password.Text = password.Text == defaultText1 ?
-            string.Empty : password.Text;
-        }
-
-        private void Username_LostFocus(object sender, RoutedEventArgs e)
-        {
-            username.Text = username.Text == string.Empty ?
-            defaultText : username.Text;
-            
-        }
-        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.Text == "")
@@ -121,5 +61,27 @@ namespace InteractiveKiosk
                 this.DragMove();
             }
         }
+
+        private void OnPasswordChanged(object sender, RoutedEventArgs e)
+        {
+            if(Password.Password.Length > 0)
+            {
+                Watermark.Visibility = Visibility.Collapsed;     
+            }
+            else
+            {
+                Watermark.Visibility = Visibility.Visible;
+            }
+        }
+
+        private void PasswordChecked(object sender, RoutedEventArgs e)
+        {
+            if (Password.Password.Length > 0)
+            {
+                Password.Visibility = Visibility.Visible;
+            }
+            
+        }
+
     }
 }

+ 1 - 0
InteractiveKiosk/InteractiveKiosk.csproj

@@ -226,6 +226,7 @@
       <DependentUpon>DataBase.edmx</DependentUpon>
       <LastGenOutput>DataBase.cs</LastGenOutput>
     </Content>
+    <Resource Include="Resources\checked.png" />
     <Resource Include="Resources\exit%28inactive%29.png" />
     <Resource Include="Resources\exit.png" />
     <Resource Include="Resources\min%28inactive%29.png" />

BIN
InteractiveKiosk/Resources/checked.png