Убраны синхронные методы
This commit is contained in:
72
Lattice.UI.DragDrop.WinUI/Services/WinUIDragDropHost.cs
Normal file
72
Lattice.UI.DragDrop.WinUI/Services/WinUIDragDropHost.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user