Убраны синхронные методы
This commit is contained in:
@@ -3,6 +3,7 @@ using Lattice.Core.DragDrop.Models;
|
||||
using Lattice.Core.DragDrop.Services;
|
||||
using Lattice.Core.Geometry;
|
||||
using Lattice.UI.DragDrop.Abstractions;
|
||||
using Lattice.UI.DragDrop.WinUI.Behaviors;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using System;
|
||||
@@ -14,25 +15,23 @@ namespace Lattice.UI.DragDrop.WinUI.Integration;
|
||||
|
||||
/// <summary>
|
||||
/// Сервис интеграции Drag & Drop с WinUI приложением.
|
||||
/// Исправленная версия с правильной обработкой событий и очисткой ресурсов.
|
||||
/// </summary>
|
||||
public sealed class WinUIDragDropIntegrationService : IDisposable
|
||||
{
|
||||
#region Вложенные типы
|
||||
|
||||
private sealed class DragSourceAdapter : IDisposable
|
||||
private sealed class DragSourceAdapter : IDragSource
|
||||
{
|
||||
private readonly UIElement _element;
|
||||
private readonly Func<Task<DragInfo>> _dragInfoFactory;
|
||||
private readonly FrameworkElement _element;
|
||||
private readonly Func<DragInfo> _dragInfoFactory;
|
||||
private readonly IDragDropService _dragDropService;
|
||||
private Point _dragStartPosition;
|
||||
private bool _isDragging;
|
||||
private bool _disposed;
|
||||
private object? _dragData;
|
||||
|
||||
public DragSourceAdapter(
|
||||
UIElement element,
|
||||
Func<Task<DragInfo>> dragInfoFactory,
|
||||
FrameworkElement element,
|
||||
Func<DragInfo> dragInfoFactory,
|
||||
IDragDropService dragDropService)
|
||||
{
|
||||
_element = element ?? throw new ArgumentNullException(nameof(element));
|
||||
@@ -42,24 +41,6 @@ public sealed class WinUIDragDropIntegrationService : IDisposable
|
||||
SubscribeToEvents();
|
||||
}
|
||||
|
||||
public DragSourceAdapter(
|
||||
UIElement element,
|
||||
object dragData,
|
||||
IDragDropService dragDropService)
|
||||
{
|
||||
_element = element ?? throw new ArgumentNullException(nameof(element));
|
||||
_dragData = dragData ?? throw new ArgumentNullException(nameof(dragData));
|
||||
_dragDropService = dragDropService ?? throw new ArgumentNullException(nameof(dragDropService));
|
||||
|
||||
_dragInfoFactory = async () => new DragInfo(
|
||||
_dragData,
|
||||
Core.DragDrop.Enums.DragDropEffects.Copy | Core.DragDrop.Enums.DragDropEffects.Move,
|
||||
Point.Zero,
|
||||
_element);
|
||||
|
||||
SubscribeToEvents();
|
||||
}
|
||||
|
||||
private void SubscribeToEvents()
|
||||
{
|
||||
_element.PointerPressed += OnPointerPressed;
|
||||
@@ -86,7 +67,7 @@ public sealed class WinUIDragDropIntegrationService : IDisposable
|
||||
_dragStartPosition = new Point(point.Position.X, point.Position.Y);
|
||||
}
|
||||
|
||||
private async void OnPointerMoved(object sender, PointerRoutedEventArgs e)
|
||||
private void OnPointerMoved(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
if (_isDragging || _disposed) return;
|
||||
|
||||
@@ -96,16 +77,24 @@ public sealed class WinUIDragDropIntegrationService : IDisposable
|
||||
var distance = CalculateDistance(_dragStartPosition, currentPosition);
|
||||
if (distance > _dragDropService.DragStartThreshold)
|
||||
{
|
||||
await StartDragAsync(currentPosition);
|
||||
StartDragOperation(currentPosition);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task StartDragAsync(Point position)
|
||||
private async Task StartDragOperation(Point position)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dragInfo = await _dragInfoFactory();
|
||||
var dragInfo = _dragInfoFactory();
|
||||
|
||||
// Обновляем позицию в dragInfo
|
||||
var screenPosition = GetScreenPosition(position);
|
||||
dragInfo = new DragInfo(
|
||||
dragInfo.Data,
|
||||
dragInfo.AllowedEffects,
|
||||
screenPosition,
|
||||
dragInfo.Source
|
||||
);
|
||||
|
||||
_isDragging = await _dragDropService.StartDragAsync(this, screenPosition);
|
||||
}
|
||||
@@ -134,131 +123,71 @@ public sealed class WinUIDragDropIntegrationService : IDisposable
|
||||
{
|
||||
if (!_isDragging || _disposed) return;
|
||||
|
||||
var point = e.GetCurrentPoint(_element);
|
||||
var position = GetScreenPosition(new Point(point.Position.X, point.Position.Y));
|
||||
await _dragDropService.EndDragAsync(position);
|
||||
await _dragDropService.EndDragAsync();
|
||||
_isDragging = false;
|
||||
}
|
||||
|
||||
private async void OnPointerCanceled(object sender, PointerRoutedEventArgs e)
|
||||
private void OnPointerCanceled(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
if (!_isDragging || _disposed) return;
|
||||
|
||||
await _dragDropService.CancelDragAsync();
|
||||
_dragDropService.CancelDragAsync();
|
||||
_isDragging = false;
|
||||
}
|
||||
|
||||
private async void OnPointerCaptureLost(object sender, PointerRoutedEventArgs e)
|
||||
private void OnPointerCaptureLost(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
if (!_isDragging || _disposed) return;
|
||||
|
||||
await _dragDropService.CancelDragAsync();
|
||||
_dragDropService.CancelDragAsync();
|
||||
_isDragging = false;
|
||||
}
|
||||
|
||||
#region IDragSource Implementation
|
||||
|
||||
public async Task<(bool, DragInfo? dragInfo)> CancelDragAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
dragInfo = _dragInfoFactory();
|
||||
return dragInfo != null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
dragInfo = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> StartDragAsync(DragInfo dragInfo)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task DragCompletedAsync(DragInfo dragInfo, Core.DragDrop.Enums.DragDropEffects effects)
|
||||
{
|
||||
_isDragging = false;
|
||||
}
|
||||
|
||||
public async Task DragCancelledAsync(DragInfo dragInfo)
|
||||
{
|
||||
_isDragging = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_disposed) return;
|
||||
|
||||
UnsubscribeFromEvents();
|
||||
|
||||
if (_isDragging)
|
||||
{
|
||||
Task.Run(async () => await _dragDropService.CancelDragAsync()).Wait(1000);
|
||||
}
|
||||
|
||||
_disposed = true;
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class DropTargetAdapter : IDisposable
|
||||
{
|
||||
private readonly UIElement _element;
|
||||
private readonly IDropTarget _dropTarget;
|
||||
private readonly IDragDropService _dragDropService;
|
||||
private string? _registrationId;
|
||||
private bool _disposed;
|
||||
|
||||
public DropTargetAdapter(
|
||||
UIElement element,
|
||||
IDropTarget dropTarget,
|
||||
IDragDropService dragDropService)
|
||||
public Task<(bool CanStart, DragInfo? DragInfo)> CanStartDragAsync()
|
||||
{
|
||||
_element = element ?? throw new ArgumentNullException(nameof(element));
|
||||
_dropTarget = dropTarget ?? throw new ArgumentNullException(nameof(dropTarget));
|
||||
_dragDropService = dragDropService ?? throw new ArgumentNullException(nameof(dragDropService));
|
||||
|
||||
SubscribeToEvents();
|
||||
UpdateRegistration();
|
||||
}
|
||||
|
||||
private void SubscribeToEvents()
|
||||
{
|
||||
_element.LayoutUpdated += OnLayoutUpdated;
|
||||
_element.Unloaded += OnElementUnloaded;
|
||||
}
|
||||
|
||||
private void UnsubscribeFromEvents()
|
||||
{
|
||||
_element.LayoutUpdated -= OnLayoutUpdated;
|
||||
_element.Unloaded -= OnElementUnloaded;
|
||||
}
|
||||
|
||||
private void UpdateRegistration()
|
||||
{
|
||||
var bounds = GetElementBounds();
|
||||
if (_registrationId is null)
|
||||
{
|
||||
_registrationId = _dragDropService.RegisterDropTarget(_dropTarget, bounds);
|
||||
}
|
||||
else
|
||||
{
|
||||
_dragDropService.UpdateDropTargetBounds(_registrationId, bounds);
|
||||
}
|
||||
}
|
||||
|
||||
private Rect GetElementBounds()
|
||||
{
|
||||
var transform = _element.TransformToVisual(null);
|
||||
var topLeft = transform.TransformPoint(new Windows.Foundation.Point(0, 0));
|
||||
var bottomRight = transform.TransformPoint(new Windows.Foundation.Point(_element.ActualWidth, _element.ActualHeight));
|
||||
|
||||
return new Rect(
|
||||
topLeft.X,
|
||||
topLeft.Y,
|
||||
bottomRight.X - topLeft.X,
|
||||
bottomRight.Y - topLeft.Y);
|
||||
}
|
||||
|
||||
private void OnLayoutUpdated(object? sender, object e)
|
||||
{
|
||||
if (_disposed) return;
|
||||
UpdateRegistration();
|
||||
}
|
||||
|
||||
private void OnElementUnloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_disposed) return;
|
||||
|
||||
UnsubscribeFromEvents();
|
||||
|
||||
if (_registrationId is not null)
|
||||
{
|
||||
_dragDropService.UnregisterDropTarget(_registrationId);
|
||||
_registrationId = null;
|
||||
}
|
||||
|
||||
if (_dropTarget is IDisposable disposable)
|
||||
disposable.Dispose();
|
||||
|
||||
_disposed = true;
|
||||
GC.SuppressFinalize(this);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,30 +198,22 @@ public sealed class WinUIDragDropIntegrationService : IDisposable
|
||||
private readonly IDragDropService _dragDropService;
|
||||
private readonly IDragVisualProvider _dragVisualProvider;
|
||||
private readonly IDragDropHost _dragDropHost;
|
||||
private readonly Dictionary<UIElement, DragSourceAdapter> _dragSources = new();
|
||||
private readonly Dictionary<UIElement, DropTargetAdapter> _dropTargets = new();
|
||||
private readonly Window _window;
|
||||
private readonly Dictionary<FrameworkElement, DragSourceAdapter> _dragSources = new();
|
||||
private readonly Dictionary<FrameworkElement, WinUIDropTargetBehavior> _dropTargets = new();
|
||||
private bool _disposed;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Конструктор
|
||||
|
||||
/// <summary>
|
||||
/// Инициализирует новый экземпляр.
|
||||
/// </summary>
|
||||
public WinUIDragDropIntegrationService(
|
||||
Window window,
|
||||
IDragDropService dragDropService,
|
||||
IDragVisualProvider dragVisualProvider,
|
||||
IDragDropHost dragDropHost)
|
||||
{
|
||||
_window = window ?? throw new ArgumentNullException(nameof(window));
|
||||
_dragDropService = dragDropService ?? throw new ArgumentNullException(nameof(dragDropService));
|
||||
_dragVisualProvider = dragVisualProvider ?? throw new ArgumentNullException(nameof(dragVisualProvider));
|
||||
_dragDropHost = dragDropHost ?? throw new ArgumentNullException(nameof(dragDropHost));
|
||||
|
||||
InitializeEvents();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -302,9 +223,9 @@ public sealed class WinUIDragDropIntegrationService : IDisposable
|
||||
/// <summary>
|
||||
/// Регистрирует элемент как источник перетаскивания.
|
||||
/// </summary>
|
||||
public void RegisterDragSource(UIElement element, Func<Task<DragInfo>> dragInfoFactory)
|
||||
public void RegisterDragSource(FrameworkElement element, Func<DragInfo> dragInfoFactory)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
if (_disposed) throw new ObjectDisposedException(nameof(WinUIDragDropIntegrationService));
|
||||
ArgumentNullException.ThrowIfNull(element);
|
||||
ArgumentNullException.ThrowIfNull(dragInfoFactory);
|
||||
|
||||
@@ -317,39 +238,130 @@ public sealed class WinUIDragDropIntegrationService : IDisposable
|
||||
/// <summary>
|
||||
/// Регистрирует элемент как источник перетаскивания с данными.
|
||||
/// </summary>
|
||||
public void RegisterDragSource(UIElement element, object dragData)
|
||||
public void RegisterDragSource(FrameworkElement element, object dragData)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
ArgumentNullException.ThrowIfNull(element);
|
||||
ArgumentNullException.ThrowIfNull(dragData);
|
||||
|
||||
if (_dragSources.ContainsKey(element)) return;
|
||||
|
||||
var adapter = new DragSourceAdapter(element, dragData, _dragDropService);
|
||||
_dragSources[element] = adapter;
|
||||
RegisterDragSource(element, () =>
|
||||
{
|
||||
var position = GetScreenPosition(element, new Point(0, 0));
|
||||
return new DragInfo(
|
||||
dragData,
|
||||
Core.DragDrop.Enums.DragDropEffects.Copy | Core.DragDrop.Enums.DragDropEffects.Move,
|
||||
position,
|
||||
element
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Регистрирует элемент как цель сброса.
|
||||
/// </summary>
|
||||
public void RegisterDropTarget(UIElement element, IDropTarget dropTarget)
|
||||
public void RegisterDropTarget(FrameworkElement element)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
if (_disposed) throw new ObjectDisposedException(nameof(WinUIDragDropIntegrationService));
|
||||
ArgumentNullException.ThrowIfNull(element);
|
||||
ArgumentNullException.ThrowIfNull(dropTarget);
|
||||
|
||||
if (_dropTargets.ContainsKey(element)) return;
|
||||
|
||||
var adapter = new DropTargetAdapter(element, dropTarget, _dragDropService);
|
||||
_dropTargets[element] = adapter;
|
||||
var behavior = new WinUIDropTargetBehavior(ServiceProviderHelper.GetServiceProvider())
|
||||
{
|
||||
AssociatedElement = element
|
||||
};
|
||||
|
||||
_dropTargets[element] = behavior;
|
||||
|
||||
// Настраиваем события WinUI
|
||||
element.AllowDrop = true;
|
||||
element.DragEnter += OnDragEnter;
|
||||
element.DragOver += OnDragOver;
|
||||
element.DragLeave += OnDragLeave;
|
||||
element.Drop += OnDrop;
|
||||
}
|
||||
|
||||
private Point GetScreenPosition(FrameworkElement element, Point relativePoint)
|
||||
{
|
||||
var transform = element.TransformToVisual(null);
|
||||
var point = transform.TransformPoint(new Windows.Foundation.Point(relativePoint.X, relativePoint.Y));
|
||||
return new Point(point.X, point.Y);
|
||||
}
|
||||
|
||||
private void OnDragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (sender is FrameworkElement element && _dropTargets.TryGetValue(element, out var behavior))
|
||||
{
|
||||
var position = GetScreenPosition(element, e.GetPosition(element).ToCorePoint());
|
||||
var dropInfo = CreateDropInfo(e, position, element);
|
||||
|
||||
if (behavior.CanAcceptDrop(dropInfo))
|
||||
{
|
||||
e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
|
||||
behavior.DragOver(dropInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDragOver(object sender, DragEventArgs e)
|
||||
{
|
||||
if (sender is FrameworkElement element && _dropTargets.TryGetValue(element, out var behavior))
|
||||
{
|
||||
var position = GetScreenPosition(element, e.GetPosition(element).ToCorePoint());
|
||||
var dropInfo = CreateDropInfo(e, position, element);
|
||||
|
||||
if (behavior.CanAcceptDrop(dropInfo))
|
||||
{
|
||||
e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
|
||||
behavior.DragOver(dropInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDragLeave(object sender, DragEventArgs e)
|
||||
{
|
||||
if (sender is FrameworkElement element && _dropTargets.TryGetValue(element, out var behavior))
|
||||
{
|
||||
behavior.DragLeave();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (sender is FrameworkElement element && _dropTargets.TryGetValue(element, out var behavior))
|
||||
{
|
||||
var position = GetScreenPosition(element, e.GetPosition(element).ToCorePoint());
|
||||
var dropInfo = CreateDropInfo(e, position, element);
|
||||
behavior.Drop(dropInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private DropInfo CreateDropInfo(DragEventArgs e, Point position, FrameworkElement target)
|
||||
{
|
||||
// Извлекаем данные из DragEventArgs
|
||||
object? data = null;
|
||||
|
||||
// В реальной реализации нужно извлечь данные из e.DataView
|
||||
// Это упрощенная версия
|
||||
if (e.DataView.Properties.TryGetValue("DragData", out var dragData))
|
||||
{
|
||||
data = dragData;
|
||||
}
|
||||
|
||||
return new DropInfo(
|
||||
data: data,
|
||||
position: position,
|
||||
allowedEffects: Core.DragDrop.Enums.DragDropEffects.Copy | Core.DragDrop.Enums.DragDropEffects.Move,
|
||||
target: target
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаляет регистрацию элемента как источника.
|
||||
/// </summary>
|
||||
public void UnregisterDragSource(UIElement element)
|
||||
public void UnregisterDragSource(FrameworkElement element)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
if (_disposed) throw new ObjectDisposedException(nameof(WinUIDragDropIntegrationService));
|
||||
|
||||
if (_dragSources.Remove(element, out var adapter))
|
||||
{
|
||||
@@ -360,122 +372,38 @@ public sealed class WinUIDragDropIntegrationService : IDisposable
|
||||
/// <summary>
|
||||
/// Удаляет регистрацию элемента как цели.
|
||||
/// </summary>
|
||||
public void UnregisterDropTarget(UIElement element)
|
||||
public void UnregisterDropTarget(FrameworkElement element)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
if (_disposed) throw new ObjectDisposedException(nameof(WinUIDragDropIntegrationService));
|
||||
|
||||
if (_dropTargets.Remove(element, out var adapter))
|
||||
if (_dropTargets.Remove(element, out var behavior))
|
||||
{
|
||||
adapter.Dispose();
|
||||
behavior.Detach();
|
||||
element.AllowDrop = false;
|
||||
element.DragEnter -= OnDragEnter;
|
||||
element.DragOver -= OnDragOver;
|
||||
element.DragLeave -= OnDragLeave;
|
||||
element.Drop -= OnDrop;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Обработка событий
|
||||
|
||||
private void InitializeEvents()
|
||||
{
|
||||
_dragDropService.DragStarted += OnDragStarted;
|
||||
_dragDropService.DragUpdated += OnDragUpdated;
|
||||
_dragDropService.DragCompleted += OnDragCompleted;
|
||||
_dragDropService.DragCancelled += OnDragCancelled;
|
||||
_dragDropService.ErrorOccurred += OnErrorOccurred;
|
||||
}
|
||||
|
||||
private void UnsubscribeFromEvents()
|
||||
{
|
||||
_dragDropService.DragStarted -= OnDragStarted;
|
||||
_dragDropService.DragUpdated -= OnDragUpdated;
|
||||
_dragDropService.DragCompleted -= OnDragCompleted;
|
||||
_dragDropService.DragCancelled -= OnDragCancelled;
|
||||
_dragDropService.ErrorOccurred -= OnErrorOccurred;
|
||||
}
|
||||
|
||||
private void OnDragStarted(object? sender, DragStartedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var visual = _dragVisualProvider.CreateDragVisual(e.DragInfo, e.StartPosition);
|
||||
_dragDropHost.ShowDragVisual(visual, e.StartPosition);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"Error in OnDragStarted: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDragUpdated(object? sender, DragUpdatedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Обновление визуала будет через хост
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"Error in OnDragUpdated: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDragCompleted(object? sender, DragCompletedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_dragDropHost.HideDragVisual(null!); // В реальности нужно передать конкретный визуал
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"Error in OnDragCompleted: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDragCancelled(object? sender, DragCancelledEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_dragDropHost.HideDragVisual(null!);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"Error in OnDragCancelled: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnErrorOccurred(object? sender, DragDropErrorEventArgs e)
|
||||
{
|
||||
Debug.WriteLine($"DragDrop error in {e.Operation}: {e.Exception.Message}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Вспомогательные методы
|
||||
|
||||
private void ThrowIfDisposed()
|
||||
{
|
||||
if (_disposed)
|
||||
throw new ObjectDisposedException(nameof(WinUIDragDropIntegrationService));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
if (_disposed) return;
|
||||
|
||||
UnsubscribeFromEvents();
|
||||
|
||||
foreach (var adapter in _dragSources.Values)
|
||||
{
|
||||
adapter.Dispose();
|
||||
}
|
||||
_dragSources.Clear();
|
||||
|
||||
foreach (var adapter in _dropTargets.Values)
|
||||
foreach (var behavior in _dropTargets.Values)
|
||||
{
|
||||
adapter.Dispose();
|
||||
behavior.Detach();
|
||||
}
|
||||
_dropTargets.Clear();
|
||||
|
||||
@@ -484,4 +412,15 @@ public sealed class WinUIDragDropIntegrationService : IDisposable
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Методы расширения для преобразования координат.
|
||||
/// </summary>
|
||||
internal static class PointExtensions
|
||||
{
|
||||
public static Point ToCorePoint(this Windows.Foundation.Point point)
|
||||
{
|
||||
return new Point(point.X, point.Y);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user