<ResourceDictionary x:Class="NebulaAuth.Theme.WindowStyle.WindowStyle"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
                    xmlns:local="clr-namespace:NebulaAuth.Theme.WindowStyle">

    <Style TargetType="Button" BasedOn="{StaticResource MaterialDesignFlatButton}">
        <Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
    </Style>

    <ControlTemplate x:Key="WindowTemplate" TargetType="{x:Type Window}" >
        <!--<i:Interaction.Behaviors>
            <local:WindowChromeLoadedBehavior />
        </i:Interaction.Behaviors>-->
        <Grid>
            <Border x:Name="RootBorder"
                    Margin="{x:Static local:WindowChromeHelper.LayoutOffsetThickness}"
                    BorderBrush="Transparent"
                    BorderThickness="1"
                    Background="{DynamicResource WindowBackground}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <Grid x:Name="TitleBar"
                        Grid.Row="0"
                        Height="28"
                        Background="{DynamicResource WindowBackground}">
                        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"
                                   Foreground="{DynamicResource PrimaryHueMidBrush}" 
                                   Text="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=Title}" FontSize="17"/>
                        <!--  Window Buttons  -->
                        <StackPanel
                            HorizontalAlignment="Right"
                            Orientation="Horizontal">
                            <StackPanel.Resources>
                                <Style TargetType="materialDesign:PackIcon">
                                    <Setter Property="HorizontalAlignment" Value="Center"/>
                                    <Setter Property="VerticalAlignment" Value="Center"/>
                                </Style>
                            </StackPanel.Resources>
                            <Button x:Name="MinimizeButton"
                                    Click="OnMinimizeClick"
                            >
                                <materialDesign:PackIcon Kind="WindowMinimize"/>
                            </Button>
                            <Button x:Name="MaximizeRestoreButton"
                                    Click="OnMaximizeRestoreClick"
                                     >
                                <materialDesign:PackIcon Kind="WindowMaximize"/>
                            </Button>
                            <Button x:Name="CloseButton"
                                    Click="OnCloseClick">
                                <materialDesign:PackIcon Kind="WindowClose"/>
                            </Button>
                        </StackPanel>
                    </Grid>

                    <!--  Main Window Content  -->
                    <Grid x:Name="MainGrid"
                        Grid.Row="1"
                        Background="{DynamicResource MainBackgroundBrush}">
                        <AdornerDecorator>
                            <ContentPresenter />
                        </AdornerDecorator>
                    </Grid>
                </Grid>
            </Border>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsActive" Value="True">
                <Setter TargetName="RootBorder" Property="BorderBrush" Value="#1e1e24" />

            </Trigger>
            <Trigger Property="WindowState" Value="Maximized">
                <Setter TargetName="RootBorder" Property="BorderThickness" Value="{Binding Source={x:Static local:WindowChromeHelper.WindowResizeBorderThickness}}" />
                <Setter TargetName="RootBorder" Property="BorderBrush" Value="Transparent" />
                <Setter TargetName="MaximizeRestoreButton" Property="Content" >
                    <Setter.Value>
                        <materialDesign:PackIcon Kind="WindowRestore"/>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="MainWindow" TargetType="{x:Type Window}">
        <Setter Property="UseLayoutRounding" Value="True" />
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
        <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
        <Setter Property="WindowChrome.WindowChrome">
            <Setter.Value>
                <WindowChrome
                    CaptionHeight="38"
                    CornerRadius="0"
                    GlassFrameThickness="0"
                    NonClientFrameEdges="None"
                    ResizeBorderThickness="5"
                    UseAeroCaptionButtons="False" />
            </Setter.Value>
        </Setter>
        <Setter Property="Template" Value="{StaticResource WindowTemplate}" />
    </Style>
</ResourceDictionary>