<featurebase:FeaturePage 
    x:Class="was.touchcopy.features.internet.InternetPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:was.touchcopy.features.internet"
    xmlns:featurebase="using:was.touchcopy.features"
    xmlns:internetdatabookmarks="using:was.touchcopy.features.internet.data.Bookmarks"
    xmlns:internetdatahistory="using:was.touchcopy.features.internet.data.History"
    xmlns:commoncontrols="using:was.touchcopy.features.controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="using:was.touchcopy.features.controls"
    xmlns:converters="using:was.touchcopy.features.internet.converters"
    xmlns:utilities="using:was.touchcopy.features.utilities"
    d:DataContext="{d:DesignInstance Type=local:InternetPage}"
    mc:Ignorable="d"
    x:Name="FeaturePageInternet"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Page.Resources>
        <ResourceDictionary>
            <converters:InternetItemTreeViewGlyphConverter x:Key="InternetItemTreeViewGlyphConverter" />
            <converters:BookmarkItemChildrenItemSourceConverter x:Key="BookMarkItemChildrenItemSourceConverter" />
            <converters:HistoryItemChildrenItemSourceConverter x:Key="HistoryItemChildrenItemSourceConverter" />
            <converters:BooleanInverterConverter x:Key="BooleanInverterConverter" />
        </ResourceDictionary>
    </Page.Resources>
    <Grid >
        <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" MaxWidth="350"/>
                    <AppBarButton x:Name="buttonCopyHTML" x:Uid="appBarButtonHTML" Icon="Globe" Label="XX Copy Web Page" Style="{ThemeResource AppBarButtonStyle}" Click="ButtonCopyHTML_Click" IsEnabled="{x:Bind IsExportAvailable, Mode=OneWay}">
                        <AppBarButton.Content>
                            <FontIcon Glyph="&#xE7C3;" Foreground="{x:Bind utilities:AppBarUtilities.BrushForAppBarIcon(buttonCopyHTML.IsEnabled), Mode=OneWay}"/>
                        </AppBarButton.Content>
                    </AppBarButton>
                    <AppBarButton x:Name="buttonCopy" x:Uid="appBarButtonCopy" Label="XX Save as Shortcuts" Style="{ThemeResource AppBarButtonStyle}" Click="ButtonCopy_Click" IsEnabled="{x:Bind IsExportAvailable, Mode=OneWay}">
                        <AppBarButton.Content>
                            <FontIcon Glyph="&#xE71B;" Foreground="{x:Bind utilities:AppBarUtilities.BrushForAppBarIcon(buttonCopy.IsEnabled), Mode=OneWay}"/>
                        </AppBarButton.Content>
                    </AppBarButton>
                    <AppBarButton x:Name="buttonCopyCSV" x:Uid="appBarButtonCSV" Label="XX Save to CSV" Style="{ThemeResource AppBarButtonStyle}" Click="ButtonCopyCSV_Click" IsEnabled="{x:Bind IsExportAvailable, Mode=OneWay}">
                        <AppBarButton.Content>
                            <FontIcon Glyph="&#xE9F9;" Foreground="{x:Bind utilities:AppBarUtilities.BrushForAppBarIcon(buttonCopyCSV.IsEnabled), Mode=OneWay}"/>
                        </AppBarButton.Content>
                    </AppBarButton>
                    <AppBarSeparator/>
                    <AppBarButton x:Name="buttonOpen" x:Uid="appBarButtonOpen" Label="XX Open in Broswer" Style="{ThemeResource AppBarButtonStyle}" Click="ButtonOpen_Click" IsEnabled="{x:Bind IsOpenAvailable, Mode=OneWay}">
                        <AppBarButton.Content>
                            <FontIcon Glyph="&#xE8A7;" Foreground="{x:Bind utilities:AppBarUtilities.BrushForAppBarIcon(buttonOpen.IsEnabled), Mode=OneWay}"/>
                        </AppBarButton.Content>
                    </AppBarButton>
                </CommandBar>
                <TextBlock Text="{Binding PageTitle }" Style="{ThemeResource PageHeaderTitleStyle}"/>
            </Grid>
        </Border>

        <Grid Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <NavigationView x:Name="naviagationViewInternet"  PaneDisplayMode="Top" IsSettingsVisible="False" IsBackButtonVisible="Collapsed" SelectionChanged="NaviagationViewInternet_SelectionChanged" >
                <NavigationView.MenuItems>
                    <NavigationViewItem x:Name="internetNavigationBookmarks" x:Uid="internetNavigationBookmarks" Content="XX Bookmarks"  Tag="itemBookmarks" IsSelected="True"/>
                    <NavigationViewItem x:Name="internetNavigationHistory" x:Uid="internetNavigationHistory" Content="XX History" Tag="itemHistory"/>

                </NavigationView.MenuItems>
            </NavigationView>
            <SplitView Grid.Row="1" Style="{ThemeResource FeatureSplitViewStyle}" OpenPaneLength="400" >
                <SplitView.Pane>
                    <Grid x:Name="gridInternetTrewViews">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="auto" /> 
                        </Grid.ColumnDefinitions>
                        <Grid.Resources>
                            <Style TargetType="TreeView">
                                <Setter Property="HorizontalAlignment" Value="Stretch"/>
                                <Setter Property="VerticalAlignment" Value="Stretch"/>
                                <Setter Property="SelectionMode" Value="Single"/>
                                <Setter Property="Margin" Value="0,5,0,0"/>
                            </Style>
                        </Grid.Resources>

                        <!-- History TreeView -->
                        <ScrollViewer x:Name="scrollViewHistory" HorizontalScrollMode="Disabled" HorizontalScrollBarVisibility="Disabled" Visibility="Collapsed"  Margin="0,0,4,0">
                            <TreeView x:Name="treeViewHistory" SelectionMode="Multiple" ItemsSource="{Binding InternetHistoryCollection}" ItemInvoked="TreeView_ItemInvoked" HorizontalContentAlignment="Stretch"
                                      DoubleTapped="TreeView_DoubleTapped" IsDoubleTapEnabled="True" Margin="0,0,4,0">
                                <TreeView.ItemTemplate>
                                    <DataTemplate x:DataType="internetdatahistory:HistoryItem">
                                        <TreeViewItem x:Name="treeViewHistoryItem" AutomationProperties.Name="{x:Bind Title}"
                                                          ItemsSource="{Binding Converter={StaticResource HistoryItemChildrenItemSourceConverter}, ConverterParameter={Binding Mode=TwoWay, ElementName='FeaturePageInternet', Path='History' }}">

                                            <Grid  VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="auto"/>
                                                    <ColumnDefinition Width="*"/>
                                                </Grid.ColumnDefinitions>
                                                <FontIcon Glyph="{Binding Path=Glyph, ElementName=treeViewItem, Mode=OneWay}" Margin="-5,0,10,0" />
                                                <TextBlock Text="{x:Bind Title}" Grid.Column="1" ToolTipService.ToolTip="{x:Bind Title}" TextTrimming="CharacterEllipsis"  VerticalAlignment="Center" />
                                                <FontIcon Glyph="{x:Bind Converter={StaticResource InternetItemTreeViewGlyphConverter}, ConverterParameter={Binding IsExpanded, ElementName=treeViewHistoryItem}}" Margin="0,0,10,0" />
                                                <TextBlock Text="{x:Bind Title}" Grid.Column="1" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" />
                                            </Grid>
                                  
                                            <TreeViewItem.ContextFlyout>
                                                <MenuFlyout>
                                                    <MenuFlyoutItem x:Name="flyoutmenuItemOpenInBrowser" Tag="{Binding Url}" IsEnabled="{Binding IsFolder, Converter={StaticResource BooleanInverterConverter}}"
                                                                        x:Uid="flyoutmenuItemOpenInBrowser" Text="Open in Web Browser" Click="FlyoutmenuItemOpenInBrowser_Click">
                                                        <MenuFlyoutItem.Icon>
                                                            <FontIcon Glyph="&#xE8A7;" />
                                                        </MenuFlyoutItem.Icon>
                                                    </MenuFlyoutItem>
                                                </MenuFlyout>
                                            </TreeViewItem.ContextFlyout>
                                        </TreeViewItem>
                                    </DataTemplate>
                                </TreeView.ItemTemplate>
                            </TreeView>
                        </ScrollViewer>

                        <!-- Bookmarks TreeView -->
                        <ScrollViewer x:Name="scrollViewBookMarks" HorizontalScrollMode="Disabled" HorizontalScrollBarVisibility="Disabled"  Margin="0,0,4,0" >
                            <TreeView x:Name="treeViewBookMarks"  SelectionMode="Multiple" ItemsSource="{Binding InternetBookmarkCollection}" ItemInvoked="TreeView_ItemInvoked"
                                      DoubleTapped="TreeView_DoubleTapped" IsDoubleTapEnabled="True" Margin="0,0,4,0">
                                <TreeView.ItemTemplate>
                                    <DataTemplate x:DataType="internetdatabookmarks:BookmarkItem">
                                        <TreeViewItem x:Name="treeViewItem" AutomationProperties.Name="{x:Bind Title}" HorizontalContentAlignment="Stretch"
                                                      ItemsSource="{Binding Converter={StaticResource BookMarkItemChildrenItemSourceConverter}, ConverterParameter={Binding Mode=TwoWay, ElementName='FeaturePageInternet', Path='Bookmarks' }}">
                                            <Grid>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="auto"/>
                                                    <ColumnDefinition Width="*"/>
                                                </Grid.ColumnDefinitions>
                                                <FontIcon Glyph="{x:Bind Converter={StaticResource InternetItemTreeViewGlyphConverter}, ConverterParameter={Binding IsExpanded, ElementName=treeViewItem}}" Margin="0,0,10,0" />
                                                <TextBlock Grid.Column="1" Text="{x:Bind Title}" ToolTipService.ToolTip="{x:Bind Title}" TextTrimming="CharacterEllipsis" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                            </Grid>
                                            <TreeViewItem.ContextFlyout>
                                                <MenuFlyout>
                                                    <MenuFlyoutItem x:Name="flyoutmenuItemOpenInBrowser" Tag="{Binding Url}" IsEnabled="{Binding IsFolder, Converter={StaticResource BooleanInverterConverter}}"
                                                                        x:Uid="flyoutmenuItemOpenInBrowser" Text="Open in Web Browser" Click="FlyoutmenuItemOpenInBrowser_Click">
                                                        <MenuFlyoutItem.Icon>
                                                            <FontIcon Glyph="&#xE8A7;" />
                                                        </MenuFlyoutItem.Icon>
                                                    </MenuFlyoutItem>
                                                </MenuFlyout>
                                            </TreeViewItem.ContextFlyout>
                                        </TreeViewItem>
                                    </DataTemplate>
                                </TreeView.ItemTemplate>
                            </TreeView>
                        </ScrollViewer>
                        <commoncontrols:ResizeSplitterHandle Grid.Column="1"/>
                    </Grid>
                </SplitView.Pane>
                <Border Style="{ThemeResource FeatureContentPageBorder}" Padding="0">
                    <Grid>
                        <WebView2 x:Name="webView" Visibility="Collapsed" />
                        <Grid x:Name="gridFolderDetails" Visibility="Collapsed">
                            <StackPanel VerticalAlignment="Center">
                                <FontIcon Glyph="&#xED43;" FontSize="42" Margin="0,0,0,10" />
                                <TextBlock x:Name="textBlockFolderTitle" Style="{ThemeResource TitleTextBlockStyle}" TextAlignment="Center" Margin="0,0,0,5" TextWrapping="Wrap" />
                                <TextBlock x:Name="textBlockFolderDescription" FontSize="16" TextAlignment="Center" Opacity=".7" />
                            </StackPanel>
                        </Grid>
                    </Grid>
                </Border>
            </SplitView>
            
        </Grid>
    </Grid>
</featurebase:FeaturePage>
