<UserControl x:Class="StockAnalysis.Partial.UserControls.Overlays"
             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:data="clr-namespace:StockAnalysis.Data;assembly=StockAnalysis.Data"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:cmd="clr-namespace:StockAnalysis.Command"
             xmlns:cvt="clr-namespace:StockAnalysis.Converter"
             xmlns:cc="clr-namespace:StockAnalysis.Partial.CustomControls"
             xmlns:System="clr-namespace:System;assembly=mscorlib"
             xmlns:local="clr-namespace:StockAnalysis.Partial.UserControls"
             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="210" Background="White" DataContext="{Binding RelativeSource={RelativeSource Mode=Self}}">
    <StackPanel>
        <cc:NavList x:Name="listbox" BorderThickness="0" SelectionChanged="listbox_SelectionChanged" >
            <cc:NavList.ItemContainerStyle>
                <Style TargetType="{x:Type ListBoxItem}">
                    <Setter Property="Background" Value="White"/>
                    <Setter Property="BorderBrush" Value="{StaticResource PaperWhite800}"/>
                    <Setter Property="BorderThickness" Value="1"/>
                    <Setter Property="VerticalAlignment" Value="Stretch" />
                    <Setter Property="VerticalContentAlignment" Value="Center" />
                    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                    <Setter Property="SnapsToDevicePixels" Value="True"/>
                    <Setter Property="Padding" Value="15,3"/>
                    <Setter Property="FocusVisualStyle">
                        <Setter.Value>
                            <Style>
                                <Setter Property="Control.Template">
                                    <Setter.Value>
                                        <ControlTemplate>
                                            <Rectangle Margin="2" SnapsToDevicePixels="True" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                <Border x:Name="templateRoot" Background="Transparent" SnapsToDevicePixels="True" Tag="{Binding IsShowSettings}">
                                    <Grid Margin="{TemplateBinding Padding}">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <ContentPresenter x:Name="contentPresenter" Margin="0,0,10,0" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>

                                        <cc:SimpleButton x:Name="setting" Grid.Column="1" Visibility="Hidden" Margin="10, 0" Background="Transparent" BorderBrush="Transparent"
                                         Padding="4"
                                                         Command="{StaticResource SettingCommand}" CommandParameter="{Binding Tag}"
                                         HorizontalAlignment="Center" VerticalAlignment="Center">
                                            <Path Visibility="Visible" Data="M12,7.6c0,0.1,0,0.2,0,0.4c0,0.1-0.1,0.3-0.1,0.4c-0.1,0.2-0.1,0.3-0.2,0.4c-0.1,0.1-0.2,0.2-0.3,0.3
	c-0.1,0.1-0.2,0.1-0.3,0.1c-0.1,0-0.2,0-0.3-0.1c-0.1,0-0.2,0-0.3-0.1c-0.1,0-0.3,0-0.4,0c-0.1,0-0.3,0-0.4,0.1
	c-0.1,0-0.2,0.1-0.3,0.2C9.1,9.6,9,9.8,9,10.1c0,0.3,0,0.5,0.1,0.8c0.1,0.2,0.1,0.3,0,0.5c-0.1,0.1-0.1,0.1-0.2,0.2
	c-0.1,0.1-0.2,0.1-0.4,0.2c-0.1,0.1-0.3,0.1-0.4,0.1C7.9,12,7.8,12,7.6,12c-0.1,0-0.2,0-0.2-0.1c-0.1-0.1-0.1-0.1-0.1-0.2h0
	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6,8.8z M6,8.8" Fill="{Binding (TextElement.Foreground), ElementName=contentPresenter, Mode=OneTime}" />
                                        </cc:SimpleButton>
                                        <Border x:Name="radioButtonBorder" Grid.Column="2" Margin="10,0,0,0" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="100" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="True" >
                                            <Ellipse x:Name="optionMark" Margin="3" Fill="#398dff" MinWidth="6" MinHeight="6" Opacity="0" SnapsToDevicePixels="True" />
                                        </Border>
                                    </Grid>

                                </Border>
                                <ControlTemplate.Triggers>
                                    <!--<Trigger Property="IsSelected" Value="True">
                                        <Setter Property="Opacity" TargetName="optionMark" Value="1" />
                                        <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="#398dff"/>
                                        <Setter Property="Visibility" TargetName="setting" Value="Visible" />
                                    </Trigger>-->
                                    <MultiDataTrigger>
                                        <MultiDataTrigger.Conditions>
                                            <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True" />
                                            <Condition Binding="{Binding IsShowSettings}" Value="True" />
                                        </MultiDataTrigger.Conditions>
                                        <Setter Property="Opacity" TargetName="optionMark" Value="1" />
                                        <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="#398dff"/>
                                        <Setter Property="Visibility" TargetName="setting" Value="Visible" />
                                    </MultiDataTrigger>
                                    <MultiDataTrigger>
                                        <MultiDataTrigger.Conditions>
                                            <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True" />
                                            <Condition Binding="{Binding IsShowSettings}" Value="False" />
                                        </MultiDataTrigger.Conditions>
                                        <Setter Property="Opacity" TargetName="optionMark" Value="1" />
                                        <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="#398dff"/>
                                        <Setter Property="Visibility" TargetName="setting" Value="Hidden" />
                                    </MultiDataTrigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </cc:NavList.ItemContainerStyle>
            <cc:NavList.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Name}" />
                </DataTemplate>
            </cc:NavList.ItemTemplate>
            <data:OverlayItem Name="Bollinger Bands" Tag="Bollinger Bands" Type="{x:Static data:OverlayType.BollingerBands}" />
            <data:OverlayItem Name="Envelopes" Tag="Envelopes" Type="{x:Static data:OverlayType.Envelopes}" />
            <data:OverlayItem Name="Fibonacci Retracements" Tag="Fibonacci Retracements" Type="{x:Static data:OverlayType.FibonacciRetracements}" />
            <data:OverlayItem Name="Fibonacci Arcs" Tag="Fibonacci Arcs" Type="{x:Static data:OverlayType.FibonacciArcs}" IsShowSettings="False" />
            <data:OverlayItem Name="Fibonacci Fans" Tag="Fibonacci Fans" Type="{x:Static data:OverlayType.FibonacciFans}" IsShowSettings="False" />
            <data:OverlayItem Name="Fibonacci Time Zones" Tag="Fibonacci Time Zones" Type="{x:Static data:OverlayType.FibonacciTimeZones}" />
            <data:OverlayItem Name="Pivot &amp; Point" Tag="Pivot Point" Type="{x:Static data:OverlayType.PivotPoint}" />
        </cc:NavList>
        <Rectangle HorizontalAlignment="Stretch" Height="1" Margin="0, 5" Fill="#D3D3D3" SnapsToDevicePixels="True" />
        <cc:FlatButton Content="Clear" Margin="10,5" Background="{StaticResource Blue500}" BorderBrush="{StaticResource Blue700}"
                       Foreground="{StaticResource PaperWhite1000}"
                         Command="{Binding ClearCommand}" CommandParameter="{Binding ElementName=listbox}" />
    </StackPanel>
</UserControl>
