Example #1
0
        private void onMouseDown(MouseButtonEventArgs args)
        {
            if (args.Button != MouseButton.Left)
            {
                return;
            }
            if (!_selectionMarker.Visible)
            {
                return;
            }
            var obj = _editor.CanvasHitTest.ObjectAtMousePosition;

            if (obj == null)
            {
                return;
            }

            _dragHandle?.Dispose();
            var handle = _editor.Editor.Factory.Object.GetObject($"{obj.ID}_DraggingHandle");

            _dragHandle = new DragHandle(handle, _editor, _editor.Editor.State,
                                         _editor.EditorResolver.Container.Resolve <ActionManager>(), false);
            _dragHandle.SetBox(obj.GetComponent <IBoundingBoxComponent>());
            _dragHandle.SetTranslate(obj.GetComponent <ITranslateComponent>());
            _dragHandle.SetImage(obj.GetComponent <IImageComponent>());
            handle.GetComponent <IDraggableComponent>().SimulateMouseDown(args);
        }
Example #2
0
        public override void Init()
        {
            base.Init();
            addResizeHandles(Entity, Direction.Right, Direction.Left, Direction.Up, Direction.Down,
                             Direction.UpRight, Direction.UpLeft, Direction.DownRight, Direction.DownLeft);
            addRotateHandles(Entity, Direction.UpRight, Direction.UpLeft, Direction.DownRight, Direction.DownLeft);
            addPivotHandle(Entity);
            addDragHandle(Entity);

            Entity.Bind <IScaleComponent>(setScale, _ => setScale(null));
            Entity.Bind <IRotateComponent>(setRotate, _ => setRotate(null));
            Entity.Bind <IImageComponent>(setImage, _ => setImage(null));
            Entity.Bind <ITranslateComponent>(setTranslate, _ => setTranslate(null));
            Entity.Bind <IDrawableInfoComponent>(setDrawable, _ => setDrawable(null));

            Entity.Bind <IBoundingBoxComponent>(
                c => { _box = c; c.OnBoundingBoxesChanged.Subscribe(onBoundingBoxChanged); _pivotHandle?.SetBox(c); _dragHandle?.SetBox(c); updatePositions(); },
                c => { _box = null; c.OnBoundingBoxesChanged.Unsubscribe(onBoundingBoxChanged); _pivotHandle?.SetBox(null); _dragHandle?.SetBox(null); });

            Entity.Bind <EditorUIEvents>(c => c.MouseClicked.Subscribe(onMouseClicked), c => c.MouseClicked.Unsubscribe(onMouseClicked));

            _events.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);
        }