<UserControl x:Class="BeWo.View.Controls.MultiSupportConceptSelectionControl" 
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:localsearch="clr-namespace:BeWo.View.Search">
    <UserControl.Resources>
        <Style x:Key="MultiSupportConceptSelectionControlStyle" TargetType="{x:Type ListBoxItem}">
            <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type ItemsControl}, Mode=FindAncestor}}" />
            <Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type ItemsControl}, Mode=FindAncestor}}" />
            <Setter Property="Margin" Value="0,2,0,0" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Grid>
                            <Border x:Name="ItemBorder" CornerRadius="5" MinHeight="25" Background="#FF000000">
                                <Border.OpacityMask>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#19000000" Offset="0" />
                                        <GradientStop Color="#26000000" Offset="1" />
                                    </LinearGradientBrush>
                                </Border.OpacityMask>

                            </Border>

                            <Border x:Name="ItemContent" CornerRadius="5" MinHeight="25">
                                <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5,3,5,3" OpacityMask="{x:Null}" SnapsToDevicePixels="True">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>

                                    <TextBlock x:Name="txtDetail1" Grid.Column="0" Grid.Row="0" Text="{Binding Path=CustomerName}" FontSize="12" Foreground="#FFD2D2D2" FontFamily="Microsoft Sans Serif" />
                                    <TextBlock x:Name="txtDetail2" Grid.Column="0" Grid.Row="1" ToolTip="{Binding Path=FirstCostBearerDetailString}" Text="{Binding Path=FirstCostBearerDetailString}" FontSize="10" Foreground="{Binding ForegroundBrush}" FontFamily="Microsoft Sans Serif" />
                                    <Button x:Name="btnRemoveSupportConcept" Grid.Column="2" Grid.RowSpan="2" Width="20" Height="20" ToolTip="Hilfeplan aus der Liste entfernen" Tag="{Binding}" Style="{DynamicResource CloseButtonStyle}" Click="btnRemoveSupportConcept_Click" Margin="3,0,0,0" />
                                </Grid>
                            </Border>
                        </Grid>

                        <ControlTemplate.Triggers>
                            <DataTrigger Binding="{Binding Path=IsArchived}" Value="True">
                                <Setter Property="Foreground" TargetName="txtDetail1" Value="#FF808080" />
                                <Setter Property="Foreground" TargetName="txtDetail2" Value="#FF808080" />
                            </DataTrigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="OpacityMask" TargetName="ItemBorder">
                                    <Setter.Value>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#33000000" Offset="0" />
                                            <GradientStop Color="#66000000" Offset="1" />
                                        </LinearGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>

                            <Trigger Property="ListBoxItem.IsSelected" Value="True">
                                <Setter Property="OpacityMask" TargetName="ItemBorder">
                                    <Setter.Value>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#99000000" Offset="0" />
                                            <GradientStop Color="#CC000000" Offset="1" />
                                        </LinearGradientBrush>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="ListBoxItem.IsSelected" Value="True" />
                                    <Condition Property="Selector.IsSelectionActive" Value="False" />
                                </MultiTrigger.Conditions>
                                <Setter Property="OpacityMask" TargetName="ItemBorder">
                                    <Setter.Value>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#99000000" Offset="0" />
                                            <GradientStop Color="#B2000000" Offset="1" />
                                        </LinearGradientBrush>
                                    </Setter.Value>
                                </Setter>

                            </MultiTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Label x:Name="labelTitle" Content="Ausgewählte Hilfepläne" FontSize="12" FontWeight="Bold" />
        <Button x:Name="btnAddGroup" HorizontalAlignment="Right" Click="btnAddGroup_Click" Height="21" Width="45" Margin="0,0,48,3" ToolTip="Gruppe hinzufügen">
            <StackPanel Orientation="Horizontal">
                <Grid Width="18" HorizontalAlignment="Center" VerticalAlignment="Center">
                    <Line X1="4" X2="12" Y1="8" Y2="8" Fill="{x:Null}" Stroke="#FFFFFFFF" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeThickness="2" HorizontalAlignment="Center" VerticalAlignment="Center" Width="16" Height="16" />
                    <Line X1="8" X2="8" Y1="4" Y2="12" Fill="{x:Null}" Stroke="#FFFFFFFF" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeThickness="2" HorizontalAlignment="Center" VerticalAlignment="Center" Width="16" Height="16" />
                </Grid>
                <Image Width="20" Source="/BeWoPlaner;component/Ressources/Icons/UserGroupHome24bw.png" />
            </StackPanel>
        </Button>
        <Button x:Name="btnAddSupportConcept" HorizontalAlignment="Right" Click="btnAddSupportConcept_Click" Height="21" Width="45" Margin="0,0,0,3" ToolTip="Klient/in hinzufügen">
            <StackPanel Orientation="Horizontal">
                <Grid Width="18" HorizontalAlignment="Center" VerticalAlignment="Center">
                    <Line X1="4" X2="12" Y1="8" Y2="8" Fill="{x:Null}" Stroke="#FFFFFFFF" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeThickness="2" HorizontalAlignment="Center" VerticalAlignment="Center" Width="16" Height="16" />
                    <Line X1="8" X2="8" Y1="4" Y2="12" Fill="{x:Null}" Stroke="#FFFFFFFF" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeThickness="2" HorizontalAlignment="Center" VerticalAlignment="Center" Width="16" Height="16" />
                </Grid>
                <Image Width="20" Source="/BeWoPlaner;component/Ressources/Icons/AnonymousUserDisabled.png" />
            </StackPanel>
        </Button>
        <ListBox Background="{DynamicResource SupportConceptListBrush}" Padding="2,0,2,2" Grid.Row="1" x:Name="listBoxSupportConcepts" IsSynchronizedWithCurrentItem="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch" ItemContainerStyle="{DynamicResource MultiSupportConceptSelectionControlStyle}" SelectionMode="Single" SelectionChanged="listBoxSupportConcepts_SelectionChanged">
            <ListBox.Template>
                <ControlTemplate TargetType="{x:Type ListBox}">
                    <Border x:Name="Bd" SnapsToDevicePixels="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}">
                        <ScrollViewer Focusable="False" Padding="{TemplateBinding Padding}" HorizontalScrollBarVisibility="Disabled">
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>

            </ListBox.Template>
        </ListBox>

        <Popup x:Name="popupSupportConcepts" StaysOpen="False" Placement="MousePoint" Width="400" Grid.Row="2" Height="400">
            <localsearch:SupportConceptSearchView x:Name="SearchView" ShowFilterPanel="True" ItemSelected="SupportConceptSearchView_ItemSelected" SearchMode="ActiveCostbearer2SupportConcepts" />
        </Popup>
        <Popup x:Name="popupGroup" StaysOpen="False" Placement="MousePoint" Width="400" Grid.Row="2" Height="400">
            <localsearch:SupportConceptGroupSearchView x:Name="GroupSearchView" ItemSelected="GroupSearchView_ItemSelected" />
        </Popup>
    </Grid>
</UserControl>