mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Profiles - Added module activation requirements
Editor - Refactored tools and selected keyframes management Timeline - Added keyframe duplicating, copying and pasting Windows UI - Added logging of fatal exceptions
This commit is contained in:
1 parent
d563d17270
commit
dd40bdd544
31 files changed
+719
-178
No files matched your search
@@ -0,0 +1,29 @@
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Avalonia.Input.Platform;
|
||||
|
||||
namespace Artemis.UI.Shared.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Provides extension methods for Avalonia's <see cref="IClipboard" /> type.
|
||||
/// </summary>
|
||||
public static class ClipboardExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves clipboard JSON data representing <typeparamref name="T" /> and deserializes it into an instance of
|
||||
/// <typeparamref name="T" />.
|
||||
/// </summary>
|
||||
/// <param name="clipboard">The clipboard to retrieve the data off.</param>
|
||||
/// <param name="format">The data format to retrieve data for.</param>
|
||||
/// <typeparam name="T">The type of data to retrieve</typeparam>
|
||||
/// <returns>
|
||||
/// The resulting value or if the clipboard did not contain data for the provided <paramref name="format" />;
|
||||
/// <see langword="null" />.
|
||||
/// </returns>
|
||||
public static async Task<T?> GetJsonAsync<T>(this IClipboard clipboard, string format)
|
||||
{
|
||||
byte[]? bytes = (byte[]?) await clipboard.GetDataAsync(format);
|
||||
return bytes == null ? default : CoreJson.DeserializeObject<T>(Encoding.Unicode.GetString(bytes), true);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user