mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
code style
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using Snap.Hutao.Web.Request.Builder;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using Snap.Hutao.Web.Request.Builder;
|
||||
|
||||
namespace Snap.Hutao.Core.IO.Http.Sharding;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ internal static class WinRTExtension
|
||||
}
|
||||
|
||||
// protected bool disposed;
|
||||
[UnsafeAccessor(UnsafeAccessorKind.Field, Name ="disposed")]
|
||||
[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "disposed")]
|
||||
private static extern ref bool GetProtectedDisposed(IObjectReference objRef);
|
||||
|
||||
// private object _disposedLock
|
||||
|
||||
@@ -116,7 +116,7 @@ internal abstract partial class DbStoreOptions : ObservableObject, IOptions<DbSt
|
||||
/// <param name="deserializer">反序列化器</param>
|
||||
/// <param name="defaultValue">默认值</param>
|
||||
/// <returns>值</returns>
|
||||
[return:NotNull]
|
||||
[return: NotNull]
|
||||
protected T GetOption<T>(ref T? storage, string key, Func<string, T> deserializer, [DisallowNull] T defaultValue)
|
||||
{
|
||||
if (storage is not null)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Internal;
|
||||
using Snap.Hutao.Core.Database;
|
||||
using Snap.Hutao.Model.Entity;
|
||||
using Snap.Hutao.Model.Entity.Database;
|
||||
|
||||
@@ -287,7 +287,7 @@ internal sealed partial class GachaLogDbService : IGachaLogDbService
|
||||
Time = i.Time,
|
||||
Id = i.Id,
|
||||
});
|
||||
return [..result];
|
||||
return [.. result];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -279,41 +279,6 @@ internal sealed partial class AvatarPropertyViewModel : Abstraction.ViewModel, I
|
||||
}
|
||||
}
|
||||
|
||||
[Command("ExportAsImageCommand")]
|
||||
private async Task ExportAsImageAsync(FrameworkElement? element)
|
||||
{
|
||||
if (element is { IsLoaded: true })
|
||||
{
|
||||
RenderTargetBitmap bitmap = new();
|
||||
await bitmap.RenderAsync(element);
|
||||
|
||||
IBuffer buffer = await bitmap.GetPixelsAsync();
|
||||
bool clipboardOpened = false;
|
||||
using (SoftwareBitmap softwareBitmap = SoftwareBitmap.CreateCopyFromBuffer(buffer, BitmapPixelFormat.Bgra8, bitmap.PixelWidth, bitmap.PixelHeight))
|
||||
{
|
||||
Bgra32 tint = appResourceProvider.GetResource<Color>("CompatBackgroundColor");
|
||||
softwareBitmap.NormalBlend(tint);
|
||||
using (InMemoryRandomAccessStream memory = new())
|
||||
{
|
||||
BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, memory);
|
||||
encoder.SetSoftwareBitmap(softwareBitmap);
|
||||
await encoder.FlushAsync();
|
||||
|
||||
clipboardOpened = clipboardInterop.SetBitmap(memory);
|
||||
}
|
||||
}
|
||||
|
||||
if (clipboardOpened)
|
||||
{
|
||||
infoBarService.Success(SH.ViewModelAvatarPropertyExportImageSuccess);
|
||||
}
|
||||
else
|
||||
{
|
||||
infoBarService.Warning(SH.ViewModelAvatarPropertyOpenClipboardFail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async ValueTask<CultivateCoreResult> CultivateCoreAsync(Model.Entity.User user, CalculatorAvatarPromotionDelta delta, AvatarView avatar)
|
||||
{
|
||||
Response<CalculatorConsumption> consumptionResponse = await calculatorClient.ComputeAsync(user, delta).ConfigureAwait(false);
|
||||
@@ -352,4 +317,39 @@ internal sealed partial class AvatarPropertyViewModel : Abstraction.ViewModel, I
|
||||
|
||||
return CultivateCoreResult.Ok;
|
||||
}
|
||||
|
||||
[Command("ExportAsImageCommand")]
|
||||
private async Task ExportAsImageAsync(FrameworkElement? element)
|
||||
{
|
||||
if (element is { IsLoaded: true })
|
||||
{
|
||||
RenderTargetBitmap bitmap = new();
|
||||
await bitmap.RenderAsync(element);
|
||||
|
||||
IBuffer buffer = await bitmap.GetPixelsAsync();
|
||||
bool clipboardOpened = false;
|
||||
using (SoftwareBitmap softwareBitmap = SoftwareBitmap.CreateCopyFromBuffer(buffer, BitmapPixelFormat.Bgra8, bitmap.PixelWidth, bitmap.PixelHeight))
|
||||
{
|
||||
Bgra32 tint = appResourceProvider.GetResource<Color>("CompatBackgroundColor");
|
||||
softwareBitmap.NormalBlend(tint);
|
||||
using (InMemoryRandomAccessStream memory = new())
|
||||
{
|
||||
BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, memory);
|
||||
encoder.SetSoftwareBitmap(softwareBitmap);
|
||||
await encoder.FlushAsync();
|
||||
|
||||
clipboardOpened = clipboardInterop.SetBitmap(memory);
|
||||
}
|
||||
}
|
||||
|
||||
if (clipboardOpened)
|
||||
{
|
||||
infoBarService.Success(SH.ViewModelAvatarPropertyExportImageSuccess);
|
||||
}
|
||||
else
|
||||
{
|
||||
infoBarService.Warning(SH.ViewModelAvatarPropertyOpenClipboardFail);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,21 +18,21 @@ internal static class NameValueCollectionExtension
|
||||
}
|
||||
|
||||
StringBuilder sb = new();
|
||||
string?[] keys = collection.AllKeys;
|
||||
for (int i = 0; i < count; i++)
|
||||
foreach (string? key in collection.AllKeys)
|
||||
{
|
||||
string? key = keys[i];
|
||||
if (collection.GetValues(key) is { } values)
|
||||
if (collection.GetValues(key) is not { } values)
|
||||
{
|
||||
foreach (ref readonly string value in values.AsSpan())
|
||||
{
|
||||
if (!string.IsNullOrEmpty(key))
|
||||
{
|
||||
sb.Append(key).Append('=');
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
sb.Append(HttpUtility.UrlEncode(value)).Append('&');
|
||||
foreach (ref readonly string value in values.AsSpan())
|
||||
{
|
||||
if (!string.IsNullOrEmpty(key))
|
||||
{
|
||||
sb.Append(key).Append('=');
|
||||
}
|
||||
|
||||
sb.Append(HttpUtility.UrlEncode(value)).Append('&');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user