WIP memory iconstorage

This commit is contained in:
dan_clark@outlook.com
2022-03-24 20:09:10 +00:00
parent 04df2d2ff6
commit 506161e4b9
14 changed files with 79 additions and 54 deletions
@@ -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)
{
}
}
}