Added app configuration
This commit is contained in:
@@ -1,82 +0,0 @@
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Shell;
|
||||
using TheXamlGuy.TaskbarGroup.Core;
|
||||
using Microsoft.WindowsAPICodePack.Shell;
|
||||
|
||||
namespace TheXamlGuy.TaskbarGroup.Foundation
|
||||
{
|
||||
public class FileDropTarget : IDropTarget<UIElement>
|
||||
{
|
||||
private UIElement? target;
|
||||
private readonly IMessenger messenger;
|
||||
|
||||
public FileDropTarget(IMessenger messenger)
|
||||
{
|
||||
this.messenger = messenger;
|
||||
}
|
||||
|
||||
public void Register(UIElement target)
|
||||
{
|
||||
if (this.target is not null)
|
||||
{
|
||||
target.DragOver -= OnDragOver;
|
||||
target.DragEnter -= OnDragEnter;
|
||||
target.Drop -= OnDrop;
|
||||
}
|
||||
|
||||
this.target = target;
|
||||
|
||||
target.DragOver += OnDragOver;
|
||||
target.DragEnter += OnDragEnter;
|
||||
target.Drop += OnDrop;
|
||||
}
|
||||
|
||||
private void OnDrop(object sender, DragEventArgs args)
|
||||
{
|
||||
String[] fileName = (String[])args.Data.GetFormats();
|
||||
|
||||
var ddd = ShellObjectCollection.FromDataObject((System.Runtime.InteropServices.ComTypes.IDataObject)args.Data);
|
||||
|
||||
//args.Handled = true;
|
||||
//var fileName = GetFileName(args.Data);
|
||||
//messenger.Publish<FileDropped>();
|
||||
|
||||
}
|
||||
|
||||
private string GetFileName(IDataObject data)
|
||||
{
|
||||
var filenames = (string[])data.GetData(DataFormats.FileDrop);
|
||||
return filenames[0];
|
||||
}
|
||||
|
||||
private bool IsFileDrop(IDataObject data)
|
||||
{
|
||||
return data.GetDataPresent(DataFormats.FileDrop);
|
||||
}
|
||||
|
||||
private void OnDragEnter(object sender, DragEventArgs args)
|
||||
{
|
||||
if (IsFileDrop(args.Data))
|
||||
{
|
||||
args.Effects = DragDropEffects.Link;
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Effects = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDragOver(object sender, DragEventArgs args)
|
||||
{
|
||||
if (IsFileDrop(args.Data))
|
||||
{
|
||||
args.Effects = DragDropEffects.Link;
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Effects = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,7 @@ namespace TheXamlGuy.TaskbarGroup.Foundation
|
||||
.AddSingleton<TemplateSelector>()
|
||||
.AddSingleton<IDataTemplateCollection>(new DataTemplateCollection(new Dictionary<Type, Type>()))
|
||||
.AddSingleton<DataTemplateFactory>()
|
||||
.AddSingleton<IDispatcherTimerFactory, DispatcherTimerFactory>()
|
||||
.AddTransient<FileDropTarget>();
|
||||
.AddSingleton<IDispatcherTimerFactory, DispatcherTimerFactory>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
<Platforms>x64;x86</Platforms>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft-WindowsAPICodePack-Core" Version="1.1.4" />
|
||||
<PackageReference Include="Microsoft-WindowsAPICodePack-Shell" Version="1.1.4" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user