<commit_before>﻿<UserControl x:Class="tomenglertde.ResXManager.View.Visuals.ResourceView"
             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" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="700"
             xmlns:dgx="clr-namespace:DataGridExtensions;assembly=DataGridExtensions"
             xmlns:windows="clr-namespace:System.Windows;assembly=PresentationFramework"
             xmlns:model="urn:ResXManager.Model"
             xmlns:properties="clr-namespace:tomenglertde.ResXManager.View.Properties"
             xmlns:converters="clr-namespace:tomenglertde.ResXManager.View.Converters"
             xmlns:columnHeaders="clr-namespace:tomenglertde.ResXManager.View.ColumnHeaders"
             xmlns:tools="clr-namespace:tomenglertde.ResXManager.View.Tools"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:behaviors="clr-namespace:tomenglertde.ResXManager.View.Behaviors"
             x:Name="LayoutRoot"
             UseLayoutRounding="True" TextOptions.TextFormattingMode="Display"
             d:DataContext="{d:DesignInstance model:ResourceManager}">
  <UserControl.Resources>

    <converters:ConfirmedCommandConverter x:Key="DeleteCommandConverter" Executing="DeleteCommandConverter_OnExecuting" />
    <converters:ConfirmedCommandConverter x:Key="CutCommandConverter" Executing="CutCommandConverter_OnExecuting" />

    <Style TargetType="{x:Type Control}" x:Key="SingleSelectElementStyle">
      <Setter Property="IsEnabled" Value="False" />
      <Setter Property="Opacity" Value="0.5" />
      <Style.Triggers>
        <DataTrigger Binding="{Binding Path=SelectedItems.Count, ElementName=ListBox}" Value="1">
          <Setter Property="IsEnabled" Value="True" />
          <Setter Property="Opacity" Value="1" />
        </DataTrigger>
      </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type Control}" x:Key="ToolbarCommandButtonStyle">
      <Style.Triggers>
        <Trigger Property="IsEnabled" Value="False">
          <Setter Property="Opacity" Value="0.5" />
        </Trigger>
      </Style.Triggers>
    </Style>

    <CollectionViewSource x:Key="ResourceEntitiesSource" Source="{Binding FilteredResourceEntities}">
      <CollectionViewSource.GroupDescriptions>
        <PropertyGroupDescription PropertyName="ProjectName" />
      </CollectionViewSource.GroupDescriptions>
    </CollectionViewSource>

    <CollectionViewSource x:Key="GroupedResourceTableEntriesSource" Source="{Binding ResourceTableEntries}">
      <CollectionViewSource.GroupDescriptions>
        <PropertyGroupDescription PropertyName="Owner" />
      </CollectionViewSource.GroupDescriptions>
    </CollectionViewSource>

  </UserControl.Resources>
  <UserControl.InputBindings>
    <KeyBinding Key="N" Modifiers="Control" Command="{Binding Converter={x:Static converters:AddNewKeyCommandConverter.Default}}" />
  </UserControl.InputBindings>
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="Auto" MinWidth="120" />
      <ColumnDefinition Width="Auto" />
      <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <DockPanel Grid.Column="0">
      <Grid DockPanel.Dock="Top" Background="{x:Static windows:SystemColors.MenuBrush}">
        <DockPanel Margin="0,5">
          <StackPanel Orientation="Horizontal" DockPanel.Dock="Left">
            <Decorator Width="16" />
            <CheckBox VerticalAlignment="Center" IsChecked="{Binding AreAllFilesSelected}" IsThreeState="True" />
            <Decorator Width="7" />
          </StackPanel>
          <Border Background="{x:Static SystemColors.WindowBrush}">
            <DockPanel>
              <StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
                <Decorator Width="3" />
                <Path Data="M0,0 L10,0 6,4 6,9 4,9 4,4 Z" Fill="Gray"
                      VerticalAlignment="Center" HorizontalAlignment="Right" Margin="2,0" />
              </StackPanel>
              <TextBox ToolTip="{x:Static properties:Resources.ResourceFilterToolTip}" BorderThickness="0"
                       Text="{Binding EntityFilter, UpdateSourceTrigger=PropertyChanged}" />
            </DockPanel>
          </Border>
        </DockPanel>
      </Grid>
      <ListBox x:Name="ListBox"
               ItemsSource="{Binding Source={StaticResource ResourceEntitiesSource}}"
               Margin="5" BorderThickness="0" SelectionMode="Extended"
               tools:MultiSelectorExtensions.SelectionBinding="{Binding SelectedEntities}">
        <ListBox.ContextMenu>
          <ContextMenu>
            <MenuItem Header="{x:Static properties:Resources.Paste}" Command="{Binding PasteCommand}">
              <MenuItem.Icon>
                <Image SnapsToDevicePixels="True" Source="/ResXManager.View;component/Assets/paste.png" />
              </MenuItem.Icon>
            </MenuItem>
          </ContextMenu>
        </ListBox.ContextMenu>
        <ListBox.ItemTemplate>
          <DataTemplate DataType="model:ResourceEntity">
            <DockPanel ToolTip="{Binding Path=Directory, Mode=OneWay}" Margin="5,2" HorizontalAlignment="Stretch">
              <CheckBox DockPanel.Dock="Left" IsChecked="{Binding IsSelected, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}}" />
              <Decorator DockPanel.Dock="Left" Width="5" />
              <TextBlock Background="Transparent" VerticalAlignment="Center">
                <Run Text="{Binding Path=RelativePath, Mode=OneWay}" /><Run Text="{Binding Path=BaseName, Mode=OneWay}" />
              </TextBlock>
            </DockPanel>
          </DataTemplate>
        </ListBox.ItemTemplate>
        <ListBox.GroupStyle>
          <GroupStyle>
            <GroupStyle.ContainerStyle>
              <Style TargetType="{x:Type GroupItem}">
                <Setter Property="Margin" Value="0,0,0,5" />
                <Setter Property="Template">
                  <Setter.Value>
                    <ControlTemplate TargetType="{x:Type GroupItem}">
                      <StackPanel Background="Transparent" d:DataContext="{d:DesignInstance GroupItem}">
                        <i:Interaction.Behaviors>
                          <behaviors:SelectGroupOnGroupHeaderClickBehavior />
                        </i:Interaction.Behaviors>
                        <TextBlock Text="{Binding Path=Name}" FontWeight="Bold" />
                        <ItemsPresenter />
                      </StackPanel>
                    </ControlTemplate>
                  </Setter.Value>
                </Setter>
              </Style>
            </GroupStyle.ContainerStyle>
          </GroupStyle>
        </ListBox.GroupStyle>
      </ListBox>
    </DockPanel>

    <GridSplitter Grid.Column="1" Width="3" HorizontalAlignment="Left" VerticalAlignment="Stretch" />

    <DockPanel Grid.Column="2">
      <DockPanel DockPanel.Dock="Bottom" Background="{Binding Background, ElementName=DataGrid}">
        <Control DataContext="{Binding SelectedItem, ElementName=DataGrid}" >
          <Control.Template>
            <ControlTemplate>
              <Border BorderThickness="0,0.7,0,0" BorderBrush="{x:Static SystemColors.ControlDarkBrush}">
                <ContentControl x:Name="footerContent" Foreground="Gray" Margin="5" >
                  <TextBlock Text="{x:Static properties:Resources.MultipleSelection}"/>
                </ContentControl>
              </Border>
              <ControlTemplate.Triggers>
                <DataTrigger Binding="{Binding SelectedItems.Count, ElementName=DataGrid}" Value="1">
                  <Setter Property="Content" TargetName="footerContent">
                    <Setter.Value>
                      <TextBlock d:DataContext="{d:DesignInstance model:ResourceTableEntry}">
                        <Run Text="{Binding Path=Key, Mode=OneWay}" Foreground="Black"/>:
                        <Run Text="{Binding Path=Owner.BaseName, Mode=OneWay}" FontWeight="Bold" />
                        (<Run Text="{Binding Path=Owner.Directory, Mode=OneWay}" />)
                      </TextBlock>
                    </Setter.Value>
                  </Setter>
                </DataTrigger>
                <DataTrigger Binding="{Binding SelectedItems.Count, ElementName=DataGrid}" Value="0">
                  <Setter Property="Content" TargetName="footerContent">
                    <Setter.Value>
                      <TextBlock Text="{x:Static properties:Resources.NoSelection}"/>
                    </Setter.Value>
                  </Setter><commit_msg>Sort listbox content, improve status bar text.<commit_after>﻿<UserControl x:Class="tomenglertde.ResXManager.View.Visuals.ResourceView"
             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" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="700"
             xmlns:dgx="clr-namespace:DataGridExtensions;assembly=DataGridExtensions"
             xmlns:windows="clr-namespace:System.Windows;assembly=PresentationFramework"
             xmlns:model="urn:ResXManager.Model"
             xmlns:properties="clr-namespace:tomenglertde.ResXManager.View.Properties"
             xmlns:converters="clr-namespace:tomenglertde.ResXManager.View.Converters"
             xmlns:columnHeaders="clr-namespace:tomenglertde.ResXManager.View.ColumnHeaders"
             xmlns:tools="clr-namespace:tomenglertde.ResXManager.View.Tools"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:behaviors="clr-namespace:tomenglertde.ResXManager.View.Behaviors"
             xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
             x:Name="LayoutRoot"
             UseLayoutRounding="True" TextOptions.TextFormattingMode="Display"
             d:DataContext="{d:DesignInstance model:ResourceManager}">
  <UserControl.Resources>

    <converters:ConfirmedCommandConverter x:Key="DeleteCommandConverter" Executing="DeleteCommandConverter_OnExecuting" />
    <converters:ConfirmedCommandConverter x:Key="CutCommandConverter" Executing="CutCommandConverter_OnExecuting" />

    <Style TargetType="{x:Type Control}" x:Key="SingleSelectElementStyle">
      <Setter Property="IsEnabled" Value="False" />
      <Setter Property="Opacity" Value="0.5" />
      <Style.Triggers>
        <DataTrigger Binding="{Binding Path=SelectedItems.Count, ElementName=ListBox}" Value="1">
          <Setter Property="IsEnabled" Value="True" />
          <Setter Property="Opacity" Value="1" />
        </DataTrigger>
      </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type Control}" x:Key="ToolbarCommandButtonStyle">
      <Style.Triggers>
        <Trigger Property="IsEnabled" Value="False">
          <Setter Property="Opacity" Value="0.5" />
        </Trigger>
      </Style.Triggers>
    </Style>

    <CollectionViewSource x:Key="ResourceEntitiesSource" Source="{Binding FilteredResourceEntities}">
      <CollectionViewSource.SortDescriptions>
        <componentModel:SortDescription PropertyName="BaseName"/>
      </CollectionViewSource.SortDescriptions>
      <CollectionViewSource.GroupDescriptions>
        <PropertyGroupDescription PropertyName="ProjectName" />
      </CollectionViewSource.GroupDescriptions>
    </CollectionViewSource>

    <CollectionViewSource x:Key="GroupedResourceTableEntriesSource" Source="{Binding ResourceTableEntries}">
      <CollectionViewSource.GroupDescriptions>
        <PropertyGroupDescription PropertyName="Owner" />
      </CollectionViewSource.GroupDescriptions>
    </CollectionViewSource>

  </UserControl.Resources>
  <UserControl.InputBindings>
    <KeyBinding Key="N" Modifiers="Control" Command="{Binding Converter={x:Static converters:AddNewKeyCommandConverter.Default}}" />
  </UserControl.InputBindings>
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="Auto" MinWidth="120" />
      <ColumnDefinition Width="Auto" />
      <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <DockPanel Grid.Column="0">
      <Grid DockPanel.Dock="Top" Background="{x:Static windows:SystemColors.MenuBrush}">
        <DockPanel Margin="0,5">
          <StackPanel Orientation="Horizontal" DockPanel.Dock="Left">
            <Decorator Width="16" />
            <CheckBox VerticalAlignment="Center" IsChecked="{Binding AreAllFilesSelected}" IsThreeState="True" />
            <Decorator Width="7" />
          </StackPanel>
          <Border Background="{x:Static SystemColors.WindowBrush}">
            <DockPanel>
              <StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
                <Decorator Width="3" />
                <Path Data="M0,0 L10,0 6,4 6,9 4,9 4,4 Z" Fill="Gray"
                      VerticalAlignment="Center" HorizontalAlignment="Right" Margin="2,0" />
              </StackPanel>
              <TextBox ToolTip="{x:Static properties:Resources.ResourceFilterToolTip}" BorderThickness="0"
                       Text="{Binding EntityFilter, UpdateSourceTrigger=PropertyChanged}" />
            </DockPanel>
          </Border>
        </DockPanel>
      </Grid>
      <ListBox x:Name="ListBox"
               ItemsSource="{Binding Source={StaticResource ResourceEntitiesSource}}"
               Margin="5" BorderThickness="0" SelectionMode="Extended"
               tools:MultiSelectorExtensions.SelectionBinding="{Binding SelectedEntities}">
        <ListBox.ContextMenu>
          <ContextMenu>
            <MenuItem Header="{x:Static properties:Resources.Paste}" Command="{Binding PasteCommand}">
              <MenuItem.Icon>
                <Image SnapsToDevicePixels="True" Source="/ResXManager.View;component/Assets/paste.png" />
              </MenuItem.Icon>
            </MenuItem>
          </ContextMenu>
        </ListBox.ContextMenu>
        <ListBox.ItemTemplate>
          <DataTemplate DataType="model:ResourceEntity">
            <DockPanel ToolTip="{Binding Path=Directory, Mode=OneWay}" Margin="5,2" HorizontalAlignment="Stretch">
              <CheckBox DockPanel.Dock="Left" IsChecked="{Binding IsSelected, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}}" />
              <Decorator DockPanel.Dock="Left" Width="5" />
              <TextBlock Background="Transparent" VerticalAlignment="Center">
                <Run Text="{Binding Path=RelativePath, Mode=OneWay}" /><Run Text="{Binding Path=BaseName, Mode=OneWay}" />
              </TextBlock>
            </DockPanel>
          </DataTemplate>
        </ListBox.ItemTemplate>
        <ListBox.GroupStyle>
          <GroupStyle>
            <GroupStyle.ContainerStyle>
              <Style TargetType="{x:Type GroupItem}">
                <Setter Property="Margin" Value="0,0,0,5" />
                <Setter Property="Template">
                  <Setter.Value>
                    <ControlTemplate TargetType="{x:Type GroupItem}">
                      <StackPanel Background="Transparent" d:DataContext="{d:DesignInstance GroupItem}">
                        <i:Interaction.Behaviors>
                          <behaviors:SelectGroupOnGroupHeaderClickBehavior />
                        </i:Interaction.Behaviors>
                        <TextBlock Text="{Binding Path=Name}" FontWeight="Bold" />
                        <ItemsPresenter />
                      </StackPanel>
                    </ControlTemplate>
                  </Setter.Value>
                </Setter>
              </Style>
            </GroupStyle.ContainerStyle>
          </GroupStyle>
        </ListBox.GroupStyle>
      </ListBox>
    </DockPanel>

    <GridSplitter Grid.Column="1" Width="3" HorizontalAlignment="Left" VerticalAlignment="Stretch" />

    <DockPanel Grid.Column="2">
      <DockPanel DockPanel.Dock="Bottom" Background="{Binding Background, ElementName=DataGrid}">
        <Control>
          <Control.Template>
            <ControlTemplate>
              <Border BorderThickness="0,0.7,0,0" BorderBrush="{x:Static SystemColors.ControlDarkBrush}">
                <ContentControl x:Name="footerContent" Foreground="Gray" Margin="5" >
                  <TextBlock Text="{x:Static properties:Resources.MultipleSelection}"/>
                </ContentControl>
              </Border>
              <ControlTemplate.Triggers>
                <MultiDataTrigger> 
                  <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding SelectedItems.Count, ElementName=DataGrid}" Value="0"/>
                    <Condition Binding="{Binding SelectedItems.Count, ElementName=ListBox}" Value="0"/>
                  </MultiDataTrigger.Conditions>
                  <Setter Property="Content" TargetName="footerContent">
                    <Setter.Value>
                      <TextBlock Text="{x:Static properties:Resources.NoSelection}"/>
                    </Setter.Value>
                  </Setter>
                </MultiDataTrigger>
                <DataTrigger Binding="{Binding SelectedItems.Count, ElementName=ListBox}" Value="1">
                  <Setter Property="DataContext" Value="{Binding SelectedItem, ElementName=ListBox}"/>
                  <Setter Property="Content" TargetName="footerContent">
                    <Setter.Value>
                      <TextBlock d:DataContext="{d:DesignInstance model:ResourceEntity}">
                        <Run Text="{Binding Path=BaseName, Mode=OneWay}" FontWeight="Bold" />
                        (<Run Text="{Binding Path=Directory, Mode=OneWay}" />)
                      </TextBlock>
                    </Setter.Value>
                  </Setter>
                </DataTrigger>
                <DataTrigger Binding="{Binding SelectedItems.Count, ElementName=DataGrid}" Value="1">
                  <Setter Property="DataContext" Value="{Binding SelectedItem, ElementName=DataGrid}"/>
                  <Setter Property="Content" TargetName="footerContent">
                    <Setter.Value>
                      <TextBlock d:DataContext="{d:DesignInstance model:ResourceTableEntry}">
                        <Run Text="{Binding Path=Key, Mode=OneWay}" Foreground="Black"/>:
                        <Run Text="{Binding Path=Owner.BaseName, Mode=OneWay}" FontWeight="Bold" />
                        (<Run Text="{Binding Path=Owner.Directory, Mode=OneWay}" />)
                      </TextBlock>
                    </Setter.Value>
                  </Setter>
{'fraction_non_alphanumeric': 0.125684512733266, 'fraction_numerical': 0.008400233930565154, 'mean_word_length': 2.609671848013817, 'pattern_counts': {'":': 0, '<': 292, '<?xml version=': 0, '>': 292, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 29}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2967210', 'n_tokens_mistral': 5229, 'n_tokens_neox': 4824, 'n_words': 714}