WIP memory iconstorage
This commit is contained in:
@@ -1,46 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using TheXamlGuy.TaskbarGroup.Core;
|
||||
using TheXamlGuy.TaskbarGroup.Flyout.Foundation;
|
||||
using Windows.ApplicationModel.DataTransfer;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.FileProperties;
|
||||
|
||||
namespace TheXamlGuy.TaskbarGroup.Flyout
|
||||
{
|
||||
public class TaskbarButtonGroupDropHandler : IDropHandler<TaskbarButtonGroupView>
|
||||
{
|
||||
public async Task Handle(Drop<TaskbarButtonGroupView> message, CancellationToken canellationToken = default)
|
||||
private readonly IMediator mediator;
|
||||
|
||||
public TaskbarButtonGroupDropHandler(IMediator mediator)
|
||||
{
|
||||
this.mediator = mediator;
|
||||
}
|
||||
|
||||
public async void Handle(Drop<TaskbarButtonGroupView> message)
|
||||
{
|
||||
if (message.DropEventArgs.DataView.Contains(StandardDataFormats.StorageItems))
|
||||
{
|
||||
var items = await message.DropEventArgs.DataView.GetStorageItemsAsync();
|
||||
foreach (var storageItem in items)
|
||||
foreach (IStorageItem storageItem in items)
|
||||
{
|
||||
if (storageItem is StorageFile storageFile)
|
||||
if ((await storageItem.RetrievePropertiesAsync("System.AppUserModel.ID"))
|
||||
.TryGetValue("System.AppUserModel.ID", out var appUserModelId)
|
||||
|| File.Exists(storageItem.Path))
|
||||
{
|
||||
if (storageFile.Path is { Length: > 0 })
|
||||
if (storageItem is IStorageItemProperties storageItemProperties)
|
||||
{
|
||||
|
||||
using var thumbnail = await storageItemProperties.GetThumbnailAsync(ThumbnailMode.SingleItem, 94);
|
||||
using var stream = thumbnail.AsStreamForWrite();
|
||||
mediator.Handle(new IconStorage(appUserModelId is not null ? $"{appUserModelId}" : storageItem.Path, stream));
|
||||
}
|
||||
else
|
||||
{
|
||||
var properties = await storageFile.Properties.RetrievePropertiesAsync(new List<string>
|
||||
{
|
||||
"System.AppUserModel.ID"
|
||||
});
|
||||
|
||||
var appUserModelId = properties["System.AppUserModel.ID"];
|
||||
if (appUserModelId is not null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (storageItem is StorageFolder storageFolder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user