Files
ShrlAlgoToolkit/NeuWPF/NeuWPFTest/App.xaml

140 lines
10 KiB
Plaintext
Raw Normal View History

2025-07-31 20:12:24 +08:00
<Application
x:Class="NeuWPFTest.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2025-08-12 23:08:54 +08:00
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
2025-07-31 20:12:24 +08:00
xmlns:enu="https://github.com/ShrlAlgo/LucentUI"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
2025-08-12 23:08:54 +08:00
StartupUri="MainWindow.xaml">
2025-07-31 20:12:24 +08:00
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- <enu:ThemesDictionary Theme="Dark" /> -->
<!-- <enu:ControlsDictionary /> -->
2025-08-12 23:08:54 +08:00
<ResourceDictionary Source="pack://application:,,,/NeuWPF;component/Themes/Light.xaml" />
<!--<ResourceDictionary Source="pack://application:,,,/NeuWPF;component/Themes/Dark.xaml" />-->
2025-07-31 20:12:24 +08:00
<ResourceDictionary Source="pack://application:,,,/NeuWPF;component/Themes/Styles.xaml" />
<!-- <ResourceDictionary Source="pack://application:,,,/LucentUI;component/Themes/Extra.xaml" /> -->
</ResourceDictionary.MergedDictionaries>
2025-08-12 23:08:54 +08:00
<!-- 定义拟态风格的颜色 -->
<Color x:Key="NeumorphismBaseColor">#e0e5ec</Color>
<Color x:Key="NeumorphismDarkShadowColor">#a3b1c6</Color>
<Color x:Key="NeumorphismLightShadowColor">#ffffff</Color>
<SolidColorBrush x:Key="NeumorphismBaseBrush" Color="{StaticResource NeumorphismBaseColor}"/>
<Style x:Key="NeumorphicButtonLocal" TargetType="Button">
<Setter Property="Foreground" Value="#707070"/>
<Setter Property="Background" Value="{StaticResource NeumorphismBaseBrush}"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="RenderTransformOrigin" Value="0.5, 0.5"/>
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="1" ScaleY="1"/>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Border x:Name="ShadowContainer" Background="{StaticResource NeumorphismBaseBrush}" CornerRadius="20">
<Border.Effect>
<DropShadowEffect ShadowDepth="5" Direction="315" Color="{StaticResource NeumorphismDarkShadowColor}" Opacity="0.5" BlurRadius="10"/>
</Border.Effect>
</Border>
<Border x:Name="LightContainer" Background="{StaticResource NeumorphismBaseBrush}" CornerRadius="20">
<Border.Effect>
<DropShadowEffect ShadowDepth="-5" Direction="135" Color="{StaticResource NeumorphismLightShadowColor}" Opacity="1" BlurRadius="10"/>
</Border.Effect>
</Border>
<Border x:Name="MainBorder" Background="{TemplateBinding Background}" CornerRadius="10">
<Border x:Name="PressedEffectBorder" CornerRadius="10" Opacity="0">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="{StaticResource NeumorphismDarkShadowColor}" Offset="0.1"/>
<GradientStop Color="Transparent" Offset="0.5"/>
<GradientStop Color="{StaticResource NeumorphismLightShadowColor}" Offset="0.9"/>
</LinearGradientBrush>
</Border.Background>
</Border>
</Border>
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Content="{TemplateBinding Content}"/>
</Grid>
<!-- 将所有Triggers移到ControlTemplate内部 -->
<ControlTemplate.Triggers>
<!-- 按下状态的静态Trigger -->
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="ShadowContainer" Property="Opacity" Value="0"/>
<Setter TargetName="LightContainer" Property="Opacity" Value="0"/>
<Setter TargetName="PressedEffectBorder" Property="Opacity" Value="1"/>
</Trigger>
<!-- 动画 EventTriggers -->
<EventTrigger RoutedEvent="MouseEnter">
<BeginStoryboard>
<Storyboard>
<!-- 在这里TargetName可以正常工作 -->
<DoubleAnimation Storyboard.TargetName="ShadowContainer" Storyboard.TargetProperty="Effect.ShadowDepth" To="8" Duration="0:0:0.2"/>
<DoubleAnimation Storyboard.TargetName="LightContainer" Storyboard.TargetProperty="Effect.ShadowDepth" To="-8" Duration="0:0:0.2"/>
<DoubleAnimation Storyboard.TargetName="ShadowContainer" Storyboard.TargetProperty="Effect.BlurRadius" To="15" Duration="0:0:0.2"/>
<DoubleAnimation Storyboard.TargetName="LightContainer" Storyboard.TargetProperty="Effect.BlurRadius" To="15" Duration="0:0:0.2"/>
<!-- 没有TargetName默认作用于应用模板的控件(Button) -->
<DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" To="1.05" Duration="0:0:0.2"/>
<DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" To="1.05" Duration="0:0:0.2"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="MouseLeave">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="ShadowContainer" Storyboard.TargetProperty="Effect.ShadowDepth" To="5" Duration="0:0:0.2"/>
<DoubleAnimation Storyboard.TargetName="LightContainer" Storyboard.TargetProperty="Effect.ShadowDepth" To="-5" Duration="0:0:0.2"/>
<DoubleAnimation Storyboard.TargetName="ShadowContainer" Storyboard.TargetProperty="Effect.BlurRadius" To="10" Duration="0:0:0.2"/>
<DoubleAnimation Storyboard.TargetName="LightContainer" Storyboard.TargetProperty="Effect.BlurRadius" To="10" Duration="0:0:0.2"/>
<DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" To="1" Duration="0:0:0.2"/>
<DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" To="1" Duration="0:0:0.2"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="PreviewMouseDown">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" To="0.95" Duration="0:0:0.1"/>
<DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" To="0.95" Duration="0:0:0.1"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="PreviewMouseUp">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" To="1.05" Duration="0:0:0.5">
<DoubleAnimation.EasingFunction>
<ElasticEase EasingMode="EaseOut" Oscillations="2" Springiness="4"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
<DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" To="1.05" Duration="0:0:0.5">
<DoubleAnimation.EasingFunction>
<ElasticEase EasingMode="EaseOut" Oscillations="2" Springiness="4"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2025-07-31 20:12:24 +08:00
</ResourceDictionary>
2025-08-12 23:08:54 +08:00
2025-07-31 20:12:24 +08:00
</Application.Resources>
</Application>