コード例 #1
0
        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);
            }
        }
コード例 #2
0
 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);
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        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;
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 public bool OnMouseMove(Point mousePosition, EditorOperationHitTest hitTest, IEditorOperationalContext context)
 {
     // Do nothing
     return(false);
 }
コード例 #8
0
 public void OnMouseDown(Point mousePosition, EditorOperationHitTest hitTest, IEditorOperationalContext context)
 {
     selectionElement = hitTest?.Element;
     initialLocation  = selectionElement?.Layout.Location;
     initialSize      = selectionElement?.Layout.Size;
 }
コード例 #9
0
        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);
        }
コード例 #10
0
 public void OnMouseUp(Point mousePosition, EditorOperationHitTest hitTest, IEditorOperationalContext context)
 {
     // Finish resizing if it's in progress
     Abort();
 }
コード例 #11
0
 public void OnMouseUp(Point mousePosition, EditorOperationHitTest hitTest, IEditorOperationalContext context)
 {
     Abort();
     context.ReleaseExclusiveOperation();
 }
コード例 #12
0
 public void OnMouseUp(Point mousePosition, EditorOperationHitTest hitTest, IEditorOperationalContext context)
 {
     // Finish
     Abort();
 }