<!--
    DrFx - FxCop Report Translator and Visualizer.
    Copyright (C) 2010 Sasa Yuan
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->
    
<Window x:Class="Sasa.QualityTools.DrFx.Explorer.FxCopReportWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:Sasa.QualityTools.DrFx.Explorer"
        xmlns:report="clr-namespace:Sasa.QualityTools.DrFx.Explorer.Report"
        x:Name="root"
        Title="FxCop レポート" Height="700" Width="1000">
    <Grid DataContext="{Binding FxCopReport, ElementName=root}">
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="3*" />
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="5*"/>
            </Grid.ColumnDefinitions>
            <TreeView  Grid.Column="0" ItemsSource="{Binding}">
                <TreeView.Resources>
                    <Style TargetType="TreeViewItem">
                        <EventSetter Event="TreeViewItem.Selected" Handler="ShowIssues"/>
                    </Style>
                    <HierarchicalDataTemplate DataType="{x:Type report:AssemblyWarning}" ItemsSource="{Binding Namespaces}">
                        <StackPanel ToolTip="{Binding FileName}" Orientation="Horizontal">
                            <Image Source="/Resources/assembly.bmp" Margin="3,1,3,1" Width="16"/>
                            <TextBlock Text="{Binding BaseName}" Margin="0,0,3,0" VerticalAlignment="Center"/>
                        </StackPanel>
                    </HierarchicalDataTemplate>
                    <HierarchicalDataTemplate DataType="{x:Type report:NamespaceWarning}" ItemsSource="{Binding Types}">
                        <StackPanel ToolTip="{Binding Name}" Orientation="Horizontal">
                            <Image Source="/Resources/namespace.bmp" Margin="3,1,3,1" Width="16"/>
                            <TextBlock Text="{Binding Name}" Margin="0,0,3,0" VerticalAlignment="Center"/>
                        </StackPanel>
                    </HierarchicalDataTemplate>
                    <HierarchicalDataTemplate DataType="{x:Type report:TypeWarning}" ItemsSource="{Binding Members}">
                        <StackPanel ToolTip="{Binding Name}" Orientation="Horizontal">
                            <Image Source="/Resources/class.bmp" Margin="3,1,3,1" Width="16"/>
                            <TextBlock Text="{Binding Name}" Margin="0,0,3,0" VerticalAlignment="Center"/>
                        </StackPanel>
                    </HierarchicalDataTemplate>
                    <HierarchicalDataTemplate DataType="{x:Type report:MemberWarning}">
                        <StackPanel ToolTip="{Binding Name}" Orientation="Horizontal">
                            <Image Source="/Resources/method.bmp" Margin="3,1,3,1" Width="16"/>
                            <TextBlock Text="{Binding Name}" Margin="0,0,3,0" VerticalAlignment="Center"/>
                        </StackPanel>
                    </HierarchicalDataTemplate>
                </TreeView.Resources>
                <TreeViewItem>
                    <TreeViewItem.Header>
                        <StackPanel ToolTip="{Binding ReportFile}" Orientation="Horizontal">
                            <Image Source="/Resources/xml.bmp" Margin="3,1,3,1" Width="16"/>
                            <TextBlock Text="{Binding ReportFile}" Margin="0,0,3,0" VerticalAlignment="Center"/>
                        </StackPanel>
                    </TreeViewItem.Header>
                    <TreeViewItem ItemsSource="{Binding Assemblies}" VerticalAlignment="Center">
                        <TreeViewItem.Header>
                            <TextBlock ToolTip="アセンブリで定義されている型やメンバーに対する警告。" Margin="3,1,3,1" VerticalAlignment="Center">アセンブリ</TextBlock>
                        </TreeViewItem.Header>
                    </TreeViewItem>
                    <TreeViewItem ItemsSource="{Binding Namespaces}" VerticalAlignment="Center">
                        <TreeViewItem.Header>
                            <TextBlock ToolTip="名前空間に対する警告。複数のアセンブリに同じ名前空間が含まれている可能性があるため、アセンブリのツリーとは別に表示しています。" Margin="3,1,3,1" VerticalAlignment="Center">名前空間</TextBlock>
                        </TreeViewItem.Header>
                    </TreeViewItem>
                </TreeViewItem>
            </TreeView>
            <GridSplitter Grid.Column="1" ResizeBehavior="PreviousAndNext" ResizeDirection="Columns" Background="{x:Static SystemColors.WindowBrush}" Width="5"/>
            <Grid Grid.Column="2" DataContext="{Binding CurrentRelationships, ElementName=root}">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="2*"/>
                </Grid.RowDefinitions>
                <ListBox Name="issueListBox" Grid.Row="0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True" AlternationCount="2" >
                    <ListBox.ItemContainerStyle>
                        <Style TargetType="ListBoxItem">
                            <Style.Triggers>
                                <Trigger Property="ItemsControl.AlternationIndex" Value="1">
                                    <Setter Property="Background" Value="#eeeeff"/>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </ListBox.ItemContainerStyle>
                    <ListBox.ItemTemplate>
                        <DataTemplate DataType="report'FxCopIssueRelationship">
                            <Grid Grid.Row="0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <Image Grid.Column="0" Source="/Resources/warning.bmp" Margin="3,1,3,1" Width="16"/>
                                <TextBlock Grid.Column="1" Text="{Binding Issue.Content}" TextWrapping="Wrap" Margin="5"/>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
                <GridSplitter Grid.Row="1" ResizeBehavior="PreviousAndNext" ResizeDirection="Rows" Background="{x:Static SystemColors.WindowBrush}" Height="5" HorizontalAlignment="Stretch"/>
                <local:FxCopIssueDetailWidget Grid.Row="2" FxCopIssueRelationship="{Binding SelectedItem, ElementName=issueListBox}"/>
            </Grid>
        </Grid>
        <StatusBar Grid.Row="1">
        </StatusBar>
    </Grid>
</Window>
