private async Task DragRelease(Point dropPoint) { this.IsDragging = false; VisualProvider?.UpdateVisualPosition(dropPoint); // Fire relevant callback function if dropped in a dropSurface foreach (var dropSurface in dropSurfaces) { if (dropSurface.IsMouseOver) { var dpi = VisualTreeHelper.GetDpi(dropSurface); var scaledPoint = new Point(dropPoint.X / dpi.DpiScaleX, dropPoint.Y / dpi.DpiScaleY); var dropSurfaceScreenPoint = dropSurface.PointToScreen(new Point(0, 0)); var relativePoint = new Point(scaledPoint.X - dropSurfaceScreenPoint.X, scaledPoint.Y - dropSurfaceScreenPoint.Y); var dropArgs = new DropEventArgs { Result = DragDropResult.DroppedToExistingWindow, Data = this.dragObject, RelativeMousePosition = relativePoint, DropSurface = dropSurface, }; dropSurfaceData[dropSurface].DropCallback(dropArgs); VisualProvider?.CloseVisual(dropArgs); dragDropTcs.SetResult(dropArgs); return; } } // Fire event if dropped was not in any dropSurface var newWindowDropArgs = new DropEventArgs { Result = DragDropResult.NewWindowRequested, Data = this.dragObject, DropSurface = null, RelativeMousePosition = dropPoint, }; if (VisualProvider != null) { var newWindowPosition = await VisualProvider.CloseVisual(newWindowDropArgs); newWindowDropArgs.RelativeMousePosition = newWindowPosition; } dragDropTcs.SetResult(newWindowDropArgs); }
public async Task <Point> CloseVisual(DropEventArgs e) { if (e.DropSurface == null) { // Dropped outside tabFloatingDragDropWindow.SetBackgroundColor(); var location = await tabFloatingDragDropWindow.StopMovement(); // Floating tab should stay there a bit more, so the window have time to initialize. FadeOutAfterDelay(); return(location); } else { var location = await tabFloatingDragDropWindow.StopMovement(); tabFloatingDragDropWindow.Stop(); return(location); } }