<UserControl x:Class="FasdDesktopUi.Basics.UserControls.DetailedData"
             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:local="clr-namespace:FasdDesktopUi.Basics.UserControls"
             xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
             xmlns:converter="clr-namespace:FasdDesktopUi.Basics.Converter"
             mc:Ignorable="d"
             d:DesignHeight="450"
             d:DesignWidth="800"
             x:Name="DetailedDataUc">

    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BoolToVisibility" />
        <converter:NullValueToVisibilityConverter x:Key="NullToVisibility" />
        <converter:LanguageDefinitionsConverter x:Key="LanguageConverter" />
        <Style TargetType="GridViewColumnHeader" x:Key="NoColumnHeaderStyle">
            <Setter Property="Template" Value="{x:Null}"/>
        </Style>
    </UserControl.Resources>

    <Border Margin="0 0 0 10"
            Visibility="{Binding ElementName=DetailedDataUc, Path=DetailedInformationData, Converter={StaticResource NullToVisibility}}"
            CornerRadius="10"
            Padding="10"
            Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}">

        <StackPanel x:Name="mainStackPanel">
            <StackPanel.Resources>
                <Style TargetType="GridViewColumnHeader">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                                <TextBlock Style="{DynamicResource DetailsPage.DataHistory.TitleColumn.OverviewTitle}"
                                           Text="{TemplateBinding Content}"
                                           Margin="0 0 15 5"
                                           Padding="5"
                                           TextAlignment="Left"
                                           HorizontalAlignment="Left" />
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>

                <Style TargetType="ListViewItem"
                       BasedOn="{StaticResource DetailsPage.DataHistory.Value}">
                    <Setter Property="Background"
                            Value="{DynamicResource BackgroundColor.DetailsPage.DataHistory.TitleColumn}" />
                    <Setter Property="Foreground"
                            Value="{DynamicResource FontColor.DetailsPage.DataHistory.Value}" />
                    <Setter Property="FontWeight"
                            Value="Regular" />

                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type ListViewItem}">
                                <Border Margin="0 0.5"
                                        BorderBrush="Transparent"
                                        BorderThickness="0"
                                        Background="{TemplateBinding Background}">
                                    <GridViewRowPresenter Height="30"
                                                          HorizontalAlignment="Stretch"
                                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                          Width="Auto"
                                                          Content="{TemplateBinding Content}" />
                                </Border>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>

                    <Style.Triggers>
                        <Trigger Property="IsMouseOver"
                                 Value="True">
                            <Setter Property="Background"
                                    Value="{DynamicResource HighlightBackgroundColor.DetailsPage.DataHistory.TitleColumn}" />
                            <Setter Property="Foreground"
                                    Value="{DynamicResource FontColor.Menu.Categories.Hover}" />
                        </Trigger>
                        <Trigger Property="IsSelected"
                                 Value="True">
                            <Setter Property="Background"
                                    Value="{DynamicResource HighlightBackgroundColor.DetailsPage.DataHistory.TitleColumn}" />
                            <Setter Property="Foreground"
                                    Value="{DynamicResource FontColor.Menu.Categories.Hover}" />
                        </Trigger>
                    </Style.Triggers>

                </Style>

            </StackPanel.Resources>

            <DockPanel>

                <StackPanel Orientation="Horizontal" DockPanel.Dock="Right" Visibility="{Binding IsCloseButtonVisible, ElementName=DetailedDataUc, Converter={StaticResource BoolToVisibility}}">
                    <ico:AdaptableIcon x:Name="CopyButton" x:FieldModifier="private"
                                   Style="{DynamicResource SettingsPage.Close.Icon}"
                                   SelectedInternIcon="menuBar_copy"
                                   ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=DetailsPage.DetailTable.CopyContent}"
                                   MouseUp="CopyButton_MouseUp" TouchDown="CopyButton_TouchDown"
                                   />
                    <ico:AdaptableIcon x:Name="DownloadButton" x:FieldModifier="private"
                                   Style="{DynamicResource SettingsPage.Close.Icon}"
                                   SelectedMaterialIcon="ic_file_download"
                                   Margin="-12,0,0,0"
                                   ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=DetailsPage.DetailTable.ContentDownload}"
                                   MouseUp="DownloadButton_MouseUp" TouchDown="DownloadButton_TouchDown"
                                   />
                    <ico:AdaptableIcon x:Name="CloseButton"  x:FieldModifier="private"
                                   Style="{DynamicResource SettingsPage.Close.Icon}"
                                   MouseUp="CloseButton_MouseUp"
                                   TouchDown="CloseButton_TouchDown"
                                   SelectedInternIcon="window_close"
                                   Margin="-12,0,0,0"
                                   />
                </StackPanel>

                <ico:AdaptableIcon DockPanel.Dock="Left"                                
                                   VerticalAlignment="Center"
                                   PrimaryIconColor="{DynamicResource Color.FunctionMarker}"
                                   BorderPadding="0"
                                   IconHeight="10"
                                   IconWidth="10" 
                                   SelectedInternIcon="misc_dot" />

                <TextBlock Text="{Binding DetailedInformationData.Heading, ElementName=DetailedDataUc}"
                           DockPanel.Dock="Left"
                           Style="{DynamicResource DetailsPage.DataHistory.TitleColumn.OverviewTitle}"
                           VerticalAlignment="Center"
                           HorizontalAlignment="Left"
                           Margin="10" />

            </DockPanel>

            <ListView x:Name="DetailedDataListView"
                      ItemsSource="{Binding ListViewData, ElementName=DetailedDataUc}"
                      BorderThickness="0"
                      Background="Transparent"
                      PreviewMouseWheel="ListView_PreviewMouseWheel">
            </ListView>

        </StackPanel>

    </Border>

</UserControl>
