<Window x:Class="BodyshopPartner.Utils.Growls.GrowlNotification"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:BodyshopPartner.Utils.Growls"
        mc:Ignorable="d"
        SizeToContent="WidthAndHeight"
        AllowsTransparency="True"
        WindowStyle="None"
        ShowInTaskbar="False"
        Topmost="True"
        UseLayoutRounding="True"
        Title="BodyshopPartner Notification"
        xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
        TextElement.Foreground="{DynamicResource MaterialDesignBody}"
        TextElement.FontWeight="Regular"
        TextElement.FontSize="13"
        TextOptions.TextFormattingMode="Ideal"
        TextOptions.TextRenderingMode="Auto"
        Background="Transparent"
        FontFamily="{DynamicResource MaterialDesignFont}">
    <Window.Resources>
        <Storyboard x:Key="CollapseStoryboard">
            <DoubleAnimation From="100"
                             To="0"
                             Storyboard.TargetProperty="Height"
                             Duration="0:0:0.5" />
        </Storyboard>
        <DataTemplate x:Key="MessageTemplate"
                      DataType="Model:Notification">
            <Grid x:Name="NotificationWindow"
                  Tag="{Binding Path=Id}"
                  MouseLeftButtonDown="NotificationWindow_MouseLeftButtonDown"
                  Background="Transparent"
                  SizeChanged="NotificationWindowSizeChanged">
                <Border Name="border"
                        Background="#808080"
                        BorderThickness="0"
                        CornerRadius="4"
                        Margin="10">
                    <Border.Effect>
                        <DropShadowEffect ShadowDepth="0"
                                          Opacity="0.8"
                                          BlurRadius="10" />
                    </Border.Effect>
                    <Grid Height="100"
                          Width="380"
                          Margin="6">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="*"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="*"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Image Grid.RowSpan="2"
                               Source="../../favicon.ico"
                               Margin="4"
                               Width="24"></Image>
                        <TextBlock Grid.Column="1"
                                   Text="{Binding Path=Title}"
                                   TextOptions.TextRenderingMode="ClearType"
                                   TextOptions.TextFormattingMode="Display"
                                   Foreground="White"
                                   FontFamily="Arial"
                                   FontSize="14"
                                   FontWeight="Bold"
                                   VerticalAlignment="Center"
                                   Margin="2,4,4,2"
                                   TextWrapping="Wrap"
                                   TextTrimming="CharacterEllipsis" />
                        <!--<Button x:Name="CloseButton" Grid.Column="1" Width="16" Height="16"  HorizontalAlignment="Right" Margin="0,0,12,0" />-->

                        <Button x:Name="CloseButton"
                                Grid.Column="1"
                                Style="{StaticResource MaterialDesignFloatingActionMiniAccentButton}"
                                HorizontalAlignment="Right"
                                Width="24"
                                Height="24">
                            <materialDesign:PackIcon Kind="Close"
                                                     Height="16"
                                                     Width="16" />
                        </Button>

                        <TextBlock Grid.Row="1"
                                   Grid.Column="1"
                                   Text="{Binding Path=Subtitle}"
                                   TextOptions.TextRenderingMode="ClearType"
                                   TextOptions.TextFormattingMode="Display"
                                   Foreground="White"
                                   FontFamily="Arial"
                                   FontSize="14"
                                   FontWeight="Bold"
                                   VerticalAlignment="Center"
                                   Margin="2,4,4,2"
                                   TextWrapping="Wrap"
                                   TextTrimming="CharacterEllipsis" />
                        <TextBlock Grid.Row="2"
                                   Grid.Column="1"
                                   Text="{Binding Path=Message}"
                                   TextOptions.TextRenderingMode="ClearType"
                                   TextOptions.TextFormattingMode="Display"
                                   Foreground="White"
                                   FontFamily="Arial"
                                   VerticalAlignment="Center"
                                   Margin="2,2,4,4"
                                   TextWrapping="Wrap"
                                   TextTrimming="CharacterEllipsis" />
                    </Grid>
                </Border>
            </Grid>
            <DataTemplate.Triggers>
                <EventTrigger RoutedEvent="Window.Loaded"
                              SourceName="NotificationWindow">
                    <BeginStoryboard x:Name="FadeInStoryBoard">
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="NotificationWindow"
                                             From="0.01"
                                             To="1"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0:0:1" />
                            <DoubleAnimation Storyboard.TargetName="NotificationWindow"
                                             From="1"
                                             To="0"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0:0:1"
                                             BeginTime="0:0:3" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
                <Trigger Property="IsMouseOver"
                         Value="True">
                    <Trigger.EnterActions>
                        <SeekStoryboard Offset="0:0:1"
                                        BeginStoryboardName="FadeInStoryBoard" />
                        <PauseStoryboard BeginStoryboardName="FadeInStoryBoard" />
                    </Trigger.EnterActions>
                    <Trigger.ExitActions>
                        <SeekStoryboard Offset="0:0:1"
                                        BeginStoryboardName="FadeInStoryBoard" />
                        <ResumeStoryboard BeginStoryboardName="FadeInStoryBoard"></ResumeStoryboard>
                    </Trigger.ExitActions>
                </Trigger>
                <EventTrigger RoutedEvent="Button.Click"
                              SourceName="CloseButton">
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="NotificationWindow"
                                             From="1"
                                             To="0"
                                             Storyboard.TargetProperty="(Grid.Opacity)"
                                             Duration="0:0:0" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
                <Trigger SourceName="NotificationWindow"
                         Property="Opacity"
                         Value="0">
                    <Setter TargetName="NotificationWindow"
                            Property="Visibility"
                            Value="Hidden"></Setter>
                    <Trigger.EnterActions>
                        <BeginStoryboard Storyboard="{StaticResource CollapseStoryboard}" />
                    </Trigger.EnterActions>
                </Trigger>
            </DataTemplate.Triggers>
        </DataTemplate>
    </Window.Resources>
    <ItemsControl x:Name="NotificationsControl"
                  FocusVisualStyle="{x:Null}"
                  ItemsSource="{Binding .}"
                  ItemTemplate="{StaticResource MessageTemplate}" />
</Window> 
