<UserControl x:Class="Vulnerator.View.UI.UserGuideView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
             xmlns:Converters="clr-namespace:Vulnerator.View.Converter"
             xmlns:IconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
             xmlns:LiveCharts="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
             xmlns:ViewHelpers="clr-namespace:Vulnerator.View.ViewHelper"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:dat="clr-namespace:System.Windows.Data;assembly=PresentationFramework"
             xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:local="clr-namespace:Vulnerator.View.UI"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
             xmlns:v="clr-namespace:Vulnerator.View"
             xmlns:vm="clr-namespace:Vulnerator.ViewModel"
             xmlns:wpf="clr-namespace:Markdig.Wpf;assembly=Markdig.Wpf"
             HorizontalAlignment="Stretch"
             VerticalAlignment="Stretch"
             d:DesignHeight="800"
             d:DesignWidth="800"
             DataContext="{Binding UserGuide, Source={StaticResource Locator}}"
             mc:Ignorable="d">
    <FrameworkElement.CommandBindings>
        <CommandBinding Command="{x:Static wpf:Commands.Hyperlink}"
                        Executed="OpenHyperlink" />
    </FrameworkElement.CommandBindings>
    <UserControl.Resources>
        <ViewHelpers:AutoRefreshCollectionViewSource x:Key="UserGuideCollectionViewSource"
                                                     Source="{Binding UserGuidePages}">
            <ViewHelpers:AutoRefreshCollectionViewSource.SortDescriptions>
                <scm:SortDescription PropertyName="PageNumber" />
            </ViewHelpers:AutoRefreshCollectionViewSource.SortDescriptions>
        </ViewHelpers:AutoRefreshCollectionViewSource>
    </UserControl.Resources>
    <Grid Background="{DynamicResource WindowBackgroundBrush}">
        <Grid Margin="5,0,5,5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="51.299" />
                <ColumnDefinition Width="96.701" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Expander Grid.Column="0"
                      Grid.ColumnSpan="2"
                      Margin="0,10,0,0"
                      Background="{DynamicResource WindowBackgroundBrush}"
                      BorderThickness="0"
                      ExpandDirection="Right"
                      IsExpanded="False">
                <Expander.Header>
                    <Label Foreground="{DynamicResource LabelTextBrush}">
                        <Label.LayoutTransform>
                            <RotateTransform Angle="90" />
                        </Label.LayoutTransform>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <IconPacks:PackIconFontAwesomeLight Grid.Column="0"
                                                                Margin="5"
                                                                HorizontalAlignment="Center"
                                                                VerticalAlignment="Center"
                                                                Kind="Bookmark">
                                <IconPacks:PackIconFontAwesomeLight.LayoutTransform>
                                    <RotateTransform Angle="-90" />
                                </IconPacks:PackIconFontAwesomeLight.LayoutTransform>
                            </IconPacks:PackIconFontAwesomeLight>
                            <TextBlock Grid.Column="1"
                                       Margin="5,0"
                                       HorizontalAlignment="Center"
                                       VerticalAlignment="Center"
                                       Foreground="{DynamicResource LabelTextBrush}"
                                       Text="Table of Contents"
                                       TextTrimming="CharacterEllipsis" />
                        </Grid>
                    </Label>
                </Expander.Header>
                <ScrollViewer CanContentScroll="True"
                              HorizontalScrollBarVisibility="Disabled"
                              VerticalScrollBarVisibility="Auto">
                    <StackPanel>
                        <Label Content="Contents"
                               Style="{StaticResource TopLevelHeaderStyle}" />
                        <ListView x:Name="userGuidePagesListView"
                                  BorderThickness="0"
                                  DisplayMemberPath="Title"
                                  ItemsSource="{Binding Source={StaticResource UserGuideCollectionViewSource}}"
                                  ScrollViewer.CanContentScroll="True"
                                  ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                  ScrollViewer.VerticalScrollBarVisibility="Auto"
                                  SelectedIndex="0" />
                    </StackPanel>
                </ScrollViewer>
            </Expander>
            <Border Grid.Column="2"
                    BorderBrush="{DynamicResource TextBoxBorderBrush}"
                    BorderThickness="1"
                    CornerRadius="3">
                <wpf:MarkdownViewer Grid.Column="1"
                                    VerticalAlignment="Stretch"
                                    HorizontalContentAlignment="Left"
                                    Markdown="{Binding ElementName=userGuidePagesListView, Path=SelectedItem.Contents}"
                                    Pipeline="{Binding MarkdownPipeline}"
                                    ScrollViewer.CanContentScroll="True"
                                    ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                    ScrollViewer.VerticalScrollBarVisibility="Auto" />
            </Border>
        </Grid>
    </Grid>
</UserControl>
