<Application x:Class="Launcher.Client.WPF.GUI.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Application.Resources>
        <SolidColorBrush x:Key="MyBackgroundColor" Color="#232328"/>
        <SolidColorBrush x:Key="MyDarkTr"
                         Opacity="0.8"
                         Color="#141419" />
        <SolidColorBrush x:Key="MyGray" Color="#46464B" />
        <SolidColorBrush x:Key="MyWhite" Color="#F0F0F0" />
        <SolidColorBrush x:Key="MyGreen" Color="#28C311" />
        <SolidColorBrush x:Key="MyRed" Color="#E5160A" />
        <SolidColorBrush x:Key="MySelectionColor" Color="#B7800A" />


        <ControlTemplate x:Key="myScrollBar" TargetType="{x:Type ScrollBar}">
            <Grid x:Name="Bg" SnapsToDevicePixels="True">
                <Border Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
                        BorderBrush="{DynamicResource MyDarkTr}"
                        BorderThickness="0" />
                <Track x:Name="PART_Track"
                       IsDirectionReversed="True"
                       IsEnabled="{TemplateBinding IsMouseOver}">
                    <Track.Thumb>
                        <Thumb>
                            <Thumb.Style>
                                <Style TargetType="{x:Type Thumb}">
                                    <Setter Property="OverridesDefaultStyle" Value="True" />
                                    <Setter Property="IsTabStop" Value="False" />
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="{x:Type Thumb}">
                                                <Border x:Name="rectangle"
                                                        Width="6"
                                                        Height="{TemplateBinding Height}"
                                                        Background="{DynamicResource MyGray}"
                                                        SnapsToDevicePixels="True" />
                                                <ControlTemplate.Triggers>
                                                    <Trigger Property="IsMouseOver" Value="True">
                                                        <Setter TargetName="rectangle" Property="Background" Value="{DynamicResource MyGray}" />
                                                    </Trigger>
                                                    <Trigger Property="IsDragging" Value="True">
                                                        <Setter TargetName="rectangle" Property="Background" Value="{DynamicResource MySelectionColor}" />
                                                    </Trigger>
                                                </ControlTemplate.Triggers>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </Thumb.Style>
                        </Thumb>
                    </Track.Thumb>
                </Track>
            </Grid>
        </ControlTemplate>

        <ControlTemplate x:Key="myScrollViewer" TargetType="{x:Type ScrollViewer}">
            <Grid x:Name="Grid">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Rectangle x:Name="Corner"
                           Grid.Row="1"
                           Grid.Column="1"
                           Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
                <ScrollContentPresenter x:Name="PART_ScrollContentPresenter"
                                        Grid.Row="0"
                                        Grid.Column="0"
                                        Margin="{TemplateBinding Padding}"
                                        CanContentScroll="{TemplateBinding CanContentScroll}"
                                        CanHorizontallyScroll="False"
                                        CanVerticallyScroll="False"
                                        Content="{TemplateBinding Content}"
                                        ContentTemplate="{TemplateBinding ContentTemplate}" />
                <ScrollBar x:Name="PART_VerticalScrollBar"
                           Grid.Row="0"
                           Grid.Column="1"
                           AutomationProperties.AutomationId="VerticalScrollBar"
                           Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
                           Cursor="Arrow"
                           Maximum="{TemplateBinding ScrollableHeight}"
                           Minimum="0"
                           Template="{DynamicResource myScrollBar}"
                           ViewportSize="{TemplateBinding ViewportHeight}"
                           Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                           Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
                <ScrollBar x:Name="PART_HorizontalScrollBar"
                           Grid.Row="1"
                           Grid.Column="0"
                           AutomationProperties.AutomationId="HorizontalScrollBar"
                           Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
                           Cursor="Arrow"
                           Maximum="{TemplateBinding ScrollableWidth}"
                           Minimum="0"
                           Orientation="Horizontal"
                           Template="{DynamicResource myScrollBar}"
                           ViewportSize="{TemplateBinding ViewportWidth}"
                           Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                           Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
            </Grid>
        </ControlTemplate>

        <Style x:Key="MyTextBoxStyle" TargetType="TextBox">
            <Setter Property="IsReadOnly" Value="True" />
            <Setter Property="Background" Value="{DynamicResource MyDarkTr}" />
            <Setter Property="FontSize" Value="16" />
            <Setter Property="Foreground" Value="{DynamicResource MyWhite}" />
            <Setter Property="SelectionBrush" Value="{DynamicResource MySelectionColor}" />
            <Setter Property="Template" Value="{DynamicResource myTextBox}" />
            <Setter Property="TextWrapping" Value="Wrap" />
        </Style>
        <ControlTemplate x:Key="myTextBox" TargetType="{x:Type TextBoxBase}">
            <Border Name="Border"
                    Padding="0"
                    Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
                    BorderBrush="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
                    BorderThickness="2">
                <ScrollViewer x:Name="PART_ContentHost"
                              Margin="0"
                              Template="{DynamicResource myScrollViewer}" />
            </Border>
            <ControlTemplate.Triggers>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter TargetName="Border" Property="Background" Value="Black" />
                    <Setter TargetName="Border" Property="BorderBrush" Value="White" />
                    <Setter Property="Foreground" Value="White" />
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>

        <Style x:Key="MyButtonStyle" TargetType="Button">
            <Setter Property="Template" Value="{DynamicResource MyButton}" />
            <Setter Property="Background" Value="{DynamicResource MyDarkTr}" />
            <Setter Property="BorderThickness" Value="3" />
            <Setter Property="FontFamily" Value="Unispace" />
            <Setter Property="FontSize" Value="16" />
            <Setter Property="FontWeight" Value="Bold" />
            <Setter Property="Foreground" Value="{DynamicResource MyWhite}" />
        </Style>

        <ControlTemplate x:Key="MyButton" TargetType="Button">
            <Border x:Name="Border"
                    Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
                    BorderBrush="{Binding Foreground, RelativeSource={RelativeSource TemplatedParent}}"
                    BorderThickness="{Binding BorderThickness, RelativeSource={RelativeSource TemplatedParent}}">
                <Grid>
                    <Border x:Name="Border_fade"
                            Background="{DynamicResource MyWhite}"
                            Opacity="0.2"
                            Visibility="Hidden" />
                    <Border x:Name="Border_fade2"
                            Background="{DynamicResource MyGray}"
                            Opacity="0.4"
                            Visibility="Hidden" />
                    <ContentPresenter Margin="2"
                                      HorizontalAlignment="Center"
                                      VerticalAlignment="Center"
                                      RecognizesAccessKey="True" />
                </Grid>
            </Border>
            <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="true">
                    <Setter TargetName="Border_fade" Property="Visibility" Value="Visible" />
                </Trigger>
                <Trigger Property="IsPressed" Value="true">
                    <Setter TargetName="Border_fade" Property="Visibility" Value="Hidden" />
                    <Setter TargetName="Border_fade2" Property="Visibility" Value="Visible" />
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
        
        <Style x:Key="MyLabelStyle" TargetType="Label">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="Background" Value="{DynamicResource MyDarkTr}" />
            <Setter Property="FontFamily" Value="Unispace" />
            <Setter Property="FontStyle" Value="Normal" />
            <Setter Property="FontSize" Value="14" />
            <Setter Property="Foreground" Value="{DynamicResource MyWhite}" />
            <!-->disables some shit which removes underscores from Content<!-->
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Label}">
                        <Border Background="{TemplateBinding Background}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                Padding="{TemplateBinding Padding}">
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              RecognizesAccessKey="False" />
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <ControlTemplate x:Key="MyComboBox" TargetType="ComboBox">
            <Grid>
                <ToggleButton Focusable="false" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
                    <ToggleButton.Template>
                        <ControlTemplate>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="5*" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Border x:Name="Border"
                                        Grid.ColumnSpan="2"
                                        Background="{DynamicResource MyDarkTr}" />
                                <Border Grid.Column="0"
                                        Margin="1"
                                        Background="{DynamicResource MyDarkTr}" />
                                <Path x:Name="Arrow"
                                      Grid.Column="1"
                                      HorizontalAlignment="Center"
                                      VerticalAlignment="Center"
                                      Data="M 0 0 L 4 4 L 8 0 Z"
                                      Fill="{DynamicResource MySelectionColor}" />
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="ToggleButton.IsMouseOver" Value="true">
                                    <Setter TargetName="Border" Property="Background" Value="{DynamicResource MySelectionColor}" />
                                </Trigger>
                                <Trigger Property="ToggleButton.IsChecked" Value="true">
                                    <Setter TargetName="Border" Property="Background" Value="{DynamicResource MySelectionColor}" />
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </ToggleButton.Template>
                </ToggleButton>
                <ContentPresenter Name="ContentSite"
                                  Margin="3"
                                  Content="{TemplateBinding SelectionBoxItem}"
                                  ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                                  ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                  IsHitTestVisible="False" />
                <TextBox x:Name="PART_EditableTextBox"
                         IsReadOnly="{TemplateBinding IsReadOnly}"
                         Visibility="Hidden" />
                <Popup Name="Popup"
                       AllowsTransparency="True"
                       Focusable="False"
                       IsOpen="{TemplateBinding IsDropDownOpen}"
                       Placement="Bottom"
                       PopupAnimation="Slide">
                    <Grid Name="DropDown"
                          MinWidth="{TemplateBinding ActualWidth}"
                          MaxHeight="{TemplateBinding MaxDropDownHeight}"
                          SnapsToDevicePixels="True">
                        <Border x:Name="DropDownBorder" Background="{DynamicResource MyDarkTr}" />
                        <ScrollViewer SnapsToDevicePixels="True">
                            <StackPanel IsItemsHost="True" />
                        </ScrollViewer>
                    </Grid>
                </Popup>
            </Grid>
        </ControlTemplate>

    </Application.Resources>
</Application>
