public void OnMouseUp(Point mousePosition, EditorOperationHitTest hitTest, IEditorOperationalContext context) { if (!context.IsExclusiveOperation(null)) { return; // Something else is being performed } if (selectionElement == hitTest?.Element && !Keyboard.IsKeyDown(Key.LeftCtrl)) { context.SelectedElements.Clear(); } if (!MatchesSelection(hitTest?.Element)) { return; } if (!context.SelectedElements.Contains(selectionElement)) { context.SelectedElements.Add(selectionElement); } else { context.SelectedElements.Remove(selectionElement); } }
public void OnMouseDown(Point mousePosition, EditorOperationHitTest hitTest, IEditorOperationalContext context) { initialMousePosition = mousePosition; element = new PositionalComponent(context.PlaceType.Type, context.PlaceType.Configuration, initialMousePosition.ToCdPoint()); SizeComponent(element, initialMousePosition.ToCdPoint(), initialMousePosition.ToCdPoint(), context.GridSize); SetDefaultProperties(element); SetConfigurationProperties(element); context.AddElement(element); }
public bool OnMouseMove(Point mousePosition, EditorOperationHitTest hitTest, IEditorOperationalContext context) { if (element == null) { return(false); } SizeComponent(element, initialMousePosition.ToCdPoint(), mousePosition.ToCdPoint(), context.GridSize); context.UpdateElementPosition(element); context.ReRenderElement(element); return(true); }
public void OnMouseDown(Point mousePosition, EditorOperationHitTest hitTest, IEditorOperationalContext context) { if (hitTest.ResizeHandle == null || element == null) { // Not resizing element = null; return; } Log.LogInformation($"Starting resize on {hitTest.ResizeHandle.Value} handle"); initialMousePosition = mousePosition; initialLocation = element.Layout.Location; initialSize = element.Layout.Size; mode = hitTest.ResizeHandle.Value; isResizing = true; }
public void OnMouseDown(Point mousePosition, EditorOperationHitTest hitTest, IEditorOperationalContext context) { // 1. Move selected elements if the mouse is over one of them if (context.SelectedElements.Contains(hitTest.Element)) { elements = context.SelectedElements.ToArray(); } // 2. Move element the mouse is over else if (hitTest.Element != null) { elements = new[] { hitTest.Element } } ; if (!elements.Any()) { return; } initialMousePosition = mousePosition; initialLocations = elements.ToDictionary(x => x, x => x.Layout.Location); }
public bool OnMouseMove(Point mousePosition, EditorOperationHitTest hitTest, IEditorOperationalContext context) { if (hitTest.Element != null && hitTest.ResizeHandle == null) { context.Cursor = Cursors.SizeAll; } if (!elements.Any()) { return(false); } var offset = new Primitives.Vector(mousePosition.X - initialMousePosition.X, mousePosition.Y - initialMousePosition.Y); foreach (var element in elements) { var newLocation = initialLocations[element].Add(offset).SnapToGrid(context.GridSize); element.Layout.Location = newLocation; context.UpdateElementPosition(element); } return(true); }
public bool OnMouseMove(Point mousePosition, EditorOperationHitTest hitTest, IEditorOperationalContext context) { // Do nothing return(false); }
public void OnMouseDown(Point mousePosition, EditorOperationHitTest hitTest, IEditorOperationalContext context) { selectionElement = hitTest?.Element; initialLocation = selectionElement?.Layout.Location; initialSize = selectionElement?.Layout.Size; }
public bool OnMouseMove(Point mousePosition, EditorOperationHitTest hitTest, IEditorOperationalContext context) { if (!isResizing) { if (hitTest.Element == null && hitTest.ResizeHandle == null) { // Nothing under the cursor if (element != null) { Log.LogInformation("Nothing prepared for resize"); element = null; } return(false); } if (element == null && hitTest.Element != null) { Log.LogInformation($"{hitTest.Element} prepared for resize"); // Mouse is over an element - resize it later element = hitTest.Element; return(false); } if (hitTest.ResizeHandle != null) { context.Cursor = Cursors.SizeNS; } return(false); } // Resizing in progress var offset = new Vector(mousePosition.X - initialMousePosition.X, mousePosition.Y - initialMousePosition.Y); double diff = element.Layout.Orientation == Orientation.Horizontal ? offset.X : offset.Y; if (mode == ResizeHandle.Begin) { diff = -diff; } diff = SnapToGrid(diff, context.GridSize); element.Layout.Size = initialSize + diff; if (mode == ResizeHandle.Begin && element.Layout.Orientation == Orientation.Horizontal) { element.Layout.Location = element.Layout.Location.WithNewX(initialLocation.X - diff); } else if (mode == ResizeHandle.Begin) { element.Layout.Location = element.Layout.Location.WithNewY(initialLocation.Y - diff); } context.UpdateElementPosition(element); context.ReRenderElement(element); return(true); }
public void OnMouseUp(Point mousePosition, EditorOperationHitTest hitTest, IEditorOperationalContext context) { // Finish resizing if it's in progress Abort(); }
public void OnMouseUp(Point mousePosition, EditorOperationHitTest hitTest, IEditorOperationalContext context) { Abort(); context.ReleaseExclusiveOperation(); }
public void OnMouseUp(Point mousePosition, EditorOperationHitTest hitTest, IEditorOperationalContext context) { // Finish Abort(); }