Skip to content

Commit 1cfbc32

Browse files
committed
Resolved namespaces and improved feature .NET feature conditionals for AccentAnalyzer
1 parent 9639efd commit 1cfbc32

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

components/AccentAnalyzer/src/AccentAnalyzer.Clustering.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System.Numerics;
6-
using Windows.UI;
76

87
namespace CommunityToolkit.WinUI.Helpers;
98

@@ -22,9 +21,9 @@ private static Vector3[] KMeansCluster(Span<Vector3> points, int k, out int[] co
2221

2322
// Split the points into arbitrary clusters
2423
// NOTE: Can this be rearranged to converge faster?
25-
#if !WINDOWS_UWP
24+
#if NET6_0_OR_GREATER
2625
var offset = Random.Shared.Next(k); // Mathematically true random sampling
27-
#elif WINDOWS_UWP
26+
#else
2827
var rand = new Random();
2928
var offset = rand.Next(k);
3029
#endif

components/AccentAnalyzer/src/AccentAnalyzer.Properties.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System.Windows.Input;
6+
using Windows.UI;
7+
58
#if !WINDOWS_UWP
69
using Microsoft.UI;
710
using Microsoft.UI.Dispatching;
811
#elif WINDOWS_UWP
912
using Windows.System;
10-
using Windows.UI;
1113
#endif
1214

13-
using System.Windows.Input;
14-
1515

1616
namespace CommunityToolkit.WinUI.Helpers;
1717

components/AccentAnalyzer/src/AccentAnalyzer.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System.Numerics;
6+
using System.Windows.Input;
7+
using Windows.UI;
8+
59
#if !WINDOWS_UWP
6-
using Microsoft.UI;
7-
using Microsoft.UI.Dispatching;
810
using Microsoft.UI.Xaml.Media.Imaging;
911
#elif WINDOWS_UWP
10-
using Windows.UI;
1112
using Windows.UI.Xaml.Media.Imaging;
1213
#endif
1314

14-
using System.Numerics;
15-
using System.Windows.Input;
16-
using System.Linq;
1715

1816
namespace CommunityToolkit.WinUI.Helpers;
1917

@@ -75,10 +73,10 @@ private async Task UpdateAccentAsync()
7573
// Read the stream into a a color array
7674
int pos = 0;
7775
Span<Vector3> colors = new Vector3[(int)stream.Length / 4]; // This should be 4096 (64x64), but it's good to be safe.
78-
#if !WINDOWS_UWP
76+
#if NET7_0_OR_GREATER
7977
Span<byte> bytes = stackalloc byte[4];
8078
while (stream.Read(bytes) > 0)
81-
#elif WINDOWS_UWP
79+
#else
8280
byte[] bytes = new byte[4];
8381
while(stream.Read(bytes, 0, 4) > 0)
8482
#endif
@@ -121,11 +119,11 @@ private async Task UpdateAccentAsync()
121119
var baseColor = accentColors.Last();
122120

123121
// Get base color by prominence
124-
#if !WINDOWS_UWP
122+
#if NET6_0_OR_GREATER
125123
var dominant = clusters
126124
.Select((color, i) => (color, sizes[i]))
127125
.MaxBy(x => x.Item2).color * 255;
128-
#elif WINDOWS_UWP
126+
#else
129127
var dominant = clusters
130128
.Select((color, i) => (color, sizes[i]))
131129
.OrderByDescending((x) => x.Item2)

0 commit comments

Comments
 (0)