<commit_before>﻿<Window x:Class="FAManagementStudio.Views.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        xmlns:local="clr-namespace:FAManagementStudio"
        xmlns:Common="clr-namespace:FAManagementStudio.Common"
        xmlns:b="clr-namespace:FAManagementStudio.Views.Behaviors"
        xmlns:c="clr-namespace:FAManagementStudio.Views.Converters"
        xmlns:vm="clr-namespace:FAManagementStudio.ViewModels"
        xmlns:controls="clr-namespace:FAManagementStudio.Controls;assembly=FAManagementStudio.Controls"
        xmlns:core="clr-namespace:System;assembly=mscorlib"
        mc:Ignorable="d"
        Title="FAManagementStudio" Height="700" Width="1000" Icon="../Image/systemicon.ico" Loaded="Window_Loaded">
    <Window.Resources>
        <vm:MainViewModel x:Key="viewModel"/>
        <Style x:Key="VirticalSpliterStyle" TargetType="GridSplitter">
            <Setter Property="Width" Value="2"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="VerticalAlignment" Value="Stretch"/>
            <Setter Property="ResizeDirection" Value="Columns"/>
        </Style>
        <Style x:Key="HorizontalSpliterStyle" TargetType="GridSplitter">
            <Setter Property="Height" Value="2"/>
            <Setter Property="HorizontalAlignment" Value="Stretch"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="ResizeDirection" Value="Rows"/>
        </Style>
    </Window.Resources>
    <Window.DataContext>
        <StaticResourceExtension ResourceKey="viewModel" />
    </Window.DataContext>
    <i:Interaction.Behaviors>
        <b:WindowBehavior LoadedCommand="{Binding LoadHistry}" ClosedCommand="{Binding SaveHistry}"/>
    </i:Interaction.Behaviors>

    <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="22"/>
            <RowDefinition Height="1*"/>
        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*"/>
                <ColumnDefinition Width="20"/>
            </Grid.ColumnDefinitions>
            <StackPanel Grid.Row="0"  Orientation="Horizontal">
                <Button Command="{Binding CreateDatabase}">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="../Image/action_add_16xLG.png" />
                        <TextBlock Text="新規" Margin="4,0"/>
                    </StackPanel>
                </Button>
                <ComboBox Name="DbPathComb" Height="auto" Width="300" IsEditable="True" IsTextSearchEnabled="True" IsReadOnly="False" ItemsSource="{Binding DataInput}" Text="{Binding InputPath, Mode=TwoWay}" AllowDrop="True">
                    <i:Interaction.Behaviors>
                        <b:FileDropBehavior DropedCommand="{Binding DropFile}"/>
                    </i:Interaction.Behaviors>
                </ComboBox>
                <Button Command="{Binding LoadDatabase}" CommandParameter="{Binding ElementName=DbPathComb, Path=Text }">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="../Image/hardware_16xLG.png" />
                        <TextBlock Text="読込" Margin="4,0"/>
                    </StackPanel>
                </Button>
                <Button Command="{Binding ExecuteQuery}" ToolTip="F5 実行">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="../Image/base_exclamationmark_32.png" />
                        <TextBlock Text="実行" Margin="4,0"/>
                    </StackPanel>
                </Button>
                <TextBlock Text="{Binding CurrentDatabase.Path}" VerticalAlignment="Center" />
            </StackPanel>
            <Button Grid.Column="1" Command="{Binding OpenGitPage}">
                <TextBlock>
                    <Bold>？</Bold>
                </TextBlock>
            </Button>
        </Grid>
        <Grid Grid.Row="1" HorizontalAlignment="Stretch">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="80" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="170" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="1*" />
            </Grid.ColumnDefinitions>
            <ListBox Grid.Column="0" HorizontalAlignment="Stretch" MinWidth="80" ItemsSource="{Binding Databases}" HorizontalContentAlignment="Center" SelectedItem="{Binding CurrentDatabase}" AllowDrop="True" ToolTip="データベースファイルをドロップ" >
                <ListBox.Resources>
                    <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="{DynamicResource {x:Static SystemColors.HighlightColorKey}}" />
                </ListBox.Resources>
                <ListBox.ItemContainerStyle>
                    <Style>
                        <Style.Triggers>
                            <Trigger Property="Selector.IsSelected" Value="True">
                                <Setter Property="TextElement.Foreground" Value="White"/>
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </ListBox.ItemContainerStyle>
                <i:Interaction.Behaviors>
                    <b:ListBoxDropBehavior DropedCommand="{Binding DbListDropFile}"/>
                </i:Interaction.Behaviors>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Canvas Height="70" Width="50" ToolTip="{Binding Path}">
                            <Canvas.ContextMenu>
                                <ContextMenu>
                                    <MenuItem Header="再読み込み" Command="{Binding ReloadDatabase, Source={StaticResource viewModel}}"/>
                                    <MenuItem Header="切断" Command="{Binding ShutdownDatabase, Source={StaticResource viewModel}}"/>
                                </ContextMenu>
                            </Canvas.ContextMenu>
                            <Image Source="../Image/DbShape.png" Height="50" Width="50" Margin="0,3,0,0"/>
                            <TextBlock Text="{Binding DisplayDbName}" Canvas.Top="50" TextAlignment="Center" Margin="-15,2,0,0" Width="80" />
                        </Canvas>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            <GridSplitter Grid.Column="1" Style="{StaticResource VirticalSpliterStyle}" />
            <Grid Grid.Column="2" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="1*"/>
                    <RowDefinition Height="2"/>
                    <RowDefinition Height="150"/>
                </Grid.RowDefinitions>
                <TreeView Grid.Row="0" MinWidth="170" ItemsSource="{Binding Tables}">
                    <i:Interaction.Behaviors>
                        <b:TreeViewSelectedItemBehavior SelectedItem="{Binding SelectedTableItem, Mode=TwoWay}" />
                    </i:Interaction.Behaviors>
                    <TreeView.Resources>
                        <c:ConstraintsKeyToIconConverter x:Key="KeyConverter"/>
                        <ContextMenu x:Key="contextMenu">
                            <MenuItem Header="SELECT *" Command="{Binding SetSqlTemplate, Source={StaticResource viewModel}}" CommandParameter="select" />
                            <MenuItem Header="INSERT *" Command="{Binding SetSqlTemplate, Source={StaticResource viewModel}}" CommandParameter="insert" />
                            <MenuItem Header="UPDATE *" Command="{Binding SetSqlTemplate, Source={StaticResource viewModel}}" CommandParameter="update" />
                            <MenuItem Header="Reverse DB(開発中)">
                                <MenuItem Header="CREATE TABLE(仮)" Command="{Binding SetSqlDataTemplate, Source={StaticResource viewModel}}" CommandParameter="table"/>
                                <MenuItem Header="INSERT(仮)" Command="{Binding SetSqlDataTemplate, Source={StaticResource viewModel}}" CommandParameter="insert"/>
                            </MenuItem>
                        </ContextMenu>
                    </TreeView.Resources>
                    <TreeView.ItemContainerStyle>
                        <Style TargetType="{x:Type TreeViewItem}">
                            <EventSetter Event="TreeViewItem.MouseRightButtonDown" Handler="TreeViewItem_MouseRightButtonDown"/>
                        </Style>
                    </TreeView.ItemContainerStyle>
                    <TreeView.ItemTemplate >
                        <HierarchicalDataTemplate ItemsSource="{Binding Colums}">
                            <TextBlock Text="{Binding Path=DisplayName}" ContextMenu="{StaticResource contextMenu}"/>
                            <HierarchicalDataTemplate.ItemTemplate>
                                <HierarchicalDataTemplate >
                                    <StackPanel Orientation="Horizontal" Margin="-11,0,0,0" ContextMenu="{StaticResource contextMenu}">
                                        <Image Source="{Binding KeyKind, Converter={StaticResource KeyConverter}}" Width="11" Stretch="Uniform"/>
                                        <TextBlock Text="{Binding Path=DisplayName}" />
                                    </StackPanel>
                                </HierarchicalDataTemplate>
                            </HierarchicalDataTemplate.ItemTemplate>
                        </HierarchicalDataTemplate>
                    </TreeView.ItemTemplate>
                </TreeView>
                <GridSplitter Grid.Row="1" Style="{StaticResource HorizontalSpliterStyle}" />
                <ListBox Grid.Row="2" ItemsSource="{Binding Triggers}" >
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" ToolTip="{Binding Source}">
                                <TextBlock Text="{Binding TableName}" Width="50"/>
                                <TextBlock Text="{Binding Name}"/>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </Grid>
            <GridSplitter Grid.Column="3" Style="{StaticResource VirticalSpliterStyle}"  />
            <Grid x:Name="ResultGrid" Grid.Column="4">
                <Grid.RowDefinitions>
                    <RowDefinition Height="150"/>
                    <RowDefinition Height="4"/>
                    <RowDefinition Name="ResultRow" Height="1*"/>
                </Grid.RowDefinitions>
                <TabControl x:Name="QueryTab" Grid.Row="0" ItemsSource="{Binding Queries}" SelectedIndex="{Binding TagSelectedIndex, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,IsAsync=False}" SelectedValue="{Binding TagSelectedValue, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  >
                    <i:Interaction.Behaviors>
                        <b:DynamicTabControlBehavior AddTabCommand="{Binding AddTab}"/>
                    </i:Interaction.Behaviors>
                    <TabControl.ContextMenu>
                        <ContextMenu >
                            <MenuItem Header="削除" Command="{Binding DeleteTabItem}"/>
                        </ContextMenu>
                    </TabControl.ContextMenu>
                    <TabControl.Resources>
                        <Style TargetType="{x:Type TabItem}">
                            <EventSetter Event="TabItem.MouseRightButtonDown" Handler="TabItem_MouseRightButtonDown"/>
                        </Style>
                        <Common:CommandReference x:Key="Execute" Command="{Binding ExecuteQuery}"/>
                    </TabControl.Resources>
                    <TabControl.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Header}" />
                        </DataTemplate>
                    </TabControl.ItemTemplate>
                    <TabControl.ContentTemplate>
                        <DataTemplate>
                            <TextBox  Text="{Binding Query, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" AcceptsReturn="True" TextWrapping="Wrap" Margin="0,2" Grid.RowSpan="2" VerticalScrollBarVisibility="Auto">
                                <TextBox.InputBindings>
                                    <KeyBinding Key="F5" Command="{StaticResource Execute}" />
                                </TextBox.InputBindings>
                            </TextBox>
                        </DataTemplate>
                    </TabControl.ContentTemplate>
                </TabControl>
                <GridSplitter Grid.Row="1" Style="{StaticResource HorizontalSpliterStyle}" />
                <TabControl Grid.Row="2" ItemsSource="{Binding Datasource}"  SelectedIndex="{Binding SelectedResultIndex}" >
                    <TabControl.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Header}" />
                                <controls:PinButton Margin="3,0,0,0" PinCommand="{Binding DataContext.PinCommand, RelativeSource={RelativeSource AncestorType=Window}}" PinedCommand="{Binding DataContext.PinedCommand, RelativeSource={RelativeSource AncestorType=Window}}"/>
                            </StackPanel>
                        </DataTemplate>
                    </TabControl.ItemTemplate>
                    <TabControl.ContentTemplate>
                        <DataTemplate>
                            <ListBox ItemsSource="{Binding Result}" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.CanContentScroll="False">
                                <ListBox.Resources>
                                    <c:GridHightSizeConverter x:Key="HeightConverter"/>
                                    <c:GridWidthSizeConverter x:Key="WidthConverter"/>
                                </ListBox.Resources>
                                <ListBox.ItemContainerStyle>
                                    <Style TargetType="{x:Type ListBoxItem}">
                                        <Setter Property="Focusable" Value="False"/>
                                    </Style>
                                </ListBox.ItemContainerStyle>
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Vertical" Margin="0,0,0,10">
                                            <toolkit:DataGrid Name="ResultView" HorizontalAlignment="Stretch"
                                                ItemsSource="{Binding View}" Margin="0,0,0,0" EnableColumnVirtualization="True" EnableRowVirtualization="True"
                                                VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling" 
                                                CanUserAddRows="False" CanUserDeleteRows="False"
                                                MaxWidth="{Binding Path=ActualWidth, ElementName=ResultGrid, Converter={StaticResource WidthConverter}}"
                                                Width="{Binding MaxWidth, RelativeSource={RelativeSource Self}}"
                                                MaxHeight="{Binding Path=ActualHeight, ElementName=ResultRow, Converter={StaticResource HeightConverter}}"
                                                IsReadOnly="True">
                                                <toolkit:DataGrid.ContextMenu>
                                                    <ContextMenu>
                                                        <MenuItem Header="結果を保存 CSV(ヘッダ含)" Command="{Binding OutputCsv}" >
                                                            <MenuItem.CommandParameter>
                                                                <core:Boolean>True</core:Boolean>
                                                            </MenuItem.CommandParameter>
                                                        </MenuItem>
                                                        <MenuItem Header="結果を保存 CSV(ヘッダ無)" Command="{Binding OutputCsv}" >
                                                            <MenuItem.CommandParameter>
                                                                <core:Boolean>False</core:Boolean>
                                                            </MenuItem.CommandParameter>
                                                        </MenuItem>
                                                    </ContextMenu>
                                                </toolkit:DataGrid.ContextMenu>
                                            </toolkit:DataGrid>
                                            <TextBlock Text="{Binding AdditionalInfo}" TextDecorations="Underline" TextWrapping="Wrap" MaxWidth="{Binding MaxWidth, ElementName=ResultView}" Foreground="Gray" Margin="5,0,0,0"/>
                                        </StackPanel>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </DataTemplate>
                    </TabControl.ContentTemplate>
                </TabControl>
            </Grid>
        </Grid>
    </Grid>
