<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:model="clr-namespace:_1RM.Model"
                    xmlns:view="clr-namespace:_1RM.View"
                    xmlns:attachProperty="clr-namespace:Shawn.Utils.WpfResources.Theme.AttachProperty;assembly=Shawn.Utils.WpfResources"
                    xmlns:converter="clr-namespace:Shawn.Utils.WpfResources.Converter;assembly=Shawn.Utils.WpfResources">

    <converter:ConverterColorHexString2Brush x:Key="ConverterColorHexString2Brush"></converter:ConverterColorHexString2Brush>





    <Style x:Key="SearchBoxTbKeyWordStyleBase" TargetType="TextBox"  BasedOn="{StaticResource TextBoxBaseStyle}">
        <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
        <Setter Property="CaretBrush" Value="{DynamicResource PrimaryTextBrush}" />
        <Setter Property="IsTabStop" Value="True" />
        <Setter Property="TabIndex" Value="0" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Height" Value="44" />
        <Setter Property="FontSize" Value="18" />
        <Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="AllowDrop" Value="true" />
        <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />
        <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TextBox">
                    <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
                        <ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Background" Value="Transparent" />
    </Style>




    <Style x:Key="ListBoxItemStyleForServer" TargetType="ListBoxItem">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListBoxItem">
                    <Grid>
                        <Grid x:Name="GridColor" Opacity="0.4" Background="{Binding Server.ColorHex,Converter={StaticResource ConverterColorHexString2Brush}, Mode=OneWay}"></Grid>
                        <Border x:Name="GridHighLight"></Border>
                        <Grid x:Name="GridColorOnSelected" 
                              Visibility="Collapsed"
                              Width="40" 
                              HorizontalAlignment="Left" 
                              Background="{Binding Server.ColorHex, Converter={StaticResource ConverterColorHexString2Brush}, Mode=OneWay}"></Grid>
                        <ContentPresenter x:Name="ContentPresenter"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" TargetName="GridHighLight" Value="{DynamicResource PrimaryTextBrush}"></Setter>
                            <Setter Property="Opacity" Value="0.2" TargetName="GridHighLight" />
                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Opacity" Value="1" TargetName="GridHighLight" />
                            <Setter Property="Background" Value="{DynamicResource AccentMidBrush}" TargetName="GridHighLight" />
                            <Setter TargetName="GridColorOnSelected" Property="Visibility" Value="Visible" />
                            <Setter TargetName="GridColor" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="SearchBoxSelectionList" TargetType="{x:Type ListBox}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
        <Setter Property="Background" Value="{DynamicResource PrimaryMidBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBox}">
                    <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="0" SnapsToDevicePixels="true">
                        <ScrollViewer Focusable="false" Padding="{TemplateBinding Padding}" 
                                      Background="{DynamicResource PrimaryMidBrush}"
                                      attachProperty:VisionElement.ForegroundAccent="{DynamicResource PrimaryTextBrush}"
                                      attachProperty:VisionElement.BackgroundAccent="{DynamicResource PrimaryTextBrush}"
                                      Style="{StaticResource ScrollViewAccentStyle}">
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemContainerStyle" Value="{StaticResource ListBoxItemStyleForServer}"></Setter>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel IsVirtualizing="True"
                                            ScrollUnit="Pixel"
                                            VirtualizationMode="Recycling"
                                            CacheLengthUnit="Item"/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
    </Style>



    <Style x:Key="TextBlockDataTemplateForProtocolActionStyle" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBase}">
        <Setter Property="Opacity" Value="0.8"></Setter>
        <Setter Property="FontSize" Value="14"></Setter>
        <Setter Property="VerticalAlignment" Value="Center"></Setter>
        <Setter Property="TextTrimming" Value="CharacterEllipsis"></Setter>
        <Setter Property="Margin" Value="5 0 10 0"></Setter>
        <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"></Setter>
        <Style.Triggers>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
                <Setter Property="Foreground" Value="{DynamicResource AccentTextBrush}"></Setter>
                <Setter Property="Opacity" Value="1"></Setter>
            </DataTrigger>
        </Style.Triggers>
    </Style>


    <DataTemplate x:Key="DataTemplateForProtocolAction" DataType="model:ProtocolAction">
        <Grid Height="{x:Static view:LauncherWindowViewModel.LAUNCHER_ACTION_LIST_ITEM_HEIGHT}">
            <Grid VerticalAlignment="Center">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="5"></ColumnDefinition>
                    <ColumnDefinition Width="30"></ColumnDefinition>
                    <ColumnDefinition Width="5"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Row="0" 
                           Grid.Column="3" 
                           Text="{Binding ActionName}"
                           Style="{StaticResource TextBlockDataTemplateForProtocolActionStyle}">
                </TextBlock>
            </Grid>
        </Grid>
    </DataTemplate>


    <Style x:Key="ListBoxItemStyleForAction" TargetType="ListBoxItem">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListBoxItem">
                    <Grid>
                        <Border x:Name="GridHighLight"></Border>
                        <ContentPresenter x:Name="ContentPresenter"></ContentPresenter>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="GridHighLight" Property="Background" Value="{DynamicResource PrimaryTextBrush}"></Setter>
                            <Setter TargetName="GridHighLight" Property="Opacity" Value="0.2"/>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter TargetName="GridHighLight" Property="Opacity" Value="1" />
                            <Setter TargetName="GridHighLight" Property="Background" Value="{DynamicResource AccentMidBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="SearchBoxActionList" TargetType="{x:Type ListBox}" BasedOn="{StaticResource SearchBoxSelectionList}">
        <Setter Property="ItemTemplate" Value="{StaticResource DataTemplateForProtocolAction}"></Setter>
        <Setter Property="ItemContainerStyle" Value="{StaticResource ListBoxItemStyleForAction}"></Setter>
    </Style>
</ResourceDictionary>