<Window x:Class="FSI.Lib.Guis.TxtToClip.Mgt.FrmMain"
        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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:FSI.Lib.Guis.TxtToClip.Mgt"        
        xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase"        
        xmlns:control="clr-namespace:FSI.Lib.Wpf.Ctrls.FilterDataGrid"       
        d:DataContext="{d:DesignInstance Type=local:ViewModel}"
        mc:Ignorable="d"
        SizeToContent="Width"
        Height="800"
        Width="Auto"
        Icon="../../Icons/FondiumU.ico">
    <Window.Resources>
        <ObjectDataProvider x:Key="FilteredData"></ObjectDataProvider>
    </Window.Resources>

    <Window.InputBindings>
        <KeyBinding Command="{Binding CmdCopyToClip}"
                    Gesture="CTRL+x" Key="X" />
    </Window.InputBindings>

    <Grid FocusManager.FocusedElement="{Binding ElementName=tbSearch}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0"
              Margin="0,10"
              HorizontalAlignment="Stretch">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="2*" />
                <ColumnDefinition Width="1*" />
            </Grid.ColumnDefinitions>

            <StackPanel Grid.Column="0"
                        HorizontalAlignment="Left"
                        Orientation="Horizontal">
                <Label Margin="0,0,20,0"
                       VerticalAlignment="Bottom"
                       Content="Suche:"
                       FontWeight="Bold" />
                <TextBox Name="tbSearch"
                         Height="26"
                         MinWidth="200"
                         VerticalAlignment="Center"
                         VerticalContentAlignment="Center"
                         Text="{Binding Search, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                         TextChanged="tbSearch_TextChanged" />
                <Button Width="Auto"
                        Margin="5,0,0,0"
                        Padding="4"
                        Command="{Binding RefreshCommand}"
                        ToolTip="Filter löschen"
                        Cursor="Hand">
                    <Image Source="../../Icons/Cross.png"
                           Height="14" />
                </Button>
            </StackPanel>
            <StackPanel Grid.Column="2"
                        HorizontalAlignment="Right"
                        Orientation="Horizontal">
                <Button Width="Auto"
                        Margin="0 0 20 0"
                        Padding="4"
                        ToolTip="öffen"
                        Command="{Binding CmdOpen}"
                        IsEnabled="{Binding CanExecuteOpen}"
                        Cursor="Hand">
                    <Image Source="../../Icons/Open.png"
                           Height="14" />
                </Button>
            </StackPanel>
        </Grid>

        <StackPanel Grid.Row="1"
                    HorizontalAlignment="Left"
                    Orientation="Horizontal"
                    Margin="0,5">
            <Label Margin="0,0,20,0"
                   VerticalAlignment="Bottom"
                   Content="Quick-Filter:"
                   FontWeight="Bold" />
            <Button Width="Auto"
                    Margin="5,0,0,0"
                    Padding="4"
                    ToolTip="Filter löschen"
                    Command="{Binding RefreshCommand}"
                    Cursor="Hand">
                <Image Source="../../Icons/Cross.png"
                       Height="14" />
            </Button>
            <Button Content="Alg"
                    Width="Auto"
                    Margin="10,0,0,0"
                    ToolTip="Filter auf Alg"
                    Command="{Binding CmdQuickSearch}"
                    CommandParameter="Alg"
                    FocusManager.FocusedElement="{Binding ElementName=tbSearch}" />
            <Button Content="PL1"
                    Width="Auto"
                    Margin="10,0,0,0"
                    ToolTip="Filter auf PL1"
                    Command="{Binding CmdQuickSearch}"
                    CommandParameter="PL1"
                    FocusManager.FocusedElement="{Binding ElementName=tbSearch}" />
            <Button Content="PL2"
                    Width="Auto"
                    Margin="10,0,0,0"
                    ToolTip="Filter auf PL2"
                    Command="{Binding CmdQuickSearch}"
                    CommandParameter="PL2"
                    FocusManager.FocusedElement="{Binding ElementName=tbSearch}" />
            <Button Content="PL3"
                    Width="Auto"
                    Margin="10,0,0,0"
                    ToolTip="Filter auf PL3"
                    Command="{Binding CmdQuickSearch}"
                    CommandParameter="PL3"
                    FocusManager.FocusedElement="{Binding ElementName=tbSearch}" />
            <Button Content="SMZ"
                    Width="Auto"
                    Margin="10,0,0,0"
                    ToolTip="Filter auf SMZ"
                    Command="{Binding CmdQuickSearch}"
                    CommandParameter="SMZ"
                    FocusManager.FocusedElement="{Binding ElementName=tbSearch}" />
        </StackPanel>

        <control:FilterDataGrid x:Name="FilterDataGrid"
                                Grid.Row="2"
                                AutoGenerateColumns="False"
                                DateFormatString="d"
                                FilterLanguage="German"
                                ItemsSource="{Binding FilteredData, UpdateSourceTrigger=PropertyChanged}"
                                SelectionMode="Single"
                                SelectedItem="{Binding SeletctedData, UpdateSourceTrigger=PropertyChanged}"
                                ShowElapsedTime="false"
                                ShowRowsCount="True"
                                ShowStatusBar="True">

            <control:FilterDataGrid.InputBindings>
                <MouseBinding MouseAction="RightDoubleClick"
                              Command="{Binding CmdCopyToClip}" />

            </control:FilterDataGrid.InputBindings>
            <control:FilterDataGrid.Columns>

                <control:DataGridTemplateColumn FieldName="Plant"
                                                Header="Anlage"
                                                IsColumnFiltered="True"
                                                SortMemberPath="Plant">
                    <control:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate DataType="local:Interface">
                            <TextBlock Text="{Binding Plant}" />
                        </DataTemplate>
                    </control:DataGridTemplateColumn.CellTemplate>
                </control:DataGridTemplateColumn>

                <control:DataGridTextColumn Binding="{Binding SubPlant}"
                                            Header="Teilanlagen"
                                            IsReadOnly="True"
                                            IsColumnFiltered="True" />

                <control:DataGridTextColumn Binding="{Binding Description}"
                                            Header="Beschreibung"
                                            IsReadOnly="True"
                                            IsColumnFiltered="True" />

                <control:DataGridTextColumn Binding="{Binding Txt}"
                                            Header="Text"
                                            IsReadOnly="True"
                                            IsColumnFiltered="True" />

            </control:FilterDataGrid.Columns>
        </control:FilterDataGrid>
    </Grid>
</Window>