</Window>
<commit_msg>shutdown at the delete key<commit_after>﻿<Window x:Class="FAManagementStudio.Views.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        xmlns:local="clr-namespace:FAManagementStudio"
        xmlns:Common="clr-namespace:FAManagementStudio.Common"
        xmlns:b="clr-namespace:FAManagementStudio.Views.Behaviors"
        xmlns:c="clr-namespace:FAManagementStudio.Views.Converters"
        xmlns:vm="clr-namespace:FAManagementStudio.ViewModels"
        xmlns:controls="clr-namespace:FAManagementStudio.Controls;assembly=FAManagementStudio.Controls"
        xmlns:core="clr-namespace:System;assembly=mscorlib"
        mc:Ignorable="d"
        Title="FAManagementStudio" Height="700" Width="1000" Icon="../Image/systemicon.ico" Loaded="Window_Loaded">
    <Window.Resources>
        <vm:MainViewModel x:Key="viewModel"/>
        <Style x:Key="VirticalSpliterStyle" TargetType="GridSplitter">
            <Setter Property="Width" Value="2"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="VerticalAlignment" Value="Stretch"/>
            <Setter Property="ResizeDirection" Value="Columns"/>
        </Style>
        <Style x:Key="HorizontalSpliterStyle" TargetType="GridSplitter">
            <Setter Property="Height" Value="2"/>
            <Setter Property="HorizontalAlignment" Value="Stretch"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="ResizeDirection" Value="Rows"/>
        </Style>
    </Window.Resources>
    <Window.DataContext>
        <StaticResourceExtension ResourceKey="viewModel" />
    </Window.DataContext>
    <i:Interaction.Behaviors>
        <b:WindowBehavior LoadedCommand="{Binding LoadHistry}" ClosedCommand="{Binding SaveHistry}"/>
    </i:Interaction.Behaviors>

    <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="22"/>
            <RowDefinition Height="1*"/>
        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*"/>
                <ColumnDefinition Width="20"/>
            </Grid.ColumnDefinitions>
            <StackPanel Grid.Row="0"  Orientation="Horizontal">
                <Button Command="{Binding CreateDatabase}">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="../Image/action_add_16xLG.png" />
                        <TextBlock Text="新規" Margin="4,0"/>
                    </StackPanel>
                </Button>
                <ComboBox Name="DbPathComb" Height="auto" Width="300" IsEditable="True" IsTextSearchEnabled="True" IsReadOnly="False" ItemsSource="{Binding DataInput}" Text="{Binding InputPath, Mode=TwoWay}" AllowDrop="True">
                    <i:Interaction.Behaviors>
                        <b:FileDropBehavior DropedCommand="{Binding DropFile}"/>
                    </i:Interaction.Behaviors>
                </ComboBox>
                <Button Command="{Binding LoadDatabase}" CommandParameter="{Binding ElementName=DbPathComb, Path=Text }">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="../Image/hardware_16xLG.png" />
                        <TextBlock Text="読込" Margin="4,0"/>
                    </StackPanel>
                </Button>
                <Button Command="{Binding ExecuteQuery}" ToolTip="F5 実行">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="../Image/base_exclamationmark_32.png" />
                        <TextBlock Text="実行" Margin="4,0"/>
                    </StackPanel>
                </Button>
                <TextBlock Text="{Binding CurrentDatabase.Path}" VerticalAlignment="Center" />
            </StackPanel>
            <Button Grid.Column="1" Command="{Binding OpenGitPage}">
                <TextBlock>
                    <Bold>？</Bold>
                </TextBlock>
            </Button>
        </Grid>
        <Grid Grid.Row="1" HorizontalAlignment="Stretch">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="80" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="170" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="1*" />
            </Grid.ColumnDefinitions>
            <ListBox Grid.Column="0" HorizontalAlignment="Stretch" MinWidth="80" ItemsSource="{Binding Databases}" HorizontalContentAlignment="Center" SelectedItem="{Binding CurrentDatabase}" AllowDrop="True" ToolTip="データベースファイルをドロップ" >
                <ListBox.Resources>
                    <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="{DynamicResource {x:Static SystemColors.HighlightColorKey}}" />
                    <Common:CommandReference x:Key="Shutdown" Command="{Binding ShutdownDatabase, Source={StaticResource viewModel}}"/>
                </ListBox.Resources>
                <ListBox.ItemContainerStyle>
                    <Style>
                        <Style.Triggers>
                            <Trigger Property="Selector.IsSelected" Value="True">
                                <Setter Property="TextElement.Foreground" Value="White"/>
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </ListBox.ItemContainerStyle>
                <ListBox.InputBindings>
                    <KeyBinding Command="{StaticResource Shutdown}" Key="Delete"/>
                </ListBox.InputBindings>
                <i:Interaction.Behaviors>
                    <b:ListBoxDropBehavior DropedCommand="{Binding DbListDropFile}"/>
                </i:Interaction.Behaviors>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Canvas Height="70" Width="50" ToolTip="{Binding Path}">
                            <Canvas.ContextMenu>
                                <ContextMenu>
                                    <MenuItem Header="再読み込み" Command="{Binding ReloadDatabase, Source={StaticResource viewModel}}"/>
                                    <MenuItem Header="切断" Command="{Binding ShutdownDatabase, Source={StaticResource viewModel}}"/>
                                </ContextMenu>
                            </Canvas.ContextMenu>
                            <Image Source="../Image/DbShape.png" Height="50" Width="50" Margin="0,3,0,0"/>
                            <TextBlock Text="{Binding DisplayDbName}" Canvas.Top="50" TextAlignment="Center" Margin="-15,2,0,0" Width="80" />
                        </Canvas>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            <GridSplitter Grid.Column="1" Style="{StaticResource VirticalSpliterStyle}" />
            <Grid Grid.Column="2" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="1*"/>
                    <RowDefinition Height="2"/>
                    <RowDefinition Height="150"/>
                </Grid.RowDefinitions>
                <TreeView Grid.Row="0" MinWidth="170" ItemsSource="{Binding Tables}">
                    <i:Interaction.Behaviors>
                        <b:TreeViewSelectedItemBehavior SelectedItem="{Binding SelectedTableItem, Mode=TwoWay}" />
                    </i:Interaction.Behaviors>
                    <TreeView.Resources>
                        <c:ConstraintsKeyToIconConverter x:Key="KeyConverter"/>
                        <ContextMenu x:Key="contextMenu">
                            <MenuItem Header="SELECT *" Command="{Binding SetSqlTemplate, Source={StaticResource viewModel}}" CommandParameter="select" />
                            <MenuItem Header="INSERT *" Command="{Binding SetSqlTemplate, Source={StaticResource viewModel}}" CommandParameter="insert" />
                            <MenuItem Header="UPDATE *" Command="{Binding SetSqlTemplate, Source={StaticResource viewModel}}" CommandParameter="update" />
                            <MenuItem Header="Reverse DB(開発中)">
                                <MenuItem Header="CREATE TABLE(仮)" Command="{Binding SetSqlDataTemplate, Source={StaticResource viewModel}}" CommandParameter="table"/>
                                <MenuItem Header="INSERT(仮)" Command="{Binding SetSqlDataTemplate, Source={StaticResource viewModel}}" CommandParameter="insert"/>
                            </MenuItem>
                        </ContextMenu>
                    </TreeView.Resources>
                    <TreeView.ItemContainerStyle>
                        <Style TargetType="{x:Type TreeViewItem}">
                            <EventSetter Event="TreeViewItem.MouseRightButtonDown" Handler="TreeViewItem_MouseRightButtonDown"/>
                        </Style>
                    </TreeView.ItemContainerStyle>
                    <TreeView.ItemTemplate >
                        <HierarchicalDataTemplate ItemsSource="{Binding Colums}">
                            <TextBlock Text="{Binding Path=DisplayName}" ContextMenu="{StaticResource contextMenu}"/>
                            <HierarchicalDataTemplate.ItemTemplate>
                                <HierarchicalDataTemplate >
                                    <StackPanel Orientation="Horizontal" Margin="-11,0,0,0" ContextMenu="{StaticResource contextMenu}">
                                        <Image Source="{Binding KeyKind, Converter={StaticResource KeyConverter}}" Width="11" Stretch="Uniform"/>
                                        <TextBlock Text="{Binding Path=DisplayName}" />
                                    </StackPanel>
                                </HierarchicalDataTemplate>
                            </HierarchicalDataTemplate.ItemTemplate>
                        </HierarchicalDataTemplate>
                    </TreeView.ItemTemplate>
                </TreeView>
                <GridSplitter Grid.Row="1" Style="{StaticResource HorizontalSpliterStyle}" />
                <ListBox Grid.Row="2" ItemsSource="{Binding Triggers}" >
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" ToolTip="{Binding Source}">
                                <TextBlock Text="{Binding TableName}" Width="50"/>
                                <TextBlock Text="{Binding Name}"/>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </Grid>
            <GridSplitter Grid.Column="3" Style="{StaticResource VirticalSpliterStyle}"  />
            <Grid x:Name="ResultGrid" Grid.Column="4">
                <Grid.RowDefinitions>
                    <RowDefinition Height="150"/>
                    <RowDefinition Height="4"/>
                    <RowDefinition Name="ResultRow" Height="1*"/>
                </Grid.RowDefinitions>
                <TabControl x:Name="QueryTab" Grid.Row="0" ItemsSource="{Binding Queries}" SelectedIndex="{Binding TagSelectedIndex, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,IsAsync=False}" SelectedValue="{Binding TagSelectedValue, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  >
                    <i:Interaction.Behaviors>
                        <b:DynamicTabControlBehavior AddTabCommand="{Binding AddTab}"/>
                    </i:Interaction.Behaviors>
                    <TabControl.ContextMenu>
                        <ContextMenu >
                            <MenuItem Header="削除" Command="{Binding DeleteTabItem}"/>
                        </ContextMenu>
                    </TabControl.ContextMenu>
                    <TabControl.Resources>
                        <Style TargetType="{x:Type TabItem}">
                            <EventSetter Event="TabItem.MouseRightButtonDown" Handler="TabItem_MouseRightButtonDown"/>
                        </Style>
                        <Common:CommandReference x:Key="Execute" Command="{Binding ExecuteQuery}"/>
                    </TabControl.Resources>
                    <TabControl.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Header}" />
                        </DataTemplate>
                    </TabControl.ItemTemplate>
                    <TabControl.ContentTemplate>
                        <DataTemplate>
                            <TextBox  Text="{Binding Query, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" AcceptsReturn="True" TextWrapping="Wrap" Margin="0,2" Grid.RowSpan="2" VerticalScrollBarVisibility="Auto">
                                <TextBox.InputBindings>
                                    <KeyBinding Key="F5" Command="{StaticResource Execute}" />
                                </TextBox.InputBindings>
                            </TextBox>
                        </DataTemplate>
                    </TabControl.ContentTemplate>
                </TabControl>
                <GridSplitter Grid.Row="1" Style="{StaticResource HorizontalSpliterStyle}" />
                <TabControl Grid.Row="2" ItemsSource="{Binding Datasource}"  SelectedIndex="{Binding SelectedResultIndex}" >
                    <TabControl.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Header}" />
                                <controls:PinButton Margin="3,0,0,0" PinCommand="{Binding DataContext.PinCommand, RelativeSource={RelativeSource AncestorType=Window}}" PinedCommand="{Binding DataContext.PinedCommand, RelativeSource={RelativeSource AncestorType=Window}}"/>
                            </StackPanel>
                        </DataTemplate>
                    </TabControl.ItemTemplate>
                    <TabControl.ContentTemplate>
                        <DataTemplate>
                            <ListBox ItemsSource="{Binding Result}" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.CanContentScroll="False">
                                <ListBox.Resources>
                                    <c:GridHightSizeConverter x:Key="HeightConverter"/>
                                    <c:GridWidthSizeConverter x:Key="WidthConverter"/>
                                </ListBox.Resources>
                                <ListBox.ItemContainerStyle>
                                    <Style TargetType="{x:Type ListBoxItem}">
                                        <Setter Property="Focusable" Value="False"/>
                                    </Style>
                                </ListBox.ItemContainerStyle>
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Vertical" Margin="0,0,0,10">
                                            <toolkit:DataGrid Name="ResultView" HorizontalAlignment="Stretch"
                                                ItemsSource="{Binding View}" Margin="0,0,0,0" EnableColumnVirtualization="True" EnableRowVirtualization="True"
                                                VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling" 
                                                CanUserAddRows="False" CanUserDeleteRows="False"
                                                MaxWidth="{Binding Path=ActualWidth, ElementName=ResultGrid, Converter={StaticResource WidthConverter}}"
                                                Width="{Binding MaxWidth, RelativeSource={RelativeSource Self}}"
                                                MaxHeight="{Binding Path=ActualHeight, ElementName=ResultRow, Converter={StaticResource HeightConverter}}"
                                                IsReadOnly="True">
                                                <toolkit:DataGrid.ContextMenu>
                                                    <ContextMenu>
                                                        <MenuItem Header="結果を保存 CSV(ヘッダ含)" Command="{Binding OutputCsv}" >
                                                            <MenuItem.CommandParameter>
                                                                <core:Boolean>True</core:Boolean>
                                                            </MenuItem.CommandParameter>
                                                        </MenuItem>
                                                        <MenuItem Header="結果を保存 CSV(ヘッダ無)" Command="{Binding OutputCsv}" >
                                                            <MenuItem.CommandParameter>
                                                                <core:Boolean>False</core:Boolean>
                                                            </MenuItem.CommandParameter>
                                                        </MenuItem>
                                                    </ContextMenu>
                                                </toolkit:DataGrid.ContextMenu>
                                            </toolkit:DataGrid>
                                            <TextBlock Text="{Binding AdditionalInfo}" TextDecorations="Underline" TextWrapping="Wrap" MaxWidth="{Binding MaxWidth, ElementName=ResultView}" Foreground="Gray" Margin="5,0,0,0"/>
                                        </StackPanel>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </DataTemplate>
                    </TabControl.ContentTemplate>
                </TabControl>
            </Grid>
        </Grid>
    </Grid>
</Window>

{'fraction_non_alphanumeric': 0.10738458988313948, 'fraction_numerical': 0.007569688095698538, 'mean_word_length': 1.5218057684269193, 'pattern_counts': {'":': 0, '<': 507, '<?xml version=': 0, '>': 507, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 28}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 128, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4028350', 'n_tokens_mistral': 8493, 'n_tokens_neox': 7740, 'n_words': 1218}