<Application x:Class="JtkPcClientWpf.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:JtkPcClientWpf"
             StartupUri="LoginWindow.xaml">
    <Application.Resources>
        <local:LoginManager x:Key="loginManager"/>
        <local:OrderManager x:Key="orderManager"/>

        <Style TargetType="ListBoxItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                        <Grid Background="{TemplateBinding Background}">
                            <ContentPresenter 
                                    ContentTemplate="{TemplateBinding ContentTemplate}"
                                    Content="{TemplateBinding Content}"
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                    Margin="{TemplateBinding Padding}">
                            </ContentPresenter>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="Button">
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="BorderBrush" Value="#FF2C2C2C" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Border x:Name="Border" CornerRadius="3" BorderBrush="#FF3B3B3B" BorderThickness="1" >
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop x:Name="GradStop1" Color="#FF5B5B5B" Offset="0"/>
                                    <GradientStop x:Name="GradStop2" Color="#FF292929" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.Background>
                            <!--<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>-->
                            <ContentPresenter Margin="2" HorizontalAlignment="Center" VerticalAlignment="Center" RecognizesAccessKey="True" />
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal" />
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <ColorAnimation Storyboard.TargetName="GradStop1" Storyboard.TargetProperty="Color" To="#FFAAAAAA" SpeedRatio="5"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <ColorAnimation Storyboard.TargetName="GradStop1" Storyboard.TargetProperty="Color" To="#FF292929" SpeedRatio="50"/>
                                            <ColorAnimation Storyboard.TargetName="GradStop2" Storyboard.TargetProperty="Color" To="#FF5B5B5B" SpeedRatio="50"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <ColorAnimation Storyboard.TargetName="GradStop1" Storyboard.TargetProperty="Color" To="#FF5B5B5B" SpeedRatio="50"/>
                                            <ColorAnimation Storyboard.TargetName="GradStop2" Storyboard.TargetProperty="Color" To="#FF5B5B5B" SpeedRatio="50"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="placeHolder" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TextBox}">
                        <Grid>
                            <Image Source="{TemplateBinding Tag}" Margin="0,0,0,0" Panel.ZIndex="3" Width="10" Height="10" HorizontalAlignment="Left" VerticalAlignment="Center" />
                            <TextBox Text="{Binding Path=Text,
                                                RelativeSource={RelativeSource TemplatedParent}, 
                                                Mode=TwoWay,
                                                UpdateSourceTrigger=PropertyChanged}"
                                 x:Name="textSource" 
                                 Background="Transparent"  Padding="5,2,0,0" AcceptsReturn="{TemplateBinding AcceptsReturn}"
                                 Panel.ZIndex="2" BorderBrush="#FF2C2C2C"  BorderThickness="0" Foreground="White" TextWrapping="{TemplateBinding TextWrapping}"/>
                            <TextBox Text="{TemplateBinding ToolTip}" Panel.ZIndex="1" BorderBrush="#FF3B3B3B" Padding="5,2,0,0">
                                <TextBox.Background>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FF292929" Offset="0"/>
                                        <GradientStop Color="#FF5B5B5B" Offset="1"/>
                                    </LinearGradientBrush>
                                </TextBox.Background>
                                <TextBox.Style>
                                    <Style TargetType="{x:Type TextBox}">
                                        <Setter Property="Foreground" Value="Transparent"/>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding Path=Text, Source={x:Reference textSource}}" Value="">
                                                <Setter Property="Foreground" Value="#FFA5A5A5"/>
                                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                                                <Setter Property="VerticalContentAlignment" Value="Center"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </TextBox.Style>
                            </TextBox>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Application.Resources>
</Application>
