<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="clr-namespace:ClassIsland.Controls;assembly=ClassIsland"
                    xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
                    xmlns:ci="http://classisland.tech/schemas/xaml/core"
                    xmlns:system="clr-namespace:System;assembly=mscorlib"
                    xmlns:classIsland="clr-namespace:ClassIsland;assembly=ClassIsland">
    <ci:SolidColorBrushToColorConverter x:Key="SolidColorBrushToColorConverter"/>

    <Style TargetType="{x:Type Grid}" x:Key="GridComponentPresenterContainerStyle">
        <Style.Triggers>
            <Trigger Property="IsVisible" Value="True">
                <Trigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)">
                                <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.00"/>
                                <EasingDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1">
                                    <EasingDoubleKeyFrame.EasingFunction>
                                        <SineEase EasingMode="EaseOut"/>
                                    </EasingDoubleKeyFrame.EasingFunction>
                                </EasingDoubleKeyFrame>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                                <EasingDoubleKeyFrame KeyTime="00:00:00.0000000" Value="-60"/>
                                <EasingDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0">
                                    <EasingDoubleKeyFrame.EasingFunction>
                                        <SineEase EasingMode="EaseOut"/>
                                    </EasingDoubleKeyFrame.EasingFunction>
                                </EasingDoubleKeyFrame>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.EnterActions>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type ci:ComponentPresenter}" >
        <Style.Triggers>
            <Trigger Property="IsRootComponent" Value="True">
                <Setter Property="Template" >
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ci:ComponentPresenter}">
                            <Grid Style="{StaticResource GridComponentPresenterContainerStyle}">
                                <Grid.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform />
                                        <SkewTransform />
                                        <RotateTransform />
                                        <TranslateTransform Y="-60" />
                                    </TransformGroup>
                                </Grid.RenderTransform>
                                <Border CornerRadius="10" Padding="15 0"
                                            Background="{DynamicResource MaterialDesignBackground}" 
                                            Height="60"
                                            Opacity="{Binding ViewModel.Settings.Opacity, RelativeSource={RelativeSource AncestorType=classIsland:MainWindow}}"
                                            > 
                                </Border>
                                <Border CornerRadius="10" Padding="15 0"
                                        Height="60"
                                        BorderBrush="{DynamicResource PrimaryHueMidBrush}" BorderThickness="0.75"
                                        >
                                    <Grid>
                                        <Grid>
                                            <Grid.Style>
                                                <Style TargetType="{x:Type Grid}">
                                                    <Style.Triggers>
                                                        <MultiDataTrigger>
                                                            <MultiDataTrigger.Conditions>
                                                                <Condition Binding="{Binding Id}" Value="1db2017d-e374-4bc6-9d57-0b4adf03a6b8"/>
                                                            </MultiDataTrigger.Conditions>
                                                            <Setter Property="Visibility" Value="Visible"/>
                                                        </MultiDataTrigger>
                                                    </Style.Triggers>
                                                    <Setter Property="Visibility" Value="Collapsed"/>
                                                </Style>    
                                            </Grid.Style>
                                            <Canvas>
                                                <!-- 这里可以替换成你喜欢的图片 -->
                                                <Image Source="pack://application:,,,/ClassIsland;component/Assets/HoYoStickers/藿藿_好痛.png"
                                                       Height="80" Width="80" Stretch="UniformToFill"
                                                       Canvas.Top="-10" Canvas.Right="0"
                                                       Opacity="0.4">
                                                </Image> 
                                            </Canvas>
                                        </Grid> 
                                        <TextBlock Text="{Binding AssociatedComponentInfo.Name}" HorizontalAlignment="Center"
                                                FontSize="12"
                                                Margin="0 4 0 0"
                                                Opacity="0.8"/>
                                        <Grid Height="40" VerticalAlignment="Bottom">
                                            <ContentPresenter Content="{Binding Content, RelativeSource={RelativeSource AncestorType= ci:ComponentPresenter}}" />
                                        </Grid>
                                    </Grid>   
                                </Border>
                                <Border CornerRadius="10" Padding="15 0"
                                        Height="60"
                                        BorderBrush="{DynamicResource PrimaryHueMidBrush}" BorderThickness="0.75"
                                        >
                                    <Border.Effect>
                                        <DropShadowEffect BlurRadius="8" ShadowDepth="0" Opacity="0.8"  Color="{Binding BorderBrush, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Border}, Converter={StaticResource SolidColorBrushToColorConverter}}"/>
                                    </Border.Effect>
                                </Border>
                            </Grid>
                        </ControlTemplate> 
                    </Setter.Value>
                </Setter>  
            </Trigger>
            
        </Style.Triggers>
    </Style>


    
    <!-- 覆盖行容器外观，可以通过修改其中的控件模板来自定义行容器外观 -->
    <Style BasedOn="{StaticResource MainWindowLineBaseStyle}" TargetType="{x:Type controls:MainWindowLine}">
        <Style.Resources>
            <!-- 行容器高度 -->
            <system:Double x:Key="IslandContainerHeight">NaN</system:Double>
        </Style.Resources>
        <!-- <Setter Property="Height" Value="60"/> -->
        <Style.Triggers>
            <Trigger Property="IsMainLine" Value="False">
                <Setter Property="Template">
                    <Setter.Value>
                        <!-- 行容器控件模板 -->
                        <ControlTemplate x:Key="MainWindowLineMinControlTemplate">
                            <Grid 
                                ClipToBounds="True"
                                Style="{StaticResource DockingStyle}">
                                <Grid x:Name="PART_GridWrapper" ClipToBounds="True"
                                    Height="{DynamicResource IslandContainerHeight}"
                                    SnapsToDevicePixels="True"
                                    Style="{StaticResource DockingStyle}">

                                    <Grid Height="{DynamicResource IslandContainerHeight}"
                                        x:Name="GridContentRoot"
                                        Margin="12 0">
                                        <ContentPresenter
                                            Content="{Binding Content, RelativeSource={RelativeSource AncestorType=controls:MainWindowLine}}" />
                                    </Grid>
                                </Grid>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="Visibility" Value="{Binding IsAllComponentsHid, RelativeSource={RelativeSource Self}, Converter={StaticResource InverseBoolToVisConverter}}"/>
            </Trigger>
        </Style.Triggers>
        <Setter Property="Template">
            <Setter.Value>
                <!-- 完整行容器控件模板 -->
                <ControlTemplate x:Key="MainWindowLineFullControlTemplate">
                    <Grid>
                        <Grid.Effect>
                            <DropShadowEffect BlurRadius="8" Direction="0" 
                                            ShadowDepth="0" Opacity="0"
                                            x:Name="RootDropShadowEffect"
                                            Color="Black"/>
                        </Grid.Effect>
                        <Grid
                            ClipToBounds="True"
                            Style="{StaticResource DockingStyle}">
                            <!-- Background -->
                            <Border x:Name="BackgroundBorderOverlay"
                                    Style="{StaticResource BackgroundBorderStyle}"
                                    Width="{Binding ActualWidth, ElementName=BackgroundBorder, Mode=OneWay}"
                                    Opacity="0"
                                    SnapsToDevicePixels="True"
                                    Height="{DynamicResource IslandContainerHeight}">
                            </Border>
                            <Grid
                                Style="{StaticResource DockingStyle}"
                                Width="{Binding BackgroundWidth, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType=controls:MainWindowLine}}"
                                Height="{DynamicResource IslandContainerHeight}"
                                SnapsToDevicePixels="True"
                                ClipToBounds="True">
                                <materialDesign:ColorZone x:Name="BackgroundBorderOverlayMask" Mode="PrimaryMid"
                                                        VerticalAlignment="Stretch"
                                                        RenderTransformOrigin="0.5,0.5">
                                    <materialDesign:ColorZone.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform />
                                            <SkewTransform />
                                            <RotateTransform />
                                            <TranslateTransform Y="-60" />
                                        </TransformGroup>
                                    </materialDesign:ColorZone.RenderTransform>
                                </materialDesign:ColorZone>
                            </Grid>

                            <Grid x:Name="PART_GridWrapper" ClipToBounds="True"
                                Height="{DynamicResource IslandContainerHeight}"
                                SnapsToDevicePixels="True"
                                Style="{StaticResource DockingStyle}">

                                <Grid Height="{DynamicResource IslandContainerHeight}"
                                    x:Name="GridContentRoot"
                                    Margin="12 0">
                                    <ContentPresenter
                                        Content="{Binding Content, RelativeSource={RelativeSource AncestorType=controls:MainWindowLine}}" />
                                </Grid>
                            
                                <!-- Overlay View -->
                                <Grid x:Name="GridOverlay"
                                    SnapsToDevicePixels="True"
                                    ClipToBounds="True"
                                    Opacity="0">
                                    <Border Background="{DynamicResource MaterialDesignBackground}"
                                            Opacity="{Binding ViewModel.Settings.Opacity, RelativeSource={RelativeSource AncestorType=classIsland:MainWindow}}"/>
                                    <Border ClipToBounds="True">
                                        <ProgressBar VerticalAlignment="Bottom"
                                                    Maximum="1"
                                                    Value="{Binding NotificationProgressBarValue, RelativeSource={RelativeSource AncestorType=classIsland:MainWindow}}"
                                                    x:Name="OverlayTimeProgressBar"
                                                    materialDesign:TransitionAssist.DisableTransitions="True"
                                                    Height="3"
                                                    Foreground="{DynamicResource PrimaryHueMidBrush}"
                                                    Background="Transparent"
                                                    BorderBrush="Transparent">
                                            <ProgressBar.Effect>
                                                <DropShadowEffect BlurRadius="12" ShadowDepth="0" Opacity="1"  Color="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ProgressBar}, Converter={StaticResource SolidColorBrushToColorConverter}}"/>
                                            </ProgressBar.Effect>
                                        </ProgressBar>
                                    </Border>
                                    <ContentPresenter
                                        Content="{Binding ViewModel.CurrentOverlayElement, RelativeSource={RelativeSource FindAncestor, AncestorType=classIsland:MainWindow}}" />

                                </Grid>

                                <!-- Mask -->
                                <materialDesign:ColorZone x:Name="OverlayMask" Mode="PrimaryMid" HorizontalAlignment="Stretch"
                                                        VerticalAlignment="Stretch"
                                                        RenderTransformOrigin="0.5,0.5"
                                                        SnapsToDevicePixels="True">
                                    <materialDesign:ColorZone.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform />
                                            <SkewTransform />
                                            <RotateTransform />
                                            <TranslateTransform Y="-60" />
                                        </TransformGroup>
                                    </materialDesign:ColorZone.RenderTransform>
                                    <ContentPresenter x:Name="OverlayMaskContent"
                                                    Content="{Binding ViewModel.CurrentMaskElement, RelativeSource={RelativeSource FindAncestor, AncestorType=classIsland:MainWindow}}" />
                                </materialDesign:ColorZone>
                            </Grid>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

    </Style>

</ResourceDictionary>