mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Profiles - Reworked profile system
Sidebar - Redesigned sidebar with customizable categories Profiles - Added the ability to configure custom profile icons Profiles - Added the ability to activate multiple profiles for modules at once Profiles - Added the ability to create profiles for no modules Profiles - Added the ability to suspend a profile or an entire category Profiles - Added profile activation conditions Profiles - Added file-based importing/exporting Profile editor - Condensed UI, removed tabs Profile editor - Disable condition operators until a left-side is picked
This commit is contained in:
1 parent
4152c290d2
commit
ceeaa4bf6d
164 files changed
+5019
-4220
No files matched your search
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Artemis.Core.JsonConverters
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public class StreamConverter : JsonConverter<Stream>
|
||||
{
|
||||
#region Overrides of JsonConverter<Stream>
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteJson(JsonWriter writer, Stream? value, JsonSerializer serializer)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
writer.WriteNull();
|
||||
return;
|
||||
}
|
||||
|
||||
using MemoryStream memoryStream = new();
|
||||
value.Position = 0;
|
||||
value.CopyTo(memoryStream);
|
||||
writer.WriteValue(memoryStream.ToArray());
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Stream? ReadJson(JsonReader reader, Type objectType, Stream? existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
{
|
||||
if (reader.Value is not string base64)
|
||||
return null;
|
||||
|
||||
if (existingValue == null || !hasExistingValue || !existingValue.CanRead)
|
||||
return new MemoryStream(Convert.FromBase64String(base64));
|
||||
|
||||
using MemoryStream memoryStream = new(Convert.FromBase64String(base64));
|
||||
existingValue.Position = 0;
|
||||
memoryStream.CopyTo(existingValue);
|
||||
existingValue.Position = 0;
|
||||
return existingValue;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user