From 977e749939eef926dc2dd80eaf2eceaac88afb91 Mon Sep 17 00:00:00 2001
From: Lightczx <1686188646@qq.com>
Date: Mon, 5 Feb 2024 15:35:02 +0800
Subject: [PATCH] rename style
---
.../Control/Media/{Hsl32.cs => Hsla32.cs} | 2 +-
.../Snap.Hutao/Control/Media/Rgba32.cs | 26 +-
.../Control/Media/SoftwareBitmapExtension.cs | 4 +-
.../Control/Text/DescriptionTextBlock.cs | 2 +-
.../Control/Text/HtmlDescriptionTextBlock.cs | 2 +-
.../Snap.Hutao/Control/Theme/Card.xaml | 15 +-
.../Control/Theme/PivotOverride.xaml | 375 +++++++++++++++++-
.../Snap.Hutao/View/Page/AchievementPage.xaml | 2 +-
.../View/Page/AvatarPropertyPage.xaml | 2 +-
.../Snap.Hutao/View/Page/DailyNotePage.xaml | 2 +-
.../Snap.Hutao/View/Page/WikiMonsterPage.xaml | 2 +-
.../Snap.Hutao/View/Page/WikiWeaponPage.xaml | 2 +-
.../WinRT/IMemoryBufferByteAccessExtension.cs | 8 +
13 files changed, 413 insertions(+), 31 deletions(-)
rename src/Snap.Hutao/Snap.Hutao/Control/Media/{Hsl32.cs => Hsla32.cs} (96%)
diff --git a/src/Snap.Hutao/Snap.Hutao/Control/Media/Hsl32.cs b/src/Snap.Hutao/Snap.Hutao/Control/Media/Hsla32.cs
similarity index 96%
rename from src/Snap.Hutao/Snap.Hutao/Control/Media/Hsl32.cs
rename to src/Snap.Hutao/Snap.Hutao/Control/Media/Hsla32.cs
index 2cb67cfd..76743b55 100644
--- a/src/Snap.Hutao/Snap.Hutao/Control/Media/Hsl32.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Control/Media/Hsla32.cs
@@ -8,7 +8,7 @@ namespace Snap.Hutao.Control.Media;
///
/// Defines a color in Hue/Saturation/Lightness (HSL) space.
///
-internal struct Hsl32
+internal struct Hsla32
{
///
/// The Hue in 0..360 range.
diff --git a/src/Snap.Hutao/Snap.Hutao/Control/Media/Rgba32.cs b/src/Snap.Hutao/Snap.Hutao/Control/Media/Rgba32.cs
index a0726a13..a8c70b55 100644
--- a/src/Snap.Hutao/Snap.Hutao/Control/Media/Rgba32.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Control/Media/Rgba32.cs
@@ -46,14 +46,14 @@ internal struct Rgba32
///
/// 使用 RGBA 代码初始化新的结构
///
- /// RGBA 代码
- public unsafe Rgba32(uint code)
+ /// RGBA 代码
+ public unsafe Rgba32(uint xrgbaCode)
{
- // uint layout: 0xRRGGBBAA -> AABBGGRR
+ // uint layout: 0xRRGGBBAA is AABBGGRR
// AABBGGRR -> RRGGBBAA
fixed (Rgba32* pSelf = &this)
{
- *(uint*)pSelf = BinaryPrimitives.ReverseEndianness(code);
+ *(uint*)pSelf = BinaryPrimitives.ReverseEndianness(xrgbaCode);
}
}
@@ -67,14 +67,14 @@ internal struct Rgba32
public static unsafe implicit operator Color(Rgba32 hexColor)
{
- // AABBGGRR -> BBGGRRAA
- // AABBGGRR -> 000000AA
- uint a = (*(uint*)&hexColor) >> 24;
+ // Goal : Rgba32:RRGGBBAA(0xAABBGGRR) -> Color: AARRGGBB(0xBBGGRRAA)
+ // Step1: Rgba32:RRGGBBAA(0xAABBGGRR) -> UInt32:AA000000(0x000000AA)
+ uint a = ((*(uint*)&hexColor) >> 24) & 0x000000FF;
- // AABBGGRR -> BBGGRR00
- uint rgb = (*(uint*)&hexColor) << 8;
+ // Step2: Rgba32:RRGGBBAA(0xAABBGGRR) -> UInt32:00RRGGBB(0xRRGGBB00)
+ uint rgb = ((*(uint*)&hexColor) << 8) & 0xFFFFFF00;
- // BBGGRR00 + 000000AA
+ // Step2: UInt32:00RRGGBB(0xRRGGBB00) + UInt32:AA000000(0x000000AA) -> UInt32:AARRGGBB(0xRRGGBBAA)
uint rgba = rgb + a;
return *(Color*)&rgba;
@@ -85,7 +85,7 @@ internal struct Rgba32
///
/// HSL 颜色
/// RGBA8颜色
- public static Rgba32 FromHsl(Hsl32 hsl)
+ public static Rgba32 FromHsl(Hsla32 hsl)
{
double chroma = (1 - Math.Abs((2 * hsl.L) - 1)) * hsl.S;
double h1 = hsl.H / 60;
@@ -142,7 +142,7 @@ internal struct Rgba32
/// 转换到 HSL 颜色
///
/// HSL 颜色
- public readonly Hsl32 ToHsl()
+ public readonly Hsla32 ToHsl()
{
const double toDouble = 1.0 / 255;
double r = toDouble * R;
@@ -175,7 +175,7 @@ internal struct Rgba32
double lightness = 0.5 * (max + min);
double saturation = chroma == 0 ? 0 : chroma / (1 - Math.Abs((2 * lightness) - 1));
- Hsl32 ret;
+ Hsla32 ret;
ret.H = 60 * h1;
ret.S = saturation;
ret.L = lightness;
diff --git a/src/Snap.Hutao/Snap.Hutao/Control/Media/SoftwareBitmapExtension.cs b/src/Snap.Hutao/Snap.Hutao/Control/Media/SoftwareBitmapExtension.cs
index 190fcd6f..b3b03618 100644
--- a/src/Snap.Hutao/Snap.Hutao/Control/Media/SoftwareBitmapExtension.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Control/Media/SoftwareBitmapExtension.cs
@@ -2,6 +2,7 @@
// Licensed under the MIT license.
using Snap.Hutao.Win32.System.WinRT;
+using System.Runtime.CompilerServices;
using Windows.Foundation;
using Windows.Graphics.Imaging;
using WinRT;
@@ -25,8 +26,7 @@ internal static class SoftwareBitmapExtension
{
using (IMemoryBufferReference reference = buffer.CreateReference())
{
- reference.As().GetBuffer(out byte* data, out uint length);
- Span bytes = new(data, unchecked((int)length / sizeof(Bgra32)));
+ reference.As().GetBuffer(out Span bytes);
foreach (ref Bgra32 pixel in bytes)
{
byte baseAlpha = pixel.A;
diff --git a/src/Snap.Hutao/Snap.Hutao/Control/Text/DescriptionTextBlock.cs b/src/Snap.Hutao/Snap.Hutao/Control/Text/DescriptionTextBlock.cs
index 3ef1ab02..a24d1516 100644
--- a/src/Snap.Hutao/Snap.Hutao/Control/Text/DescriptionTextBlock.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Control/Text/DescriptionTextBlock.cs
@@ -109,7 +109,7 @@ internal sealed partial class DescriptionTextBlock : ContentControl
else
{
// Make lighter in light mode
- Hsl32 hsl = color.ToHsl();
+ Hsla32 hsl = color.ToHsl();
hsl.L *= 0.3;
targetColor = Rgba32.FromHsl(hsl);
}
diff --git a/src/Snap.Hutao/Snap.Hutao/Control/Text/HtmlDescriptionTextBlock.cs b/src/Snap.Hutao/Snap.Hutao/Control/Text/HtmlDescriptionTextBlock.cs
index 5d96e075..b4d680fc 100644
--- a/src/Snap.Hutao/Snap.Hutao/Control/Text/HtmlDescriptionTextBlock.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Control/Text/HtmlDescriptionTextBlock.cs
@@ -139,7 +139,7 @@ internal sealed partial class HtmlDescriptionTextBlock : ContentControl
else
{
// Make lighter in light mode
- Hsl32 hsl = color.ToHsl();
+ Hsla32 hsl = color.ToHsl();
hsl.L *= 0.3;
targetColor = Rgba32.FromHsl(hsl);
}
diff --git a/src/Snap.Hutao/Snap.Hutao/Control/Theme/Card.xaml b/src/Snap.Hutao/Snap.Hutao/Control/Theme/Card.xaml
index 2a460891..e60eabd5 100644
--- a/src/Snap.Hutao/Snap.Hutao/Control/Theme/Card.xaml
+++ b/src/Snap.Hutao/Snap.Hutao/Control/Theme/Card.xaml
@@ -18,6 +18,7 @@
Offset="0,4,0"/>
+
-
+
\ No newline at end of file
diff --git a/src/Snap.Hutao/Snap.Hutao/Control/Theme/PivotOverride.xaml b/src/Snap.Hutao/Snap.Hutao/Control/Theme/PivotOverride.xaml
index 68e1548c..1d1d5270 100644
--- a/src/Snap.Hutao/Snap.Hutao/Control/Theme/PivotOverride.xaml
+++ b/src/Snap.Hutao/Snap.Hutao/Control/Theme/PivotOverride.xaml
@@ -193,6 +193,379 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -208,7 +581,7 @@
Grid.Row="0"
Margin="16,16,16,0"
cw:Effects.Shadow="{ThemeResource CompatCardShadow}">
-
+
diff --git a/src/Snap.Hutao/Snap.Hutao/View/Page/AchievementPage.xaml b/src/Snap.Hutao/Snap.Hutao/View/Page/AchievementPage.xaml
index c64b6387..8d7a93e5 100644
--- a/src/Snap.Hutao/Snap.Hutao/View/Page/AchievementPage.xaml
+++ b/src/Snap.Hutao/Snap.Hutao/View/Page/AchievementPage.xaml
@@ -199,7 +199,7 @@
-
+
diff --git a/src/Snap.Hutao/Snap.Hutao/View/Page/AvatarPropertyPage.xaml b/src/Snap.Hutao/Snap.Hutao/View/Page/AvatarPropertyPage.xaml
index 42fae4ba..7805d551 100644
--- a/src/Snap.Hutao/Snap.Hutao/View/Page/AvatarPropertyPage.xaml
+++ b/src/Snap.Hutao/Snap.Hutao/View/Page/AvatarPropertyPage.xaml
@@ -507,7 +507,7 @@
-
+
diff --git a/src/Snap.Hutao/Snap.Hutao/View/Page/DailyNotePage.xaml b/src/Snap.Hutao/Snap.Hutao/View/Page/DailyNotePage.xaml
index 61b236df..e04510fe 100644
--- a/src/Snap.Hutao/Snap.Hutao/View/Page/DailyNotePage.xaml
+++ b/src/Snap.Hutao/Snap.Hutao/View/Page/DailyNotePage.xaml
@@ -391,7 +391,7 @@
-
+
-
+
-
+
(this IMemoryBufferByteAccess memoryBufferByteAccess, out Span value)
+ where T : unmanaged
+ {
+ HRESULT retVal = memoryBufferByteAccess.GetBuffer(out byte* data, out uint capacity);
+ value = new Span(data, unchecked((int)capacity / sizeof(T)));
+ return retVal;
+ }
}
\ No newline at end of file