mirror of
https://github.com/Maassoft/ColorControl.git
synced 2026-10-22 08:32:18 -05:00
fix issues with new UI, add color profiles, add sdr brightness for AMD
This commit is contained in:
1 parent
4d2ca8a552
commit
f42a46e53f
95 files changed
+12129
-10005
No files matched your search
@@ -0,0 +1,23 @@
|
||||
using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace ColorControl.UI.Generics;
|
||||
|
||||
public static class GeneralExtensions
|
||||
{
|
||||
public static async ValueTask<TValue?> TryGet<TValue>(this ProtectedBrowserStorage storage, string key, TValue? def = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await storage.GetAsync<TValue>(key);
|
||||
var value = result.Success ? result.Value : def;
|
||||
|
||||
return value;
|
||||
}
|
||||
catch (CryptographicException)
|
||||
{
|
||||
await storage.DeleteAsync(key);
|
||||
return def;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +1,25 @@
|
||||
using ColorControl.Shared.Contracts;
|
||||
using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace ColorControl.UI.Generics;
|
||||
|
||||
public static class PresetExtensions
|
||||
{
|
||||
public static List<T>? OrderPresetsBy<T>(this List<T> presets, PresetOrder order) where T : PresetBase
|
||||
{
|
||||
if (presets == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public static List<T>? OrderPresetsBy<T>(this List<T> presets, PresetOrder order) where T : PresetBase
|
||||
{
|
||||
if (presets == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (order == PresetOrder.ByName)
|
||||
{
|
||||
presets = presets.OrderBy(p => p.name).ToList();
|
||||
}
|
||||
else if (order == PresetOrder.ByLastUsed)
|
||||
{
|
||||
presets = presets.OrderByDescending(p => p.LastUsed).ToList();
|
||||
}
|
||||
if (order == PresetOrder.ByName)
|
||||
{
|
||||
presets = presets.OrderBy(p => p.name).ToList();
|
||||
}
|
||||
else if (order == PresetOrder.ByLastUsed)
|
||||
{
|
||||
presets = presets.OrderByDescending(p => p.LastUsed).ToList();
|
||||
}
|
||||
|
||||
return presets;
|
||||
}
|
||||
|
||||
public static async ValueTask<TValue?> TryGet<TValue>(this ProtectedBrowserStorage storage, string key, TValue? def = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await storage.GetAsync<TValue>(key);
|
||||
var value = result.Success ? result.Value : def;
|
||||
|
||||
return value;
|
||||
}
|
||||
catch (CryptographicException)
|
||||
{
|
||||
await storage.DeleteAsync(key);
|
||||
return def;
|
||||
}
|
||||
}
|
||||
return presets;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user