mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
add color for enhanced count
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Microsoft.UI.Xaml;
|
||||
using Snap.Hutao.Control;
|
||||
using Snap.Hutao.Control.Theme;
|
||||
using Snap.Hutao.Win32;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Windows.UI;
|
||||
|
||||
namespace Snap.Hutao.View.Converter;
|
||||
|
||||
/// <summary>
|
||||
/// UInt32 转 色阶颜色
|
||||
/// </summary>
|
||||
[DependencyProperty("MaximumValue", typeof(int), 6)]
|
||||
[DependencyProperty("MinimumValue", typeof(int), 1)]
|
||||
[DependencyProperty("Maximum", typeof(Color))]
|
||||
[DependencyProperty("Minimum", typeof(Color))]
|
||||
internal sealed partial class UInt32ToGradientColorConverter : DependencyValueConverter<uint, Color>
|
||||
{
|
||||
public UInt32ToGradientColorConverter()
|
||||
{
|
||||
Maximum = StructMarshal.Color(0xFFFD0093);
|
||||
Minimum = StructMarshal.Color(0xFF4B00D9);
|
||||
}
|
||||
|
||||
public override Color Convert(uint from)
|
||||
{
|
||||
double n = Math.Clamp(from, MinimumValue, MaximumValue) - MinimumValue;
|
||||
int step = MaximumValue - MinimumValue;
|
||||
double a = Minimum.A + ((Maximum.A - Minimum.A) * n / step);
|
||||
double r = Minimum.R + ((Maximum.R - Minimum.R) * n / step);
|
||||
double g = Minimum.G + ((Maximum.G - Minimum.G) * n / step);
|
||||
double b = Minimum.B + ((Maximum.B - Minimum.B) * n / step);
|
||||
|
||||
Unsafe.SkipInit(out Color color);
|
||||
color.A = (byte)a;
|
||||
color.R = (byte)r;
|
||||
color.G = (byte)g;
|
||||
color.B = (byte)b;
|
||||
return color;
|
||||
}
|
||||
}
|
||||
@@ -28,19 +28,38 @@
|
||||
</mxi:Interaction.Behaviors>
|
||||
|
||||
<Page.Resources>
|
||||
<cwuconv:BoolToObjectConverter x:Key="BoolToOpacityConverter">
|
||||
<cwuconv:BoolToObjectConverter.TrueValue>
|
||||
<x:Double>1</x:Double>
|
||||
</cwuconv:BoolToObjectConverter.TrueValue>
|
||||
<cwuconv:BoolToObjectConverter.FalseValue>
|
||||
<x:Double>0.5</x:Double>
|
||||
</cwuconv:BoolToObjectConverter.FalseValue>
|
||||
</cwuconv:BoolToObjectConverter>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary x:Key="Light">
|
||||
<shvconv:UInt32ToGradientColorConverter
|
||||
x:Key="CountToGradientColorConverter"
|
||||
Maximum="#FFFD0093"
|
||||
Minimum="#FF4B00D9"/>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="Dark">
|
||||
<shvconv:UInt32ToGradientColorConverter
|
||||
x:Key="CountToGradientColorConverter"
|
||||
Maximum="#FFFF69BF"
|
||||
Minimum="#FF9F69FF"/>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
|
||||
<shvconv:PanelSelectorModeConverter
|
||||
x:Key="PanelSelectorModeConverter"
|
||||
GridValue="{x:Bind GridImageExportPanel}"
|
||||
ListValue="{x:Bind ListImageExportPanel}"/>
|
||||
<cwuconv:BoolToObjectConverter x:Key="BoolToOpacityConverter">
|
||||
<cwuconv:BoolToObjectConverter.TrueValue>
|
||||
<x:Double>1</x:Double>
|
||||
</cwuconv:BoolToObjectConverter.TrueValue>
|
||||
<cwuconv:BoolToObjectConverter.FalseValue>
|
||||
<x:Double>0.5</x:Double>
|
||||
</cwuconv:BoolToObjectConverter.FalseValue>
|
||||
</cwuconv:BoolToObjectConverter>
|
||||
|
||||
<shvconv:PanelSelectorModeConverter
|
||||
x:Key="PanelSelectorModeConverter"
|
||||
GridValue="{x:Bind GridImageExportPanel}"
|
||||
ListValue="{x:Bind ListImageExportPanel}"/>
|
||||
|
||||
|
||||
</ResourceDictionary>
|
||||
</Page.Resources>
|
||||
|
||||
<Grid>
|
||||
@@ -53,7 +72,7 @@
|
||||
|
||||
<CommandBar
|
||||
Grid.Row="0"
|
||||
Background="{StaticResource CardBackgroundFillColorDefaultBrush}"
|
||||
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
|
||||
DefaultLabelPosition="Right">
|
||||
<CommandBar.Content>
|
||||
<shcp:PanelSelector x:Name="ItemsPanelSelector" Margin="6,8,0,0"/>
|
||||
@@ -672,13 +691,17 @@
|
||||
TextTrimming="CharacterEllipsis"
|
||||
TextWrapping="NoWrap"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Value}"/>
|
||||
<Grid Grid.Column="2" Opacity="0.7">
|
||||
<Grid Grid.Column="2" Opacity="1">
|
||||
<Ellipse
|
||||
Width="16"
|
||||
Height="16"
|
||||
Margin="0,0,0,0"
|
||||
Stroke="{ThemeResource TextFillColorPrimaryBrush}"
|
||||
StrokeThickness="1"/>
|
||||
Opacity="0.8"
|
||||
StrokeThickness="1">
|
||||
<Ellipse.Stroke>
|
||||
<SolidColorBrush Color="{Binding EnhancedCount, Converter={ThemeResource CountToGradientColorConverter}}"/>
|
||||
</Ellipse.Stroke>
|
||||
</Ellipse>
|
||||
<TextBlock
|
||||
Grid.Column="2"
|
||||
Margin="0,0,0,1"
|
||||
@@ -686,7 +709,11 @@
|
||||
VerticalAlignment="Center"
|
||||
FontSize="{ThemeResource InfoBadgeValueFontSize}"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Text="{Binding EnhancedCount}"/>
|
||||
Text="{Binding EnhancedCount}">
|
||||
<TextBlock.Foreground>
|
||||
<SolidColorBrush Color="{Binding EnhancedCount, Converter={ThemeResource CountToGradientColorConverter}}"/>
|
||||
</TextBlock.Foreground>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
Reference in New Issue
Block a user