<UserControl x:Class="BeWo.LoginControl"
             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"
             mc:Ignorable="d"
             Width="Auto" Background="{StaticResource LoginBackground}"
             d:DesignHeight="600" d:DesignWidth="800">
    <Grid Name="grid_root" >
        <StackPanel HorizontalAlignment="Center">
            <Grid Background="{x:Null}" Height="400" Width="600" Visibility="Visible" x:Name="gridLogin" RenderTransformOrigin="0.5,0.5" Margin="0,0,0,0">
                <Grid.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform ScaleX="1" ScaleY="1" />
                        <SkewTransform AngleX="0" AngleY="0" />
                        <RotateTransform Angle="0" />
                        <TranslateTransform X="0" Y="0" />
                    </TransformGroup>
                </Grid.RenderTransform>
                <Border CornerRadius="7,7,7,7" BorderThickness="2,2,2,2" Padding="5,5,5,5" BorderBrush="#FF606060" Background="{DynamicResource LoginBackgroundColor}">
                    <Grid Opacity="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="100" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="170" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="185" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
							<RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        
                        <Image Grid.Row="0" Grid.ColumnSpan="4" HorizontalAlignment="Left" VerticalAlignment="Top" Source="Ressources\Icons\bewoplaner_logo_big.png"  Height="45" Margin="7,7,0,0"/>
                        <Label VerticalAlignment="Top" HorizontalAlignment="Right" Content="Version x.x.x" Foreground="#FF818181" Margin="5,7,3,0" Grid.Row="0" Grid.ColumnSpan="4"
                               Grid.Column="0" FontSize="10" x:Name="lblVersion" />
                        <StackPanel Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" Margin="0,80,0,0">
                            <Label Content="Herzlich willkommen beim BeWoPlaner!" Foreground="#FF000000" FontSize="12" FontWeight="Bold" Margin="0,30,0,0" />
                            <Label Content="Bitte geben Sie Ihren Benutzernamen und Ihr Passwort ein." Foreground="#FF000000" FontSize="12" />
                        </StackPanel>


                        <Label Content="PIN:" Grid.Column="1" Grid.Row="1" Foreground="#FF000000" Background="#00000000" VerticalAlignment="Center" Visibility="{Binding Path=IsTechSupport, Converter={StaticResource BoolVisibilityConverter}}"/>
                        <TextBox x:Name="PINTextBox" Grid.Column="2" Grid.Row="1" Margin="10,0,20,0" Height="24" SnapsToDevicePixels="True" HorizontalAlignment="Stretch" Visibility="{Binding Path=IsTechSupport, Converter={StaticResource BoolVisibilityConverter}}"/>

                        <Label Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Right" Content="Benutzername:" Foreground="#FF000000" Background="#00000000" />
                        <Label Grid.Column="1" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Left" Content="Passwort:" Foreground="#FF000000" Background="#00000000" />

                        <TextBox TabIndex="0" SnapsToDevicePixels="True" Grid.Column="2" Grid.Row="2" Margin="10,10,20,10" Height="24" x:Name="TextBox_Username" HorizontalAlignment="Stretch" Text="" GotFocus="TextBox_Username_OnGotFocus" />

                        <PasswordBox Margin="10,0,20,0" Height="24" Grid.Column="2" Grid.Row="3" x:Name="PasswordBox_Password" Password="" HorizontalAlignment="Stretch" GotFocus="PasswordBox_Password_OnGotFocus" TabIndex="1"/>

                        
                        <Label x:Name="profileLabel" Grid.Column="1" Grid.Row="5" Content="Profil:" Foreground="#FF000000" FontSize="12" Visibility="Collapsed" VerticalAlignment="Center"/>

                        <StackPanel x:Name="profileStackPanel" Grid.Row="5" Grid.Column="2" Orientation="Horizontal" Margin="0,10,20,0" Visibility="Collapsed" >
                          <ComboBox HorizontalAlignment="Left" x:Name="profileSelectionComboBox" Width="175" Height="24" ItemsSource="{Binding Path=ProfileList}" SelectedIndex="0" Margin="10,0,0,0" />
                          <Button Click="button_addProfile_Click" Content="@" FontFamily="Webdings" FontSize="14" Height="23" Width="23" Margin="3,0,0,0" ToolTip="Profile bearbeiten"/>
                        </StackPanel>
						<Label x:Name="proxyLabel" Grid.Column="1" Grid.Row="6" Content="Proxy:" Foreground="#FF000000" FontSize="12" Visibility="Collapsed" VerticalAlignment="Center"/>

                        <StackPanel x:Name="proxyStackPanel" Grid.Row="6" Grid.Column="2" Orientation="Horizontal" Margin="0,5,20,0" Visibility="Collapsed">
                          <TextBox HorizontalAlignment="Left" x:Name="proxyTextBox" Width="175" Height="24" Margin="10,0,0,0" IsReadOnly="True"/>
                          <Button Click="button_configureProxy_Click" Content="@" FontFamily="Webdings" FontSize="14" Height="23" Width="23" Margin="3,0,0,0" ToolTip="Proxy bearbeiten"/>
                        </StackPanel>
                      
                        
                      <ToggleButton x:Name="showProfileSelectionBtn" Click="ShowProfileStackPanel" HorizontalAlignment="Right" Content="Erweitert" Grid.Row="4" Grid.Column="2" Margin="0,5,20,0" Foreground="#FF818181">
                          <ToggleButton.Template>
                              <ControlTemplate TargetType="{x:Type ToggleButton}">
                                  <Grid >
                                      <Grid.ColumnDefinitions>
                                          <ColumnDefinition Width="*"/>
                                          <ColumnDefinition Width="18"/>
                                      </Grid.ColumnDefinitions>
                                      <ContentPresenter x:Name="ButtonContent"/>
                                      <Path Grid.Column="1"
                                          x:Name="Down_Arrow"
                                          HorizontalAlignment="Center"
                                          VerticalAlignment="Center"
                                          Fill="{TemplateBinding Foreground}"
                                          Data="M 0 0 L 4 4 L 8 0 L 4 2 Z" Margin="0,3,0,0"
						/>
                                      <Path Grid.Column="1"
                                          x:Name="Down_Arrow2"
                                          HorizontalAlignment="Center"
                                          VerticalAlignment="Center"
                                          Fill="{TemplateBinding Foreground}"
                                          Data="M 0 0 L 4 4 L 8 0 L 4 2 Z" Margin="0,-3,0,0"
						/>

                                      <Path Grid.Column="1"
                                          x:Name="Up_Arrow"
                                          Visibility="Collapsed"
                                          HorizontalAlignment="Center"
                                          VerticalAlignment="Center"
                                          Fill="{TemplateBinding Foreground}"
                                          Data="M 0 4 L 4 0 L 8 4 L 4 2 Z" Margin="0,-3,0,0"
						/>
                                      <Path Grid.Column="1"
                                          x:Name="Up_Arrow2"
                                          Visibility="Collapsed"
                                          HorizontalAlignment="Center"
                                          VerticalAlignment="Center"
                                          Fill="{TemplateBinding Foreground}"
                                          Data="M 0 4 L 4 0 L 8 4 L 4 2 Z" Margin="0,3,0,0"
						/>
                                  </Grid>
                                  <ControlTemplate.Triggers>
                                      <Trigger Property="IsMouseOver" Value="true">
                                          <Setter Property="Fill" Value="#FF333333" TargetName="Down_Arrow"/>
                                          <Setter Property="Fill" Value="#FF333333" TargetName="Down_Arrow2"/>
                                          <Setter Property="Fill" Value="#FF333333" TargetName="Up_Arrow"/>
                                          <Setter Property="Fill" Value="#FF333333" TargetName="Up_Arrow2"/>
                                          <Setter Property="TextBlock.Foreground" Value="#FF333333" TargetName="ButtonContent"/>
                                      </Trigger>

                                      <Trigger Property="IsChecked" Value="true">
                                          <Setter Property="Visibility" Value="Collapsed" TargetName="Down_Arrow"/>
                                          <Setter Property="Visibility" Value="Collapsed" TargetName="Down_Arrow2"/>
                                          <Setter Property="Visibility" Value="Visible" TargetName="Up_Arrow"/>
                                          <Setter Property="Visibility" Value="Visible" TargetName="Up_Arrow2"/>
                                      </Trigger>
                                  </ControlTemplate.Triggers>
                              </ControlTemplate>
                          </ToggleButton.Template>
                          <ToggleButton.Triggers>
                          <EventTrigger RoutedEvent="Button.Click">
                            <BeginStoryboard>
                              <Storyboard>
                                <DoubleAnimation
                                  Storyboard.TargetName="gridLogin"
                                  Storyboard.TargetProperty="Height"
                                  From="{Binding HeightFrom, UpdateSourceTrigger=PropertyChanged}" To="{Binding HeightTo, UpdateSourceTrigger=PropertyChanged}" Duration="0:0:0.1"
                                  AutoReverse="False" Completed="AnimationComplete" />
                                <DoubleAnimation
                                  Storyboard.TargetName="linkLine"
                                  Storyboard.TargetProperty="Y1"
                                  From="{Binding LineYCoordFrom, UpdateSourceTrigger=PropertyChanged}" To="{Binding LineYCoordTo, UpdateSourceTrigger=PropertyChanged}" Duration="0:0:0.1"
                                  AutoReverse="False" Completed="Animation2Complete" />
                                <DoubleAnimation
                                  Storyboard.TargetName="linkLine"
                                  Storyboard.TargetProperty="Y2"
                                  From="{Binding LineYCoordFrom, UpdateSourceTrigger=PropertyChanged}" To="{Binding LineYCoordTo, UpdateSourceTrigger=PropertyChanged}" Duration="0:0:0.1"
                                  AutoReverse="False" />
                              </Storyboard>
                            </BeginStoryboard>
                          </EventTrigger>
                        </ToggleButton.Triggers>
                      </ToggleButton>


						<StackPanel Margin="10,30,20,50" Grid.Column="2" Grid.Row="7" Orientation="Vertical" HorizontalAlignment="Stretch">
							<Button Height="30" x:Name="button_login" HorizontalAlignment="Stretch" Content="Anmelden" Click="button_login_Click" IsDefault="True" Foreground="White" Margin="3" />
							<TextBlock VerticalAlignment="Center" Visibility="Collapsed" HorizontalAlignment="Center" Foreground="{DynamicResource MainGroupBoxForegroundBrush}" Margin="3">
								<Hyperlink RequestNavigate="PasswortVergessenLinkOnRequestNavigate" NavigateUri="#" >
									<TextBlock Text="Passwort vergessen" HorizontalAlignment="Center" FontSize="10" VerticalAlignment="Center" />
								</Hyperlink>
							</TextBlock>
						</StackPanel>
                        <TextBlock Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="3" HorizontalAlignment="Left" VerticalAlignment="Bottom" FontSize="10" Margin="10,5,0,5" Text="Copyright 2016 | beyondSoft GmbH"  Foreground="#FF818181"/>
                            
                        <TextBlock Grid.Row="7" Grid.Column="3" HorizontalAlignment="Right" VerticalAlignment="Bottom" FontSize="10" Margin="0,5,12,5">
                            <Hyperlink x:Name="hyperlink" TargetName="newWindow" Foreground="#FF818181" NavigateUri="http://www.beyondsoft.de" RequestNavigate="Hyperlink_OnRequestNavigate">www.beyondsoft.de</Hyperlink>
                        </TextBlock>
                    </Grid>
                </Border>
                <Line Grid.ColumnSpan="4" Stroke="#FFADADAD" X1="14" Y1="70" X2="585" Y2="70" StrokeThickness="1"></Line>
                <Line x:Name="linkLine" Stroke="#FFADADAD" X1="14" Y1="340" X2="585" Y2="340" StrokeThickness="1" Margin="0,30,0,-30"></Line>

            </Grid>
            <Rectangle Width="600" Height="400" RenderTransformOrigin="0.5,0.5">
                <Rectangle.OpacityMask>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0.418">
                        <GradientStop Color="#00000000" Offset="0" />
                        <GradientStop Color="#4CFFFFFF" Offset="1" />
                    </LinearGradientBrush>
                </Rectangle.OpacityMask>
                <Rectangle.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform ScaleX="1" ScaleY="-1" />
                        <SkewTransform AngleX="0" AngleY="0" />
                        <RotateTransform Angle="0" />
                        <TranslateTransform X="0" Y="0" />
                    </TransformGroup>
                </Rectangle.RenderTransform>
                <Rectangle.Fill>
                    <VisualBrush Visual="{Binding ElementName=gridLogin}" />
                </Rectangle.Fill>
            </Rectangle>
        </StackPanel>
      <Border x:Name="profileEditPopUp" />
    </Grid>
</UserControl>
