<?xml version="1.0" encoding="utf-8"?>
<featurebase:FeaturePage
    x:Class="was.droidtransfer.features.clipboard.ClipboardFeaturePage"
    xmlns:featurebase="using:was.droidtransfer.features"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:was.droidtransfer.features.clipboard"
    xmlns:controls="using:was.droidtransfer.features.clipboard.controls"
    xmlns:data="using:was.droidtransfer.features.clipboard.data"
    xmlns:commonclipboard="using:was.android.connect.common.clipboard"
    xmlns:commoncontrols="using:was.droidtransfer.features.controls"
    xmlns:converters="using:was.droidtransfer.features.clipboard.converters"
    xmlns:fconverters="using:was.droidtransfer.features.converters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DataContext="{d:DesignInstance Type=local:ClipboardFeaturePage}">
    <Page.Resources>
        <ResourceDictionary>
            <converters:ClipboardGroupToItemCountConverter x:Key="ClipboardGroupToItemCountConverter" />
            <converters:ClipboardGroupToTitleConverter x:Key="ClipboardGroupToTitleConverter" />
            <converters:ClipboardGroupToVisibilityConverter x:Key="ClipboardGroupToVisibilityConverter" />
            <fconverters:EnumerableCountToVisibilityConverter x:Key="EnumerableCountToVisibilityConverter" />
            <fconverters:VisibilityInverter x:Key="VisibilityInverter" />
            <data:ClipboardDataTemplateSelector x:Key="ItemTemplateSelector">
                <data:ClipboardDataTemplateSelector.TextTemplate>
                    <DataTemplate x:DataType="commonclipboard:ClipboardData">
                        <controls:ClipboardDataListViewItem CopyRequested="_clipboardDataListViewItem_CopyRequested" SendToWindowsRequested="_clipboardDataListViewItem_SendToWindowsRequested" SendToDeviceRequested="_clipboardDataListViewItem_SendToDeviceRequested" RefreshRequested="_clipboardDataListViewItem_RefreshRequested">
                            <TextBlock Text="{x:Bind Text}" TextWrapping="Wrap" />
                        </controls:ClipboardDataListViewItem>
                    </DataTemplate>
                </data:ClipboardDataTemplateSelector.TextTemplate>
                <data:ClipboardDataTemplateSelector.HTMLTemplate>
                    <DataTemplate x:DataType="commonclipboard:ClipboardData">
                        <controls:ClipboardDataListViewItem CopyRequested="_clipboardDataListViewItem_CopyRequested" SendToWindowsRequested="_clipboardDataListViewItem_SendToWindowsRequested" SendToDeviceRequested="_clipboardDataListViewItem_SendToDeviceRequested" RefreshRequested="_clipboardDataListViewItem_RefreshRequested">
                            <controls:HTMLClipboardDataViewer HTMLContent="{x:Bind Value}" />
                        </controls:ClipboardDataListViewItem>
                    </DataTemplate>
                </data:ClipboardDataTemplateSelector.HTMLTemplate>
                <data:ClipboardDataTemplateSelector.UnsupportedTemplate>
                    <DataTemplate x:DataType="commonclipboard:ClipboardData">
                        <controls:ClipboardDataListViewItem CopyRequested="_clipboardDataListViewItem_CopyRequested" SendToWindowsRequested="_clipboardDataListViewItem_SendToWindowsRequested" SendToDeviceRequested="_clipboardDataListViewItem_SendToDeviceRequested" RefreshRequested="_clipboardDataListViewItem_RefreshRequested">
                            <TextBlock Text="Unsupported data type..." Opacity="0.5" />
                        </controls:ClipboardDataListViewItem>
                    </DataTemplate>
                </data:ClipboardDataTemplateSelector.UnsupportedTemplate>
            </data:ClipboardDataTemplateSelector>
        </ResourceDictionary>
    </Page.Resources>
    <Grid x:Name="gridRoot" Visibility="Collapsed">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Border Style="{ThemeResource PageHeaderBorderStyle}">
            <Grid>
                <CommandBar Style="{ThemeResource PageHeaderCommandBarStyle}">
                    <featurebase:CopyProgressAppBarUserController x:Name="copyProgressUserControl" Visibility="Collapsed" OnCancelTapped="_copyProgressUserControl_OnCancelTapped"/>
                    <AppBarButton x:Name="appBarButtonSaveToPC" x:Uid="AppBarButtonSaveToPC" Label="XX Save to PC" Style="{ThemeResource AppBarButtonStyle}" Click="_appBarButtonSaveToPC_Click">
                        <AppBarButton.Content>
                            <FontIcon Glyph="&#xE78C;" Foreground="{ThemeResource AccentFillColorDefaultBrush}"/>
                        </AppBarButton.Content>
                    </AppBarButton>
                    <AppBarButton x:Name="appBarButtonWindowsClipboard" x:Uid="AppBarButtonWindowsClipboard" Label="XX Windows Clipboard" Style="{ThemeResource AppBarButtonStyle}" Click="_appBarButtonWindowsClipboard_Click">
                        <AppBarButton.Content>
                            <FontIcon Glyph="&#xE896;" Foreground="{ThemeResource AccentFillColorDefaultBrush}"/>
                        </AppBarButton.Content>
                    </AppBarButton>
                    <AppBarButton x:Name="appBarButtonDeviceClipboard" x:Uid="AppBarButtonDeviceClipboard" Label="XX Device Clipboard" Style="{ThemeResource AppBarButtonStyle}" Click="_appBarButtonDeviceClipboard_Click">
                        <AppBarButton.Content>
                            <FontIcon Glyph="&#xE898;" Foreground="{ThemeResource AccentFillColorDefaultBrush}"/>
                        </AppBarButton.Content>
                    </AppBarButton>
                    <AppBarButton x:Name="appBarButtonRefresh" x:Uid="AppBarButtonRefresh" Label="XX Refresh" Style="{ThemeResource AppBarButtonStyle}" Click="_appBarButtonRefresh_Click">
                        <AppBarButton.Content>
                            <FontIcon Glyph="&#xE72C;" Foreground="{ThemeResource AccentFillColorDefaultBrush}"/>
                        </AppBarButton.Content>
                    </AppBarButton>
                </CommandBar>
                <TextBlock Text="{Binding PageTitle}" Style="{ThemeResource PageHeaderTitleStyle}"/>
            </Grid>
        </Border>
        <SplitView Grid.Row="1" OpenPaneLength="300" Style="{ThemeResource FeatureSplitViewStyle}">
            <SplitView.Pane>
                <Grid Margin="0,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="auto"/>
                    </Grid.ColumnDefinitions>
                    <Grid Padding="15">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <StackPanel Spacing="20" Margin="0,20,0,20">
                            <FontIcon Glyph="&#xE8C8;" FontSize="64" Foreground="{ThemeResource SystemControlForegroundBaseHighBrush}" HorizontalAlignment="Center" VerticalAlignment="Center" />
                            <TextBlock x:Uid="TextBlockFeatureInstruction" Style="{ThemeResource BodyStrongTextBlockStyle}" Text="XX Select one or more clipboard entries from the right to copy to your PC." TextAlignment="Center" />
                        </StackPanel>
                        <TextBlock x:Uid="TextBlockFeatureNote" Grid.Row="1" Style="{ThemeResource CaptionTextBlockStyle}" Text="XX Please note that clipboard data can only be read from your device if the Transfer Companion app is the active application on your Android device." Opacity="0.8" TextAlignment="Center" />
                    </Grid>
                    <commoncontrols:ResizeSplitterHandle Grid.RowSpan="2" Grid.Column="1" Margin="0"/>
                </Grid>
            </SplitView.Pane>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Border x:Name="borderCompanionInBackground" Background="{ThemeResource SystemControlErrorBackgroundColor}" Padding="10" Visibility="Collapsed">
                    <Grid ColumnSpacing="10">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <FontIcon Glyph="&#xE783;" Foreground="{ThemeResource SystemControlErrorTextForegroundBrush}" />
                        <StackPanel Grid.Column="1">
                            <TextBlock x:Uid="TextBlockDeviceInBackgroundLineA" Style="{ThemeResource BodyStrongTextBlockStyle}" Text="XX The Transfer Companion app is currently in the background on your device." Foreground="{ThemeResource SystemControlErrorTextForegroundBrush}" />
                            <TextBlock x:Uid="TextBlockDeviceInBackgroundLineB" Style="{ThemeResource BodyTextBlockStyle}" Text="XX New clipboard data will not be read until it returns to the foreground." Foreground="{ThemeResource SystemControlErrorTextForegroundBrush}" />
                        </StackPanel>
                    </Grid>
                </Border>
                <ListView Grid.Row="1" x:Name="listViewData" ItemsSource="{x:Bind DataViewSource.View, Mode=OneWay}" Visibility="{x:Bind DataViewSource.View, Converter={StaticResource EnumerableCountToVisibilityConverter}, Mode=OneWay}" ItemTemplateSelector="{StaticResource ItemTemplateSelector}" SelectionChanged="_listViewData_SelectionChanged" SelectionMode="Extended">
                    <ListView.Resources>
                        <SolidColorBrush x:Key="ListViewItemPointerOver" Color="Transparent" />
                        <SolidColorBrush x:Key="ListViewItemBackgroundSelected" Color="Transparent" />
                        <SolidColorBrush x:Key="ListViewItemBackgroundSelectedPointerOver" Color="Transparent" />
                    </ListView.Resources>
                    <ListView.GroupStyle>
                        <GroupStyle>
                            <GroupStyle.HeaderContainerStyle>
                                <Style TargetType="ListViewHeaderItem">
                                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                                </Style>
                            </GroupStyle.HeaderContainerStyle>
                            <GroupStyle.HeaderTemplate>
                                <DataTemplate x:DataType="data:ClipboardDataGroup">
                                    <Grid ColumnSpacing="10">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="*" />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <TextBlock Style="{ThemeResource SubheaderTextBlockStyle}" FontSize="18" FontWeight="Bold" Text="{x:Bind Converter={StaticResource ClipboardGroupToTitleConverter}}" VerticalAlignment="Bottom" />
                                        <TextBlock Grid.Column="1" Style="{ThemeResource CaptionTextBlockStyle}" Text="{x:Bind Converter={StaticResource ClipboardGroupToItemCountConverter}}" VerticalAlignment="Bottom" Margin="0,0,0,2" Visibility="{x:Bind Converter={StaticResource ClipboardGroupToVisibilityConverter}, Mode=OneWay}" />
                                        <Button x:Uid="ButtonClearHistory" Grid.Column="2" Content="Clear History" Visibility="{x:Bind Converter={StaticResource ClipboardGroupToVisibilityConverter}}" Click="_listViewData_ClearHistory" />
                                    </Grid>
                                </DataTemplate>
                            </GroupStyle.HeaderTemplate>
                        </GroupStyle>
                    </ListView.GroupStyle>
                    <ListView.ItemContainerStyle>
                        <Style TargetType="ListViewItem">
                            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                            <Setter Property="Margin" Value="8,5,8,5" />
                        </Style>
                    </ListView.ItemContainerStyle>
                </ListView>
                <StackPanel Grid.Row="1" VerticalAlignment="Center" Padding="40" Spacing="10" HorizontalAlignment="Center" MinWidth="300" MaxWidth="600" Visibility="{x:Bind listViewData.Visibility, Converter={StaticResource VisibilityInverter}, Mode=OneWay}">
                    <TextBlock x:Uid="TextBlockNoDataFoundLineA" Style="{ThemeResource BodyStrongTextBlockStyle}" Text="XX No clipboard data was found." TextAlignment="Center" />
                    <TextBlock x:Uid="TextBlockNoDataFoundLineB" Style="{ThemeResource BodyTextBlockStyle}" Text="XX Please ensure that the Transfer Companion app is not running in the background on your device." />
                </StackPanel>
            </Grid>
        </SplitView>
    </Grid>
</featurebase:FeaturePage>
