<UserControl x:Class="FasdDesktopUi.Pages.DetailsPage.UserControls.DetailsPageDataHistorySection"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:basic="clr-namespace:FasdDesktopUi.Basics.UserControls"
             xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
             xmlns:local="clr-namespace:FasdDesktopUi.Pages.DetailsPage.UserControls"
             mc:Ignorable="d"
             x:Name="DataHistory"
             d:DesignHeight="450"
             d:DesignWidth="800">

    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="boolToVisibility" />
    </UserControl.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="{Binding ElementName=DataHistory, Path=HistoryData.TitleColumnWidth}"
                              SharedSizeGroup="TitleColumn" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="20" />
        </Grid.ColumnDefinitions>

        <local:DetailsPageDataHistoryTitleColumn x:Name="TitleColumnUc"
                                                 MouseEnterTitleRowEventHandler="MouseEnterTitleRow"
                                                 MouseLeaveTitleRowEventHandler="MouseLeaveTitleRow" />

        <ScrollViewer x:Name="HistoryValueScrollViewer"
                      Height="{Binding ElementName=TitleColumnUc, Path=ActualHeight}"
                      Grid.Column="1"
                      FocusVisualStyle="{x:Null}"
                      HorizontalScrollBarVisibility="Auto"
                      VerticalScrollBarVisibility="Disabled"
                      PreviewMouseWheel="HistoryValueScrollViewer_PreviewMouseWheel">
            <Grid x:Name="MainGrid" />
        </ScrollViewer>

        <Grid Grid.Column="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="60" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <Border x:Name="TitleRowEndBorder"
                    Grid.Row="0"
                    Style="{DynamicResource HighlightRowBorder}"
                    CornerRadius="0 7.5 7.5 0"
                    MouseEnter="TitleRowEndBorder_MouseEnter"
                    MouseLeave="TitleRowEndBorder_MouseLeave">
                <Border.Resources>
                    <Style x:Key="HighlightRowBorder"
                        TargetType="Border">
                        <Setter Property="Background"
                                Value="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}"/>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ElementName=DataHistory, Path=TitleRowIsHighlighted}" Value="True">
                                <Setter Property="Background"
                                        Value="{DynamicResource HighlightBackgroundColor.DetailsPage.DataHistory.ValueColumn}"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Border.Resources>

                <ico:AdaptableIcon Style="{DynamicResource DetailsPage.DataHistory.Icon.Lock}"
                                   Visibility="{Binding ElementName=DataHistory, Path=IsVerticalExpanded, Converter={StaticResource boolToVisibility}}"
                                   MouseLeftButtonUp="LockIcon_MouseLeftButtonUp"
                                   TouchDown="LockIcon_TouchDown"
                                   MouseLeave="LockIcon_MouseLeave" />
            </Border>

            <Border Grid.Row="1"
                    Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}"
                    CornerRadius="0 0 7.5 0"
                    Visibility="{Binding ElementName=DataHistory, Path=IsVerticalExpanded, Converter={StaticResource boolToVisibility}}">
            </Border>

            <ico:AdaptableIcon Grid.Row="0"
                               Grid.RowSpan="2"
                               Style="{DynamicResource DetailsPage.DataHistory.Icon.Chevron}"
                               MouseLeftButtonUp="HorizontalCollapse_MouseLeftButtonUp"
                               TouchDown="HorizontalCollapse_TouchDown"
                               MouseEnter="TitleRowEndBorder_MouseEnter"
                               MouseLeave="TitleRowEndBorder_MouseLeave"/>
        </Grid>

    </Grid>

</UserControl>
