<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:SimpleRemote.Controls.Notifications.Controls"
    xmlns:local="clr-namespace:SimpleRemote.Controls.Notifications">

    <SolidColorBrush x:Key="NotificationButtonDarkBackgroundOverlayBrush">#333333</SolidColorBrush>
    <SolidColorBrush x:Key="NotificationButtonDarkBackgroundOverlayPressedBrush">#666666</SolidColorBrush>
    <SolidColorBrush x:Key="NotificationButtonDarkBackgroundOverlayDisabledBrush">#FFFFFF</SolidColorBrush>

    <Style x:Key="NotificationBadgeBaseStyle" TargetType="{x:Type TextBlock}">
        <Setter Property="FontSize" Value="11" />
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="HorizontalAlignment" Value="Center" />
        <Setter Property="Margin" Value="10,2,0,2" />
        <Setter Property="Padding" Value="4,2" />
        <Setter Property="VerticalAlignment" Value="Center" />
    </Style>

    <Style x:Key="NotificationAdditionalContentOverBadgeStyle" TargetType="{x:Type ContentControl}">
        <Setter Property="Margin" Value="10,2,0,2" />
        <Setter Property="Padding" Value="4,2" />
        <Setter Property="HorizontalAlignment" Value="Center" />
        <Setter Property="VerticalAlignment" Value="Center" />
    </Style>

    <Style x:Key="NotificationHeaderTextStyle" TargetType="{x:Type TextBlock}">
        <Setter Property="FontSize" Value="16" />
        <Setter Property="FontWeight" Value="Light" />
        <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:NotificationMessage}}, Path=Foreground}" />
        <Setter Property="Margin" Value="0,0,8,0" />
        <Setter Property="TextWrapping" Value="Wrap" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="HorizontalAlignment" Value="Left" />
    </Style>

    <Style x:Key="NotificationMessageTextStyle" TargetType="{x:Type TextBlock}">
        <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:NotificationMessage}}, Path=Foreground}" />
        <Setter Property="Margin" Value="0,0,8,0" />
        <Setter Property="TextWrapping" Value="Wrap" />
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="VerticalAlignment" Value="Center" />
    </Style>

    <Style x:Key="NotificationMessageButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="#EAEAEA" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="Padding" Value="12,2" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <Border
                            x:Name="backgroundBorder"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding Background}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            SnapsToDevicePixels="True" />
                        <Border
                            x:Name="backgroundOverlay"
                            BorderThickness="0"
                            Opacity="0.3"
                            SnapsToDevicePixels="True" />
                        <ContentPresenter
                            x:Name="contentPresenter"
                            Margin="{TemplateBinding Padding}"
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                            Content="{TemplateBinding Content}"
                            ContentStringFormat="{TemplateBinding ContentStringFormat}"
                            ContentTemplate="{TemplateBinding ContentTemplate}"
                            Focusable="False"
                            RecognizesAccessKey="True"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Button.IsDefaulted" Value="True">
                            <Setter TargetName="backgroundBorder" Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.HighlightBrush}}" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="backgroundOverlay" Property="Background" Value="{StaticResource NotificationButtonDarkBackgroundOverlayBrush}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="backgroundOverlay" Property="Background" Value="{StaticResource NotificationButtonDarkBackgroundOverlayPressedBrush}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="backgroundOverlay" Property="Background" Value="{StaticResource NotificationButtonDarkBackgroundOverlayDisabledBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="VerticalContentAlignment" Value="Center" />
    </Style>

    <Style TargetType="{x:Type controls:NotificationMessage}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:NotificationMessage}">
                    <!--  Border for the Notification Message  -->
                    <Border
                        x:Name="notificationMessageBorder"
                        MinHeight="35"
                        VerticalAlignment="Top"
                        Background="{TemplateBinding Background}"
                        BorderBrush="#FFF5EEEB"
                        BorderThickness="0,0,0,0"
                        SnapsToDevicePixels="True"
                        UseLayoutRounding="True">
                        <!--  Outer Grid  -->
                        <Grid x:Name="outerGrid">
                            <Grid.Resources>
                                <!--  Accent Button Style  -->
                                <Style BasedOn="{StaticResource NotificationMessageButtonStyle}" TargetType="{x:Type controls:NotificationMessageButton}">
                                    <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:NotificationMessage}}, Path=ButtonAccentBrush}" />
                                </Style>
                                <!--  Accent Badge Style  -->
                                <Style
                                    x:Key="NotificationBadgeAccentStyle"
                                    BasedOn="{StaticResource NotificationBadgeBaseStyle}"
                                    TargetType="{x:Type TextBlock}">
                                    <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:NotificationMessage}}, Path=BadgeAccentBrush}" />
                                </Style>
                            </Grid.Resources>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <!--  Additional Content - Outer Grid  -->
                            <ContentControl
                                x:Name="additionalContentTop"
                                Grid.Row="0"
                                Grid.Column="0"
                                Grid.ColumnSpan="4"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                Content="{TemplateBinding AdditionalContentTop}" />
                            <ContentControl
                                x:Name="additionalContentBottom"
                                Grid.Row="2"
                                Grid.Column="0"
                                Grid.ColumnSpan="4"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                Content="{TemplateBinding AdditionalContentBottom}" />
                            <ContentControl
                                x:Name="additionalContentLeft"
                                Grid.Row="1"
                                Grid.Column="0"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                Content="{TemplateBinding AdditionalContentLeft}" />
                            <ContentControl
                                x:Name="additionalContentRight"
                                Grid.Row="1"
                                Grid.Column="3"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                Content="{TemplateBinding AdditionalContentRight}" />
                            <ContentControl
                                x:Name="additionalContentCenter"
                                Grid.Row="1"
                                Grid.Column="1"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                Content="{TemplateBinding AdditionalContentMain}" />

                            <!--  Inner Grid  -->
                            <Grid
                                x:Name="innerGrid"
                                Grid.Row="1"
                                Grid.Column="1"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <!--  Badge Grid  -->
                                <Grid
                                    x:Name="badgeGrid"
                                    Grid.Column="0"
                                    HorizontalAlignment="Stretch"
                                    VerticalAlignment="Stretch">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="*" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>
                                    <!--  Additional Content - Over Badge  -->
                                    <ContentControl
                                        x:Name="additionalContentOverBadge"
                                        Grid.Row="1"
                                        Content="{TemplateBinding AdditionalContentOverBadge}"
                                        Style="{StaticResource NotificationAdditionalContentOverBadgeStyle}" />
                                    <!--  Badge  -->
                                    <TextBlock
                                        Grid.Row="2"
                                        Style="{StaticResource NotificationBadgeAccentStyle}"
                                        Text="{TemplateBinding BadgeText}"
                                        Visibility="{TemplateBinding BadgeVisibility}" />
                                </Grid>
                                <!--  Text Grid  -->
                                <Grid
                                    x:Name="textGrid"
                                    Grid.Column="1"
                                    Margin="10,8"
                                    HorizontalAlignment="Stretch"
                                    VerticalAlignment="Stretch">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>
                                    <!--  Header and Message  -->
                                    <TextBlock
                                        x:Name="headerTextBlock"
                                        Grid.Row="0"
                                        Style="{StaticResource NotificationHeaderTextStyle}"
                                        Text="{TemplateBinding Header}"
                                        Visibility="{TemplateBinding HeaderVisibility}" />
                                    <TextBlock
                                        x:Name="messageTextBlock"
                                        Grid.Row="1"
                                        Style="{StaticResource NotificationMessageTextStyle}"
                                        Text="{TemplateBinding Message}"
                                        Visibility="{TemplateBinding MessageVisibility}" />
                                </Grid>
                            </Grid>

                            <!--  Buttons  -->
                            <ItemsControl
                                Grid.Row="1"
                                Grid.Column="2"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                ItemsSource="{TemplateBinding Buttons}">
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <StackPanel Orientation="Horizontal" />
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate DataType="local:INotificationMessageButton">
                                        <Button Content="{Binding Content}" IsEnabled="{Binding IsEnabled}" />
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>

                            <!--  Overlay Content  -->
                            <ContentControl
                                x:Name="overlayContainer"
                                Grid.Row="0"
                                Grid.RowSpan="3"
                                Grid.Column="0"
                                Grid.ColumnSpan="4"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                Content="{TemplateBinding OverlayContent}" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type controls:NotificationMessageContainer}">
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Vertical" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:NotificationMessageContainer}">
                    <Grid>
                        <Border
                            x:Name="ItemsBorder"
                            Margin="12,0,12,12"
                            Padding="{TemplateBinding Padding}"
                            Background="{TemplateBinding Background}"
                            SnapsToDevicePixels="true"
                            UseLayoutRounding="True">
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                                <ItemsPresenter.Effect>
                                    <DropShadowEffect
                                        BlurRadius="10"
                                        Direction="270"
                                        Opacity="0.3"
                                        ShadowDepth="2"
                                        Color="Black" />
                                </ItemsPresenter.Effect>
                            </ItemsPresenter>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="VerticalAlignment" Value="Top" />
    </Style>
</ResourceDictionary>
