<UserControl
    x:Class="MECF.Framework.UI.Client.CenterViews.Configs.DataConfig.DataConfigView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
    xmlns:converter="clr-namespace:MECF.Framework.UI.Client.Ctrlib.Converter"
    xmlns:cv="clr-namespace:MECF.Framework.UI.Core.Converters;assembly=MECF.Framework.UI.Core"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:micro="clr-namespace:Caliburn.Micro"
    d:DesignHeight="1024"
    d:DesignWidth="1900"
    mc:Ignorable="d">
    <UserControl.Resources>
        <cv:BoolReverseConverter x:Key="BoolReverse" />
        <cv:BoolCollapsedConverter x:Key="BoolVisibility" />
    </UserControl.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="405" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <Grid Grid.Column="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="30" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid Grid.Row="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="80" />
                </Grid.ColumnDefinitions>

                <controls:TextBoxEx
                    HorizontalAlignment="Stretch"
                    AllowBackgroundChange="False"
                    Text="{Binding Path=NewGroupName, UpdateSourceTrigger=PropertyChanged}" />
                <Button
                    Grid.Column="1"
                    Width="70"
                    Height="30"
                    Margin="0"
                    Padding="0"
                    Content="New">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <micro:ActionMessage MethodName="NewGroup" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Button>

            </Grid>

            <DataGrid
                Grid.Row="1"
                Margin="0,5,0,0"
                HorizontalAlignment="Left"
                AutoGenerateColumns="False"
                CanUserAddRows="False"
                ItemsSource="{Binding GroupData}"
                RowHeaderWidth="0"
                SelectedItem="{Binding CurrentSelection}"
                VirtualizingPanel.IsVirtualizing="True"
                VirtualizingPanel.VirtualizationMode="Recycling">

                <DataGrid.Columns>
                    <DataGridTemplateColumn Width="200" Header="Name">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock
                                    Margin="5,0"
                                    HorizontalAlignment="Left"
                                    VerticalAlignment="Center"
                                    FontFamily="Arial"
                                    FontSize="14"
                                    Foreground="{DynamicResource FG_Black}"
                                    Text="{Binding Name}" />
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                    <DataGridTemplateColumn Width="100">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Button
                                    Width="100"
                                    Height="25"
                                    Content="Rename"
                                    FontSize="14"
                                    IsEnabled="{Binding IsFix, Converter={StaticResource BoolReverse}}">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Click">
                                            <micro:ActionMessage MethodName="RenameGroup">
                                                <micro:Parameter Value="{Binding}" />
                                            </micro:ActionMessage>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>



                    <DataGridTemplateColumn Width="100">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Button
                                    Width="100"
                                    Height="25"
                                    Content="Delete"
                                    FontSize="14"
                                    IsEnabled="{Binding IsFix, Converter={StaticResource BoolReverse}}">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Click">
                                            <micro:ActionMessage MethodName="DeleteGroup">
                                                <micro:Parameter Value="{Binding}" />
                                            </micro:ActionMessage>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                </DataGrid.Columns>
            </DataGrid>

        </Grid>

        <Grid Grid.Column="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="30" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid Grid.Row="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="150" />
                    <ColumnDefinition Width="100" />
                    <ColumnDefinition Width="100" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <Border
                    Padding="5,1"
                    Background="{DynamicResource Table_BG_Title}"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="1">
                    <TextBlock
                        VerticalAlignment="Center"
                        FontFamily="Arial"
                        FontSize="12"
                        Foreground="{DynamicResource FG_Black}"
                        Text="{Binding CurrentSelection.Name}"
                        TextWrapping="Wrap" />
                </Border>
                <Button
                    Grid.Column="1"
                    Width="90"
                    Height="30"
                    Margin="0"
                    Padding="0"
                    Content="Save">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <micro:ActionMessage MethodName="SaveSelection" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Button>

                <Button
                    Grid.Column="2"
                    Width="90"
                    Height="30"
                    Margin="0"
                    Padding="0"
                    Content="Cancel">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <micro:ActionMessage MethodName="CancelSelection" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Button>

            </Grid>

            <Grid Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="460" />
                    <ColumnDefinition Width="120" />
                    <ColumnDefinition Width="460" />
                </Grid.ColumnDefinitions>

                <ListView
                    Grid.Column="0"
                    Width="450"
                    Margin="0,5,0,0"
                    HorizontalAlignment="Left"
                    ItemsSource="{Binding Unselections}"
                    Style="{x:Null}">
                    <ListView.ItemContainerStyle>
                        <Style BasedOn="{StaticResource ResourceKey={x:Type ListViewItem}}" TargetType="{x:Type ListViewItem}">
                            <Setter Property="Visibility" Value="{Binding Path=IsSelected, Mode=OneWay, Converter={StaticResource ResourceKey=BoolVisibility}}" />
                            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                        </Style>
                    </ListView.ItemContainerStyle>

                    <ListView.View>
                        <GridView>
                            <GridViewColumn Width="30">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <CheckBox
                                            x:Name="ckHold"
                                            Width="20"
                                            Height="25"
                                            VerticalContentAlignment="Center"
                                            IsChecked="{Binding Path=IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>

                            <GridViewColumn Width="390" Header="Name">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock
                                            Width="390"
                                            Height="30"
                                            VerticalAlignment="Center"
                                            Text="{Binding Name}"
                                            TextWrapping="Wrap" />

                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>



                        </GridView>
                    </ListView.View>


                </ListView>

                <Grid Grid.Column="1">
                    <StackPanel
                        Margin="0,120,0,0"
                        HorizontalAlignment="Center"
                        Orientation="Vertical">
                        <Button
                            Grid.Column="0"
                            Width="90"
                            Height="30"
                            Margin="0"
                            Padding="0"
                            Content="Select">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <micro:ActionMessage MethodName="Select" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </Button>

                        <Button
                            Grid.Column="1"
                            Width="90"
                            Height="30"
                            Margin="0,30,0,0"
                            Padding="0"
                            Content="Unselect">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <micro:ActionMessage MethodName="Unselect" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </Button>

                    </StackPanel>

                </Grid>

                <ListView
                    Grid.Column="2"
                    Width="460"
                    Margin="0,5,0,0"
                    HorizontalAlignment="Left"
                    ItemsSource="{Binding Selections}"
                    VirtualizingPanel.IsVirtualizing="True"
                    VirtualizingPanel.VirtualizationMode="Recycling">
                    <ListView.ItemContainerStyle>
                        <Style BasedOn="{StaticResource ResourceKey={x:Type ListViewItem}}" TargetType="{x:Type ListViewItem}">
                            <Setter Property="Visibility" Value="{Binding Path=IsSelected, Mode=OneWay, Converter={StaticResource ResourceKey=BoolVisibility}}" />
                        </Style>
                    </ListView.ItemContainerStyle>
                    <ListView.View>
                        <GridView>
                            <GridViewColumn Width="30">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <CheckBox
                                            x:Name="ckHold"
                                            Width="20"
                                            Height="25"
                                            VerticalContentAlignment="Center"
                                            IsChecked="{Binding Path=IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>

                            <GridViewColumn Width="390" Header="Name">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock
                                            Width="390"
                                            Height="30"
                                            VerticalAlignment="Center"
                                            Text="{Binding Name}"
                                            TextWrapping="Wrap" />

                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>



                        </GridView>
                    </ListView.View>

                </ListView>
            </Grid>

        </Grid>


    </Grid>

</UserControl>
