<?xml version="1.0" encoding="utf-8"?>
<!-- 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.droidtransfer.features.messaging.ux.MessageContentVideoDataTemplate"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:was.droidtransfer.features.messaging.ux"
    xmlns:data="using:was.droidtransfer.features.messaging.data"
    xmlns:featurebase="using:was.droidtransfer.features.controls"
    xmlns:converters="using:was.droidtransfer.features.messaging.converters"
    xmlns:commonConverters="using:was.droidtransfer.features.converters">
    <converters:MessageContentToIsSupportedConverter x:Key="MessageContentToIsSupportedConverter" />
    <converters:MessageContentToUnsupportedTextConverter x:Key="MessageContentToUnsupportedTextConverter" />
    <commonConverters:ValueToVisibilityConverter x:Key="ValueToVisibilityConverter" />
    <DataTemplate x:Key="MessageContentVideoDataTemplate" x:DataType="data:IMessageContent">
        <Border Padding="0" Margin="0,0,0,0" CornerRadius="{ThemeResource HyperlinkFocusRectCornerRadius}" Background="Transparent">
            <Grid>
                <Grid Visibility="{Binding Converter={StaticResource MessageContentToIsSupportedConverter}}" Width="400" MaxHeight="400" MaxWidth="400" Margin="0,0,0,10" DataContextChanged="_grid_DataContextChanged">
                    <Grid x:Name="gridVideoViewer" PointerEntered="_grid_PointerEntered" PointerExited="_grid_PointerExited" Padding="0" Width="400" MaxWidth="400">
                        <featurebase:VideoFileViewerControl x:Name="videoFileViewerControl" Width="400" MaxWidth="400" AreControlsCompact="True">
                            <featurebase:VideoFileViewerControl.ContextFlyout>
                                <MenuFlyout>
                                    <MenuFlyoutItem x:Uid="MenuFlyoutSaveToPC" Text="Save to PC" Click="_saveToPC_Click" Tag="{x:Bind}">
                                        <MenuFlyoutItem.Icon>
                                            <FontIcon Glyph="&#xE78C;"/>
                                        </MenuFlyoutItem.Icon>
                                    </MenuFlyoutItem>
                                    <MenuFlyoutItem x:Uid="MenuFlyoutPreview" Text="Preview" Click="_preview_Click" 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="_saveToPC_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="_preview_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 x:Name="gridThumbnail" PointerEntered="_gridThumbnail_PointerEntered" PointerExited="_gridThumbnail_PointerExited" Tapped="_gridThumbnail_Tapped" Padding="0" Background="Black" Tag="Tappable">
                        <Image x:Name="imageThumbnail" Tag="Tappable" />
                        <Border CornerRadius="8" Background="{ThemeResource TextFillColorInverse}" VerticalAlignment="Center" HorizontalAlignment="Center" Tag="Tappable">
                            <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Padding="10" Spacing="5" Tag="Tappable">
                                <FontIcon Glyph="&#xE714;" Tag="Tappable" />
                                <TextBlock x:Uid="TextBlockVideoClickToPlay" Text="Video: Click to Play" TextWrapping="WrapWholeWords" TextAlignment="Center" Tag="Tappable" />
                            </StackPanel>
                        </Border>
                        <Border x:Name="borderThumbnailControls" Visibility="Collapsed" HorizontalAlignment="Right" VerticalAlignment="Top" Background="{ThemeResource TextFillColorInverse}" Padding="3" Margin="10,10,10,10" CornerRadius="6">
                            <StackPanel Orientation="Horizontal">
                                <Button Click="_saveToPC_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="_preview_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 x:Name="gridLoadError" Padding="0" Background="Black" MinHeight="250">
                        <TextBlock x:Uid="TextBlockUnableToLoadVideo" Foreground="White" Text="Unable to load video." TextWrapping="WrapWholeWords" TextAlignment="Center" VerticalAlignment="Center" />
                    </Grid>
                    <Grid x:Name="gridDownloadProgress" Padding="0" Background="Black" MinHeight="250">
                        <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Padding="10">
                            <ProgressRing x:Name="progressRingDownload" IsActive="True" Margin="0,0,0,10"/>
                            <TextBlock x:Uid="TextBlockRetrievingVideoData" Foreground="White" Text="Retrieving Video Data" TextWrapping="WrapWholeWords" TextAlignment="Center" />
                            <TextBlock x:Uid="TextBlockPleaseWait" x:Name="textBlockProgress" Foreground="White" Text="Please wait..." TextWrapping="WrapWholeWords" TextAlignment="Center" />
                        </StackPanel>
                    </Grid>
                    <Border x:Name="borderPlaceholder" Background="#FF000000" Height="250" VerticalAlignment="Top" Width="400"/>
                </Grid>
                <Border BorderThickness="4,0,0,0" BorderBrush="{ThemeResource SystemErrorTextColor}" HorizontalAlignment="Stretch" Padding="8,2,4,8" Background="{ThemeResource TextFillColorInverse}" CornerRadius="0,4,4,0" Visibility="{Binding Converter={StaticResource MessageContentToIsSupportedConverter}, ConverterParameter='invert'}" Margin="0,0,0,4">
                    <StackPanel Spacing="5">
                        <TextBlock Style="{ThemeResource BodyStrongTextBlockStyle}" Text="{Binding Converter={StaticResource MessageContentToUnsupportedTextConverter}}" Padding="0" Margin="0" Foreground="{ThemeResource SystemErrorTextColor}" />
                        <TextBlock x:Uid="TextBlockUnsupportedVideoDescription" TextWrapping="Wrap" Text="XX This video format cannot be previewed but can be saved to your PC." Padding="0" Margin="0" />
                        <Button x:Uid="ButtonUnsupportedSaveToPC" Margin="0,10,0,0" Content="XX Save to PC" Click="_saveToPC_Click" />
                    </StackPanel>
                </Border>
            </Grid>
        </Border>
    </DataTemplate>
</ResourceDictionary>
