<!-- Resource Dictionary used to store a Data Template used to 
     display message content Video. This data template will be 
     selected by the MessageContentSelector class if the message 
     content is determined to be of Video type. -->
<ResourceDictionary
    x:Class="was.touchcopy.features.messaging.ux.MessageContentVideoDataTemplate"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:featurebase ="using:was.touchcopy.features.controls"
    xmlns:messaging="using:was.touchcopy.features.messaging"
    xmlns:converters="using:was.touchcopy.features.messaging.converters"
    xmlns:commonconverters="using:was.touchcopy.features.converters"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <converters:MessageContentToAudioVideoBackupFileConverter x:Key="MessageContentToAudioVideoBackupFileConverter"/>
    <converters:MessageContentAvailabilityToVisibilityConverter x:Key="MessageContentAvailabilityToVisibilityConverter" />
    <commonconverters:VisibilityInverter x:Key="VisibilityInverter" />
    
    <DataTemplate x:Key="MessageContentVideoDataTemplate" x:DataType="messaging:MessageContent">
        <Border Padding="0" Margin="0,0,0,0" CornerRadius="{ThemeResource HyperlinkFocusRectCornerRadius}" Background="Transparent"
                MaxWidth="400" MinHeight="400">
            <Grid>
                <Grid x:Name="gridContent" PointerEntered="PointerEnteredGrid" PointerExited="PointerExitedGrid" Visibility="{Binding Converter={StaticResource MessageContentAvailabilityToVisibilityConverter}, Mode=OneTime}">
                    <featurebase:VideoFileViewerControl x:Name="videoFileViewerControl" BackupFile="{x:Bind Converter={StaticResource MessageContentToAudioVideoBackupFileConverter} }">
                        <featurebase:VideoFileViewerControl.ContextFlyout>
                            <MenuFlyout>
                                <MenuFlyoutItem x:Uid="MenuFlyoutSaveToPC" Text="Save to PC" Click="SaveToPCClick" Tag="{x:Bind}">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon Glyph="&#xE78C;"/>
                                    </MenuFlyoutItem.Icon>
                                </MenuFlyoutItem>
                                <MenuFlyoutItem x:Uid="MenuFlyoutPreview" Text="Preview" Click="PreviewClick" Tag="{x:Bind}">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon Glyph="&#xE890;"/>
                                    </MenuFlyoutItem.Icon>
                                </MenuFlyoutItem>
                            </MenuFlyout>
                        </featurebase:VideoFileViewerControl.ContextFlyout>
                    </featurebase:VideoFileViewerControl>
                    <Border x:Name="borderControls" Visibility="Collapsed" HorizontalAlignment="Right" VerticalAlignment="Top" Background="{ThemeResource TextFillColorInverse}" Padding="3" Margin="10,10,10,10" CornerRadius="6">
                        <StackPanel Orientation="Horizontal">
                            <Button Click="SaveToPCButton_Click" BorderThickness="0" Background="Transparent" CornerRadius="4,0,0,4" Foreground="{ThemeResource TextFillColorPrimary}" Tag="{x:Bind}">
                                <FontIcon Glyph="&#xE78C;" />
                                <ToolTipService.ToolTip>
                                    <ToolTip x:Uid="SaveToPCToolTip" Content="Save to PC" />
                                </ToolTipService.ToolTip>
                            </Button>
                            <AppBarSeparator />
                            <Button Click="PreviewButton_Click" BorderThickness="0" Background="Transparent" CornerRadius="0,4,4,0" Foreground="{ThemeResource TextFillColorPrimary}" Tag="{x:Bind}">
                                <FontIcon Glyph="&#xE890;" />
                                <ToolTipService.ToolTip>
                                    <ToolTip x:Uid="PreviewToolTip" Content="Preview" />
                                </ToolTipService.ToolTip>
                            </Button>
                        </StackPanel>
                    </Border>
                </Grid>
                <Grid Visibility="{Binding Visibility, ElementName=gridContent, Converter={StaticResource VisibilityInverter}, Mode=OneWay}" ColumnSpacing="12">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <StackPanel VerticalAlignment="Center">
                        <TextBlock x:Uid="TextBlockVideoUnavailable" Text="XX Video unavailable." Style="{ThemeResource BodyStrongTextBlockStyle}"/>
                        <TextBlock x:Uid="TextBlockAttachmentNotStoredOnDevice" Text="XX It may not be stored on your device." Style="{ThemeResource CaptionTextBlockStyle}"/>
                    </StackPanel>
                    <HyperlinkButton x:Uid="HyperlinkButtonAttachmentUnavailable" VerticalAlignment="Center" Grid.Column="1" CornerRadius="16" Padding="4">
                        <FontIcon Glyph="&#xE897;" />
                    </HyperlinkButton>
                </Grid>
            </Grid>
        </Border>
    </DataTemplate>
</ResourceDictionary>
