Reorg window handling and add drag handler
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
namespace TheXamlGuy.TaskbarGroup.Flyout.Foundation
|
||||
{
|
||||
public record class Drag<TTarget>(DragEventArgs DragEventArgs) where TTarget : UIElement
|
||||
{
|
||||
public TTarget Target { get; }
|
||||
}
|
||||
}
|
||||
@@ -30,20 +30,34 @@ namespace TheXamlGuy.TaskbarGroup.Flyout.Foundation
|
||||
base.OnAttached();
|
||||
}
|
||||
|
||||
private void OnDrop(object sender, DragEventArgs args)
|
||||
private object CreateDragMessage(object sender, DragEventArgs args)
|
||||
{
|
||||
if (Mediator is not null)
|
||||
{
|
||||
var dropMessageType = typeof(Drop<>).MakeGenericType(sender.GetType());
|
||||
var dropMessage = Activator.CreateInstance(dropMessageType, args);
|
||||
var dropMessageType = typeof(Drag<>).MakeGenericType(sender.GetType());
|
||||
return Activator.CreateInstance(dropMessageType, args);
|
||||
}
|
||||
|
||||
Mediator.HandleAsync(dropMessage);
|
||||
}
|
||||
private object CreateDropMessage(object sender, DragEventArgs args)
|
||||
{
|
||||
var dropMessageType = typeof(Drop<>).MakeGenericType(sender.GetType());
|
||||
return Activator.CreateInstance(dropMessageType, args);
|
||||
}
|
||||
|
||||
private void OnDragOver(object sender, DragEventArgs args)
|
||||
{
|
||||
args.AcceptedOperation = DataPackageOperation.Link;
|
||||
if (Mediator is not null)
|
||||
{
|
||||
var message = CreateDragMessage(sender, args);
|
||||
Mediator.HandleAsync(message);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDrop(object sender, DragEventArgs args)
|
||||
{
|
||||
if (Mediator is not null)
|
||||
{
|
||||
var message = CreateDropMessage(sender, args);
|
||||
Mediator.HandleAsync(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
using TheXamlGuy.TaskbarGroup.Core;
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
namespace TheXamlGuy.TaskbarGroup.Flyout.Foundation
|
||||
{
|
||||
public interface IDragHandler<TTarget> : IAsyncMessageHandler<Drag<TTarget>> where TTarget : UIElement
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
+2
@@ -122,10 +122,12 @@
|
||||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Drag.cs" />
|
||||
<Compile Include="DropTarget.cs" />
|
||||
<Compile Include="DataTemplateFactory.cs" />
|
||||
<Compile Include="Drop.cs" />
|
||||
<Compile Include="IDataTemplateFactory.cs" />
|
||||
<Compile Include="IDragHandler.cs" />
|
||||
<Compile Include="IDropHandler.cs" />
|
||||
<Compile Include="IServiceCollectionExtensions.cs" />
|
||||
<Compile Include="IWindowPrivate.cs" />
|
||||
|
||||
Reference in New Issue
Block a user