Files
Lattice/Lattice.UI.DragDrop.WinUI/Services/WinUIDragDropHost.cs

72 lines
1.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Lattice.Core.Geometry;
using Lattice.UI.DragDrop.Abstractions;
using Lattice.UI.DragDrop.WinUI.Controls;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System;
namespace Lattice.UI.DragDrop.WinUI.Services;
public class WinUIDragDropHost : IDragDropHost
{
private readonly DragDropOverlay _overlay;
private readonly Window _window;
public WinUIDragDropHost(Window window)
{
_window = window ?? throw new ArgumentNullException(nameof(window));
_overlay = new DragDropOverlay();
// Добавляем оверлей в окно
if (_window.Content is Panel panel)
{
panel.Children.Add(_overlay);
}
}
public void ShowDragVisual(object dragVisual, Point position)
{
if (dragVisual is UIElement element)
{
_overlay.ShowDragVisual(element, position.X, position.Y);
}
}
public void UpdateDragVisualPosition(object dragVisual, Point position)
{
if (dragVisual is UIElement element)
{
_overlay.UpdateDragVisualPosition(element, position.X, position.Y);
}
}
public void HideDragVisual(object dragVisual)
{
if (dragVisual is UIElement element)
{
_overlay.HideDragVisual(element);
}
else
{
// Скрываем все, если передан null
var current = _overlay.GetCurrentDragVisual();
if (current != null)
{
_overlay.HideDragVisual(current);
}
}
}
public void ShowDropAdorner(IDropVisualAdorner adorner)
{
if (adorner is DropPreviewAdorner dropAdorner)
{
// TODO: Показываем превью сброса
}
}
public void HideDropAdorner(IDropVisualAdorner adorner)
{
_overlay.HideAllDropPreviews();
}
}