private void TouchUp(object sender, TouchEventArgs e) { if (!Game.Input.IsMouseButtonReleased(MouseButton.Left)) { return; } isInProgress = false; Controller.ChangeCursor(null); e.Handled = true; // dragging state if (isDragging) { isDragging = false; if (dragAdorner != null) { // Create a collection with all properties that might have changed var changes = new Dictionary <string, object> { { nameof(UIElement.Margin), dragAdorner.GameSideElement.Margin }, { nameof(UIElement.Width), dragAdorner.GameSideElement.Width }, { nameof(UIElement.HorizontalAlignment), dragAdorner.GameSideElement.HorizontalAlignment }, { nameof(UIElement.Height), dragAdorner.GameSideElement.Height }, { nameof(UIElement.VerticalAlignment), dragAdorner.GameSideElement.VerticalAlignment }, //{ nameof(UIElement.Depth), dragAdorner.GameSideElement.Depth }, //{ nameof(UIElement.DepthAlignment), dragAdorner.GameSideElement.DepthAlignment }, }; // Propagate the changes to the asset ApplyChanges(dragAdorner.GameSideElement.Id, changes); dragAdorner.OnResizingCompleted(); } dragAdorner = null; return; } // other states var editor = Controller.Editor; var worldPosition = e.WorldPosition; // Get the id of the game-side element that is under the pointer position Guid elementId; if (!TryGetElementIdAtPosition(ref worldPosition, out elementId)) { // Nothing, clear the selection editor.Dispatcher.InvokeAsync(() => editor.ClearSelection()); return; } // Select the corresponding asset-side UIElement, if pointer did not move between down and up events var delta = (e.ScreenPosition - originScreenPosition) * new Vector2(Game.GraphicsDevice.Presenter.BackBuffer.Width, Game.GraphicsDevice.Presenter.BackBuffer.Height); if (Math.Abs(delta.X) < System.Windows.SystemParameters.MinimumHorizontalDragDistance && Math.Abs(delta.Y) < System.Windows.SystemParameters.MinimumVerticalDragDistance) { var additiveSelection = Game.Input.IsKeyDown(Keys.LeftCtrl) || Game.Input.IsKeyDown(Keys.RightCtrl); editor.Dispatcher.InvokeAsync(() => editor.Select(elementId, additiveSelection)).Forget(); } }
/// <summary> /// Cancels the current dragging state. /// </summary> private void CancelDrag() { if (!isInProgress) { return; } isInProgress = false; Controller.ChangeCursor(null); if (!isDragging) { return; } dragAdorner?.OnResizingCompleted(); }