<local:DependencyCustomListView x:Class="Dependencies.DependencyImportList"
        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:Dependencies"
        xmlns:util="clr-namespace:Wpf.Util"
        xmlns:properties="clr-namespace:Dependencies.Properties"
        mc:Ignorable="d" 
        d:DesignHeight="300" d:DesignWidth="300"

        Style="{StaticResource DependencyCustomListViewStyle}"
        SearchListFilter="FilterName"
        CopyHandler="ImportCopyHandler"
    >

    <local:DependencyCustomListView.CommandBindings>
        <CommandBinding Command="local:DependencyImportList.CopyValuesCommand" Executed="ImportListCopySelectedValues"></CommandBinding>
    </local:DependencyCustomListView.CommandBindings>

    <local:DependencyCustomListView.Resources>
        <ContextMenu x:Key="ItemContextMenu">
            <MenuItem Header = "Copy"
                                Command="local:DependencyImportList.CopyValuesCommand"
                                InputGestureText="Ctrl+C"  
                                IsEnabled="True"/>
            <MenuItem HeaderStringFormat= "Copy {0:s}"
                                Header = "{Binding DataContext.Name, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Grid}}"
                                Command="{Binding Path=DataContext.CopyValue, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Grid},AncestorLevel=1 }}"
                                CommandParameter ="{Binding DataContext.Name, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Grid }}"
                                InputGestureText="Ctrl+Maj+C"  
                                IsEnabled="True"/>
            <MenuItem Header="Select All" 
                                Command="ApplicationCommands.SelectAll" 
                                IsEnabled="True"/>
            <Separator Height="3" Margin="-1,0,0,0"/>
            <MenuItem Header="_Undecorate C++ Functions" 
                                Height="26" InputGestureText="F10" 
                                IsCheckable="True" IsChecked="{Binding Source={x:Static properties:Settings.Default}, Path=Undecorate, Mode=TwoWay }"/>
            <Separator Height="3" Margin="-1,0,0,0"/>
            <MenuItem Header="Lookup Import function on MSDN"  
                            Command="{Binding Path=DataContext.QueryImportApi, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Grid},AncestorLevel=1 }}"
                            CommandParameter ="{Binding DataContext , RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Grid}}"
                            InputGestureText="Alt+Enter"  
                            IsEnabled="True" />
        </ContextMenu>
    </local:DependencyCustomListView.Resources>


    <local:DependencyCustomListView.View>
        <GridView AllowsColumnReorder="true">
            <GridViewColumn Width="40" Header="PI" util:GridViewSort.PropertyName="Type" >
                <GridViewColumn.HeaderContainerStyle>
                    <Style TargetType="{x:Type GridViewColumnHeader}">
                        <Setter Property="Control.ToolTip" Value="Selected's module imports"/>
                        <Setter Property="HorizontalContentAlignment" Value="Left"></Setter>
                        <Setter Property="Padding" Value="5,0,0,0"></Setter>
                    </Style>
                </GridViewColumn.HeaderContainerStyle>
                
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <Image Width="30" Height="14" Source="{Binding IconUri}"/>
                    </DataTemplate>
                </GridViewColumn.CellTemplate>
            </GridViewColumn>
            <GridViewColumn Header="Ordinal" Width="140" util:GridViewSort.PropertyName="Ordinal" HeaderContainerStyle="{StaticResource LeftAlignHeader}">
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Ordinal, StringFormat={}{0} (0x{0:x04}), TargetNullValue='N/A' }" TextAlignment="Right" />
                    </DataTemplate>
                </GridViewColumn.CellTemplate>
            </GridViewColumn>
            <GridViewColumn Header="Hint" Width="140" util:GridViewSort.PropertyName="Hint" HeaderContainerStyle="{StaticResource LeftAlignHeader}">
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Hint, StringFormat={}{0} (0x{0:x04}), TargetNullValue='N/A' }" TextAlignment="Right" />
                    </DataTemplate>
                </GridViewColumn.CellTemplate>
            </GridViewColumn>
            <GridViewColumn Header="Function" Width="250" DisplayMemberBinding="{Binding Name}" util:GridViewSort.PropertyName="Name" HeaderContainerStyle="{StaticResource LeftAlignHeader}"/>
            <GridViewColumn Header="Module" Width="300" DisplayMemberBinding="{Binding ModuleName}" util:GridViewSort.PropertyName="ModuleName" HeaderContainerStyle="{StaticResource LeftAlignHeader}"/>
            <GridViewColumn Header="Delayed" Width="100" DisplayMemberBinding="{Binding DelayImport}" util:GridViewSort.PropertyName="DelayImport" HeaderContainerStyle="{StaticResource LeftAlignHeader}"/>
            <GridViewColumn Header="Demangler" Width="250" DisplayMemberBinding="{Binding Demangler}" util:GridViewSort.PropertyName="Name" HeaderContainerStyle="{StaticResource LeftAlignHeader}"/>
        </GridView>
    </local:DependencyCustomListView.View>
</local:DependencyCustomListView>
