<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:c1tb="clr-namespace:C1.WPF.Toolbar"
    xmlns:c1="clr-namespace:C1.WPF;assembly=C1.WPF.4"
    xmlns:system="clr-namespace:System;assembly=mscorlib"
>
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/C1.WPF.4;component/themes/Common.xaml" />
        <ResourceDictionary Source="/C1.WPF.4;component/themes/C1TabControl.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <SolidColorBrush x:Key="SimplifiedToolbarBackground" Color="#FFF0F3F5" />
    
    <LinearGradientBrush x:Key="ToolbarGroupHeaderBackground" StartPoint="0.5,0" EndPoint="0.5,1">
        <GradientStop Color="#FFCBDAE9" Offset="1" />
        <GradientStop Color="#FFBCD1E4" Offset="0" />
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="SimplifiedRibbonMouseOverBrush" StartPoint="0.5,0" EndPoint="0.5,1">
        <GradientStop Color="#FFDADADA" Offset="0" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="SimplifiedRibbonSelectedBackgroundBrush" StartPoint="0.5,0" EndPoint="0.5,1">
        <GradientStop Color="#FFDADADA" Offset="0" />
    </LinearGradientBrush>

    <c1tb:BooleanToVisibilityConverter x:Key="BoolToVis" />


    <Style TargetType="c1tb:C1SimplifiedTabControl">
        <Setter Property="Background" Value="{StaticResource BaseColorBrush}" />
        <Setter Property="TabStripBackground" Value="{StaticResource BaseColorBrush}" />
        <Setter Property="TabStripForeground" Value="{StaticResource ForegroundTextBoxBrushColor}" />
        <Setter Property="BorderBrush" Value="{StaticResource BorderBrush}" />
        <Setter Property="TabStripOverlap" Value="0" />
        <Setter Property="BorderThickness" Value="{StaticResource GeneralThickness}" />
        <Setter Property="Foreground" Value="{StaticResource ForegroundTextBoxBrushColor}" />
        <Setter Property="TabItemShape" Value="Rounded" />
        <Setter Property="TabStripPlacement" Value="Top" />
        <Setter Property="Padding" Value="0" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="c1tb:C1SimplifiedTabControl">
                    <Grid x:Name="Root">
                        <c1:C1BrushBuilder x:Name="BackgroundBrush" Input="{TemplateBinding Background}" DesignBrush="{StaticResource SimplifiedToolbarBackground}" DesignColor="{StaticResource BaseColor}" />

                        <c1:C1LinePanel x:Name="LineOuter" Margin="{TemplateBinding Padding}" Orientation="Vertical">
                            <c1:C1LinePanel.LineDefinitions>
                                <c1:LineDefinition Length="Auto" />
                                <c1:LineDefinition Length="*" />
                            </c1:C1LinePanel.LineDefinitions>

                            <!-- Tab Items section -->
                            <!-- Put tab items before content so tab key navigation finds the items first. -->
                            <c1:C1LinePanel Canvas.ZIndex="100" x:Name="LineTabItems" Orientation="Horizontal">
                                <c1:C1LinePanel.LineDefinitions>
                                    <c1:LineDefinition Length="Auto" />
                                    <c1:LineDefinition Length="*" />
                                    <c1:LineDefinition Length="Auto" />
                                    <c1:LineDefinition Length="Auto" />
                                    <c1:LineDefinition Length="Auto" />
                                </c1:C1LinePanel.LineDefinitions>

                                <RepeatButton x:Name="PreviousButton" Height="15" Width="15" Style="{StaticResource ClearStyleButtonStyle}" c1:ClearStyleExtensions.MouseOverBrush="{TemplateBinding MouseOverBrush}" c1:ClearStyleExtensions.PressedBrush="{TemplateBinding PressedBrush}" c1:ClearStyleExtensions.CornerRadius="0" Background="{TemplateBinding TabStripBackground}" Foreground="{TemplateBinding Foreground}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Margin="2" RenderTransformOrigin="0.5,0.5" ToolTipService.ToolTip="{Binding Path=Previous, Source={StaticResource Resources}}">
                                    <RepeatButton.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform />
                                            <SkewTransform />
                                            <RotateTransform />
                                            <TranslateTransform />
                                        </TransformGroup>
                                    </RepeatButton.RenderTransform>
                                    <Path Data="M5.3,1E-07 L7,1E-07 L4.7,2.5 L7,5 L5.3,5 L3,2.5 z M2.3,0 L4,0 L1.7,2.5 L4,5 L2.3,5 L0,2.5 z" Width="7" Height="5" Fill="{TemplateBinding TabStripForeground}" Stretch="Uniform" HorizontalAlignment="Right" />
                                </RepeatButton>

                                <!-- TabPanel -->
                                <ContentPresenter x:Name="TabPanelPresenter">
                                    <ContentPresenter.Content>
                                        <Grid>
                                            <c1:C1TabPanel x:Name="TabPanel" Orientation="Horizontal" HorizontalAlignment="{TemplateBinding TabStripHorizontalAlignment}" VerticalAlignment="{TemplateBinding TabStripVerticalAlignment}" />
                                            <Canvas>
                                                <Rectangle
                                                x:Name="Marquee" Height="3" Canvas.Bottom="1"
                                                Fill="{Binding Path=MarqueeBrush, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type c1tb:C1SimplifiedRibbon}}}" 
                                            >
                                                    <Rectangle.RenderTransform>
                                                        <TransformGroup>
                                                            <ScaleTransform x:Name="MarqueeScale" />
                                                            <TranslateTransform x:Name="MarqueeTrans" />
                                                        </TransformGroup>
                                                    </Rectangle.RenderTransform>
                                                </Rectangle>
                                            </Canvas>
                                        </Grid>
                                    </ContentPresenter.Content>
                                </ContentPresenter>

                                <RepeatButton x:Name="NextButton" Grid.Column="3" Height="15" Width="15" Style="{StaticResource ClearStyleButtonStyle}" c1:ClearStyleExtensions.MouseOverBrush="{TemplateBinding MouseOverBrush}" c1:ClearStyleExtensions.PressedBrush="{TemplateBinding PressedBrush}" c1:ClearStyleExtensions.CornerRadius="0" Background="{TemplateBinding TabStripBackground}" Foreground="{TemplateBinding Foreground}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Margin="2" RenderTransformOrigin="0.5,0.5" ToolTipService.ToolTip="{Binding Path=Next, Source={StaticResource Resources}}">
                                    <RepeatButton.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform />
                                            <SkewTransform />
                                            <RotateTransform />
                                            <TranslateTransform />
                                        </TransformGroup>
                                    </RepeatButton.RenderTransform>
                                    <Path Data="M3,0 L4.67,0 L7,2.5 L4.67,5 L3,5 L5.3,2.5 z M0,0 L1.67,0 L4,2.5 L1.67,5 L0,5 L2.3,2.5 z" Width="7" Height="5" Fill="{TemplateBinding TabStripForeground}" Stretch="Uniform" SnapsToDevicePixels="True" />
                                </RepeatButton>
                                <!-- Close -->
                                <Button x:Name="CloseButton" Height="15" Width="15" Margin="2 2 4 2"                                         
                                        VerticalAlignment="Center" 
                                        Style="{StaticResource ClearStyleButtonStyle}" 
                                        c1:ClearStyleExtensions.MouseOverBrush="{TemplateBinding MouseOverBrush}" 
                                        c1:ClearStyleExtensions.PressedBrush="{TemplateBinding PressedBrush}" c1:ClearStyleExtensions.CornerRadius="0" 
                                        Background="Transparent" Foreground="{TemplateBinding Foreground}" 
                                        BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" 
                                        ToolTipService.ToolTip="{Binding Path=CloseGlobal, Source={StaticResource Resources}}">
                                    <Path Data="M0,0 L1.6,0 L3,1.56 L4.4,0 L6,0 L3.8,2.5 L6,5 L4.4,5 L3,3.49 L1.59,5 L-4.2E-09,5 L2.18,2.5 z" Width="7" Height="6" Fill="{TemplateBinding TabStripForeground}" Stretch="Uniform" SnapsToDevicePixels="True" />
                                </Button>

                                <!-- Collapse/Expand -->
                                <ToggleButton x:Name="CollapseButton" Background="Transparent" BorderThickness="0" Height="22" Width="22">
                                    <ToggleButton.RenderTransform>
                                        <RotateTransform CenterX="11" CenterY="11" Angle="180" />
                                    </ToggleButton.RenderTransform>
                                    <c1:C1SVGIcon Data="m121.3,34.6c-1.6-1.6-4.2-1.6-5.8,0l-51,51.1-51.1-51.1c-1.6-1.6-4.2-1.6-5.8,0-1.6,1.6-1.6,4.2 0,5.8l53.9,53.9c0.8,0.8 1.8,1.2 2.9,1.2 1,0 2.1-0.4 2.9-1.2l53.9-53.9c1.7-1.6 1.7-4.2 0.1-5.8z" Width="10" Height="8" StrokeThickness="1" Foreground="#FF505860" />
                                </ToggleButton>
                            </c1:C1LinePanel>

                            <Border x:Name="SelectedItemContentBorder"  Background="{Binding ElementName=BackgroundBrush, Path=Output}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" >
                                <ContentPresenter x:Name="SelectedItemContent" ContentTemplate="{x:Null}" />
                            </Border>
                        </c1:C1LinePanel>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="c1tb:C1SimplifiedTabItem">
        <Setter Property="Padding" Value="8,0" />
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrushColor}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="c1tb:C1SimplifiedTabItem">
                    <Border Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>

                            <ContentPresenter Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Grid.Column="0" />

                            <Button x:Name="CloseButton" Grid.Column="1" Height="15" Width="15" 
                                    Style="{StaticResource ClearStyleButtonStyle}" 
                                    c1:ClearStyleExtensions.MouseOverBrush="{TemplateBinding MouseOverBrush}" 
                                    c1:ClearStyleExtensions.PressedBrush="{TemplateBinding PressedBrush}" c1:ClearStyleExtensions.CornerRadius="0" 
                                    Background="Transparent" Foreground="{TemplateBinding Foreground}" 
                                    BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" VerticalAlignment="Center" HorizontalAlignment="Right" 
                                    Margin="5 0 -6 0" ToolTipService.ToolTip="{Binding Path=Close, Source={StaticResource Resources}}">
                                <Path Data="M0,0 L1.6,0 L3,1.56 L4.4,0 L6,0 L3.8,2.5 L6,5 L4.4,5 L3,3.49 L1.59,5 L-4.2E-09,5 L2.18,2.5 z" Fill="{TemplateBinding Foreground}" Stretch="Uniform" Width="7" Height="6" />
                            </Button>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="c1tb:C1SimplifiedRibbonGroup">
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrushColor}" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <c1tb:C1SimplifiedGroupPanel />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="c1tb:C1SimplifiedRibbonGroup">
                    <Grid Margin="0, 5, 0, 0">
                        <c1:C1BrushBuilder x:Name="BackgroundBrush" Input="{TemplateBinding Background}" DesignBrush="{StaticResource SimplifiedToolbarBackground}" DesignColor="{StaticResource BaseColor}" />
                        <c1:C1BrushBuilder x:Name="HeaderBackgroundBrush" Input="{TemplateBinding Background}" DesignBrush="{StaticResource ToolbarGroupHeaderBackground}" DesignColor="{StaticResource BaseColor}" />
                        <c1:C1BrushBuilder x:Name="InnerBorderBrush" Input="{TemplateBinding Background}" DesignColor="{StaticResource BaseColor}" />
                        <c1:C1BrushBuilder x:Name="PopupBorderBrush" Input="{TemplateBinding BorderBrush}" DesignColor="{StaticResource BorderColor}" />
                        <Grid x:Name="Normal">
                            <Border x:Name="BackgroundElement" BorderThickness="0 0 2 0" BorderBrush="{StaticResource WpfInputSelectedBackground}" Margin="0,4" Padding="5,0">
                                <Border x:Name="InnerBorderElement" BorderBrush="{Binding ElementName=InnerBorderBrush, Path=Output}">
                                    <Grid x:Name="NormalGrid">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <ItemsPresenter x:Name="Items" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Grid.Row="0" />

                                        <Border x:Name="HeaderBackgroundElement" Grid.Row="1" Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type c1tb:C1SimplifiedRibbon}}, Path=IsCollapsed, Converter={StaticResource BoolToVis}}">
                                            <Grid>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition />
                                                    <ColumnDefinition Width="Auto" />
                                                </Grid.ColumnDefinitions>
                                                <ContentPresenter HorizontalAlignment="Center" Content="{TemplateBinding Header}"/>
                                                <Button x:Name="DialogLauncher" Visibility="Collapsed" Grid.Column="1">
                                                    <Path Data="M6,3 L7,3 L7,4 L7,6 L7,7 L6,7 L4,7 L3,7 L3,6 L4,6 L4,4 L6,4 z M3,3 L4,3 L4,4 L3,4 z M0,0 L1,0 L6,0 L6,1 L1,1 L1,6 L0,6 z" Fill="Black" Stretch="Uniform" />
                                                </Button>
                                            </Grid>
                                        </Border>
                                    </Grid>
                                </Border>
                            </Border>
                        </Grid>
                        <Grid x:Name="Collapsed" Visibility="Collapsed">
                            <c1:C1DropDownButton x:Name="DropDown" AutoClose="True" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" BorderBrush="{TemplateBinding BorderBrush}" MouseOverBrush="{TemplateBinding MouseOverBrush}" PressedBrush="{TemplateBinding PressedBrush}" HeaderBackground="{TemplateBinding Background}" HeaderForeground="{TemplateBinding Foreground}" VerticalHeaderAlignment="Center" HorizontalHeaderAlignment="Center">
                                <c1:C1DropDownButton.Header>
                                    <Grid>
                                        <TextBlock Grid.Row="1" Text="{TemplateBinding Header}" TextTrimming="WordEllipsis" TextAlignment="Center" VerticalAlignment="Center" />
                                    </Grid>
                                </c1:C1DropDownButton.Header>
                                <c1:C1DropDownButton.Content>
                                    <Border BorderBrush="{Binding ElementName=PopupBorderBrush, Path=Output}" BorderThickness="{StaticResource GeneralThickness}">
                                        <Grid x:Name="CollapsedGrid">
                                            <Grid.RowDefinitions>
                                                <RowDefinition />
                                                <RowDefinition Height="Auto" />
                                            </Grid.RowDefinitions>
                                            <Border Grid.Row="1" Background="{Binding ElementName=HeaderBackgroundBrush, Path=Output}">
                                                <Grid>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition />
                                                        <ColumnDefinition Width="Auto" />
                                                    </Grid.ColumnDefinitions>

                                                    <TextBlock Text="{TemplateBinding Header}" TextTrimming="WordEllipsis" TextAlignment="Center" VerticalAlignment="Center" />
                                                    <Button x:Name="DialogLauncherCollapsed" Visibility="Visible" Grid.Column="1">
                                                        <Path Data="M6,3 L7,3 L7,4 L7,6 L7,7 L6,7 L4,7 L3,7 L3,6 L4,6 L4,4 L6,4 z M3,3 L4,3 L4,4 L3,4 z M0,0 L1,0 L6,0 L6,1 L1,1 L1,6 L0,6 z" Fill="Black" Stretch="Uniform" />
                                                    </Button>
                                                </Grid>
                                            </Border>
                                        </Grid>
                                    </Border>
                                </c1:C1DropDownButton.Content>
                            </c1:C1DropDownButton>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
