<UserControl x:Class="Filtration.Views.ItemFilterCommentBlockView"
             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"
             xmlns:viewModels="clr-namespace:Filtration.ViewModels"
             xmlns:views="clr-namespace:Filtration.Views"
             xmlns:converters="clr-namespace:Filtration.Converters"
             d:DataContext="{d:DesignInstance Type=viewModels:ItemFilterCommentBlockViewModel}"
             mc:Ignorable="d" 
             d:DesignHeight="50" d:DesignWidth="300">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary>
                    <views:BindingProxy x:Key="Proxy" Data="{Binding}" />
                    <converters:BlockGroupAdvancedFillColorConverter x:Key="BlockGroupAdvancedFillColorConverter" />
                    <Style TargetType="{x:Type ContentPresenter}" x:Key="BlockItemFadeInStyle">
                        <Setter Property="LayoutTransform">
                            <Setter.Value>
                                <ScaleTransform x:Name="transform" />
                            </Setter.Value>
                        </Setter>
                        <Style.Triggers>
                            <EventTrigger RoutedEvent="Loaded">
                                <EventTrigger.Actions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:0.5" />
                                        </Storyboard>
                                    </BeginStoryboard>
                                </EventTrigger.Actions>
                            </EventTrigger>
                        </Style.Triggers>
                    </Style>
                </ResourceDictionary>
                <ResourceDictionary>
                <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MetroTextBox}">
                    <Style.Setters>
                        <Setter Property="BorderBrush" Value="Transparent" />
                        <Setter Property="Background" Value="Transparent" />
                    </Style.Setters>
                </Style>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>

    </UserControl.Resources>
    <Grid>
        <Grid.ContextMenu>
            <ContextMenu>
                <ContextMenu.Items>
                    <MenuItem Header="Copy Block" Command="{Binding CopyBlockCommand}" Icon="{StaticResource CopyIcon}" />
                    <MenuItem Header="Paste Block" Command="{Binding PasteBlockCommand}" Icon="{StaticResource PasteIcon}" />
                    <Separator />
                    <MenuItem Header="Add Block" Command="{Binding AddBlockCommand}" Icon="{StaticResource AddBlockIcon}" />
                    <MenuItem Header="Add Section" Command="{Binding AddSectionCommand}" Icon="{StaticResource AddSectionIcon}" />
                    <Separator />
                    <MenuItem Header="Delete Section" Command="{Binding DeleteBlockCommand}" Icon="{StaticResource DeleteIcon}" />
                    <Separator />
                    <MenuItem Header="Move Section To Top" Command="{Binding MoveBlockToTopCommand}" Icon="{StaticResource MoveToTopIcon}" />
                    <MenuItem Header="Move Section Up" Command="{Binding MoveBlockUpCommand}" Icon="{StaticResource MoveUpIcon}" />
                    <MenuItem Header="Move Section Down" Command="{Binding MoveBlockDownCommand}" Icon="{StaticResource MoveDownIcon}" />
                    <MenuItem Header="Move Section To Bottom" Command="{Binding MoveBlockToBottomCommand}" Icon="{StaticResource MoveToBottomIcon}" />
                </ContextMenu.Items>
            </ContextMenu>
        </Grid.ContextMenu>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Border Width="7" Grid.Column="0" BorderBrush="Gray" Background="Gray" CornerRadius="2,0,0,2" />
        <Border Grid.Column =" 1"  BorderThickness="1" BorderBrush="SlateGray" Background="Gainsboro" CornerRadius="0,2,2,0" Padding="3">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <Expander Grid.Column="1"
                          Style="{StaticResource ExpanderRightAlignStyle}"
                          x:Name="BlockExpander">

                    <Expander.Header>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <Label Grid.Column="0" VerticalAlignment="Center" MinWidth="150" Content="{Binding Header, Mode=OneWay}" />
                            <WrapPanel Grid.Column="1" HorizontalAlignment="Right" Visibility="{Binding HasVisibleChild, Converter={StaticResource BooleanVisibilityConverter}}">
                                <Button Command="{Binding ToggleSectionCommand}"
                                    Width="25"
                                    Height="25"
                                    VerticalAlignment="Center"
                                    Margin="0,0,3,0"
                                    Background="Transparent"
                                    BorderBrush="Transparent"
                                    ToolTip="Expand Section" Visibility="{Binding IsExpanded, Converter={StaticResource InverseBooleanVisibilityConverter}}">
                                    <Image Source="/Filtration;component/Resources/Icons/expand_icon.png"  VerticalAlignment="Center" HorizontalAlignment="Center" />
                                </Button>
                                <Button Command="{Binding ToggleSectionCommand}"
                                    Width="25"
                                    Height="25"
                                    VerticalAlignment="Center"
                                    Margin="0,0,3,0"
                                    Background="Transparent"
                                    BorderBrush="Transparent"
                                    ToolTip="Collapse Section" Visibility="{Binding IsExpanded, Converter={StaticResource BooleanVisibilityConverter}}">
                                    <Image Source="/Filtration;component/Resources/Icons/collapse_icon.png"  VerticalAlignment="Center" HorizontalAlignment="Center" />
                                </Button>
                            </WrapPanel>
                        </Grid>
                    </Expander.Header>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <TextBox Grid.Column ="0" Text="{Binding Comment, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" VerticalAlignment="Center" TextWrapping="Wrap" MinWidth="150"/>
                    </Grid>
                </Expander>
            </Grid>
        </Border>
    </Grid>
</UserControl>
