<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="clr-namespace:AIStudio.Wpf.Mind.Controls"
                    xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Mind;component/Styles/Button.xaml" />
        <ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Mind;component/Styles/ContextMenu.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <dd:BrushOpacityConverter x:Key="BrushOpacityConverter"/>

    <Style x:Key="MenuItemStyle" TargetType="{x:Type MenuItem}">
        <Setter Property="Padding" Value="6"/>
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="ScrollViewer.PanningMode" Value="Both" />
        <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
        <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type MenuItem}">
                    <Grid Margin="{TemplateBinding Margin}" SnapsToDevicePixels="True">
                        <Border x:Name="templateRoot"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}"
                            SnapsToDevicePixels="True" />
                        <Border x:Name="BackgroundRoot"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="LightGray"
                            SnapsToDevicePixels="True"
                            Opacity="0" />
                        <ContentPresenter Margin="{TemplateBinding Padding}" VerticalAlignment="Center" HorizontalAlignment="Center" ContentSource="Header" RecognizesAccessKey="True"/>
                    </Grid>
                    <ControlTemplate.Triggers>                     
                        <Trigger Property="IsHighlighted" Value="True">
                            <Setter TargetName="BackgroundRoot" Property="Opacity" Value="0.5" />
                        </Trigger>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="BackgroundRoot" Property="Opacity" Value="1" />
                            <Setter TargetName="BackgroundRoot" Property="Background" Value="#73a1bf" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" Value=".5" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

    </Style>

    <Style x:Key="DropDownButtonStyle" TargetType="{x:Type controls:DropDownButton}">
        <Setter Property="ArrowBrush" Value="Black" />
        <Setter Property="ArrowMouseOverBrush" 
                Value="{Binding Foreground, RelativeSource={RelativeSource Mode=Self},
                    Converter={StaticResource BrushOpacityConverter}, ConverterParameter=0.16}" />
        <Setter Property="ArrowPressedBrush" Value="Black" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="ButtonStyle" Value="{StaticResource AIStudio.Mind.Styles.Button.Flat}" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Foreground" Value="Black" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="MenuStyle" Value="{StaticResource AIStudio.Mind.Styles.ContextMenu}" />
        <Setter Property="ItemContainerStyle" Value="{StaticResource MenuItemStyle}" />
        <Setter Property="MinHeight" Value="26" />
        <Setter Property="Padding" Value="3" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:DropDownButton}">
                    <Grid>
                        <Border x:Name="PART_Border"
                            Background="Transparent"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="3"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                            UseLayoutRounding="True">
                            <Button x:Name="PART_Button"
                                    HorizontalAlignment="Stretch"
                                    VerticalAlignment="Stretch"
                                    HorizontalContentAlignment="Stretch"
                                    VerticalContentAlignment="Stretch"
                                    Background="{TemplateBinding Background}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    FocusVisualStyle="{TemplateBinding FocusVisualStyle}"
                                    Foreground="{TemplateBinding Foreground}"
                                    RenderOptions.ClearTypeHint="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(RenderOptions.ClearTypeHint), Mode=OneWay}"
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                    Style="{TemplateBinding ButtonStyle}">
                                <DockPanel x:Name="PART_Content"
                                           Focusable="False"
                                           LastChildFill="True">
                                    <!--  Material - ChevronDown  -->
                                    <Path x:Name="PART_Arrow"
                                                  Width="9"
                                                  Height="6"
                                                  Margin="0 0 3 0"
                                                  HorizontalAlignment="Center"
                                                  VerticalAlignment="Center"
                                                  Data="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z"
                                                  DockPanel.Dock="Right"
                                                  Stretch="Fill"
                                                  Fill="{TemplateBinding ArrowBrush}"
                                                  Visibility="{TemplateBinding ArrowVisibility}" />
                                    <StackPanel x:Name="PART_ContentOrientation"
                                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                Focusable="False"
                                                Orientation="Horizontal">
                                        <ContentPresenter HorizontalAlignment="Center"
                                                          VerticalAlignment="Center"
                                                          Content="{TemplateBinding Icon}"
                                                          ContentTemplate="{TemplateBinding IconTemplate}"
                                                          Focusable="False"
                                                          RecognizesAccessKey="True"
                                                          UseLayoutRounding="False" />
                                        <ContentControl x:Name="PART_ButtonContent"
                                                              Padding="{TemplateBinding Padding}"
                                                              HorizontalAlignment="Center"
                                                              VerticalAlignment="Center"
                                                              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                                              Content="{Binding Content, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"                                                             
                                                              ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                                              ContentTemplate="{TemplateBinding ContentTemplate}"
                                                              ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                              UseLayoutRounding="False" />
                                    </StackPanel>
                                </DockPanel>
                                <Button.ContextMenu>
                                    <ContextMenu x:Name="PART_Menu"
                                                 MinWidth="{TemplateBinding ActualWidth}"
                                                 DisplayMemberPath="{TemplateBinding DisplayMemberPath}"
                                                 GroupStyleSelector="{TemplateBinding GroupStyleSelector}"
                                                 IsOpen="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                                 ItemContainerStyle="{TemplateBinding ItemContainerStyle}"
                                                 ItemContainerStyleSelector="{TemplateBinding ItemContainerStyleSelector}"
                                                 ItemStringFormat="{TemplateBinding ItemStringFormat}"
                                                 ItemTemplate="{TemplateBinding ItemTemplate}"
                                                 ItemTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                                 ItemsPanel="{TemplateBinding ItemsPanel}"
                                                 ItemsSource="{TemplateBinding ItemsSource}"
                                                 Placement="Bottom"
                                                 StaysOpen="False"
                                                 Style="{TemplateBinding MenuStyle}"
                                                 UseLayoutRounding="False" />
                                </Button.ContextMenu>
                            </Button>

                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Content" Value="{x:Null}">
                            <Setter TargetName="PART_ButtonContent" Property="Margin" Value="0" />
                        </Trigger>
                        <Trigger Property="Orientation" Value="Vertical">
                            <Setter TargetName="PART_Arrow" Property="DockPanel.Dock" Value="Bottom" />
                            <Setter TargetName="PART_Arrow" Property="Margin" Value="0 0 0 3" />
                            <Setter TargetName="PART_ContentOrientation" Property="Orientation" Value="Vertical" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition SourceName="PART_Button" Property="IsEnabled" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="PART_Arrow" Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ArrowMouseOverBrush, Mode=OneWay}" />
                        </MultiTrigger>
                        <Trigger SourceName="PART_Button" Property="IsPressed" Value="True">
                            <Setter TargetName="PART_Arrow" Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ArrowPressedBrush, Mode=OneWay}" />
                        </Trigger>
                        <Trigger SourceName="PART_Button" Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" Value=".55" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Style.Triggers>
            <Trigger Property="IsFocused" Value="True">
                <Setter Property="BorderBrush" Value="LightGray" />
            </Trigger>
            <Trigger Property="IsKeyboardFocusWithin" Value="True">
                <Setter Property="BorderBrush" Value="LightGray" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Opacity" Value=".55" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type controls:DropDownButton}" BasedOn="{StaticResource DropDownButtonStyle}" />

</ResourceDictionary>