Beispiel #1
0
        private void DragBeginAction(DragEventArgs e)
        {
            DataObject data         = e.Data as DataObject;
            var        dragObjQuery = new ConvertOperation(data, ConvertOperation.Operation.All).Perform <GameObject>();

            if (dragObjQuery != null)
            {
                List <GameObject> dragObj = dragObjQuery.ToList();

                bool    lockZ      = this.CameraComponent.FocusDist <= 0.0f;
                Point   mouseLoc   = this.PointToClient(new Point(e.X, e.Y));
                Vector3 spaceCoord = this.GetSpaceCoord(new Vector3(
                                                            mouseLoc.X,
                                                            mouseLoc.Y,
                                                            lockZ ? 0.0f : this.CameraObj.Transform.Pos.Z + MathF.Abs(this.CameraComponent.FocusDist)));

                // Setup GameObjects
                CreateGameObjectAction      createAction = new CreateGameObjectAction(null, dragObj);
                DropGameObjectInSceneAction dropAction   = new DropGameObjectInSceneAction(dragObj, spaceCoord, this.CameraObj.Transform.Angle);
                UndoRedoManager.BeginMacro(dropAction.Name);
                UndoRedoManager.Do(createAction);
                UndoRedoManager.Do(dropAction);

                // Select them & begin action
                this.selBeforeDrag = DualityEditorApp.Selection;
                this.SelectObjects(createAction.Result.Select(g => new SelGameObj(g) as SelObj));
                this.BeginAction(ObjectAction.Move);

                // Get focused
                this.Focus();

                e.Effect = e.AllowedEffect;
            }
        }
        private void DragBeginAction(DragEventArgs e)
        {
            DataObject data = e.Data as DataObject;
            var dragObjQuery = new ConvertOperation(data, ConvertOperation.Operation.All).Perform<GameObject>();
            if (dragObjQuery != null)
            {
                List<GameObject> dragObj = dragObjQuery.ToList();

                bool lockZ = this.CameraComponent.FocusDist <= 0.0f;
                Point mouseLoc = this.PointToClient(new Point(e.X, e.Y));
                Vector3 spaceCoord = this.GetSpaceCoord(new Vector3(
                    mouseLoc.X,
                    mouseLoc.Y,
                    lockZ ? 0.0f : this.CameraObj.Transform.Pos.Z + MathF.Abs(this.CameraComponent.FocusDist)));

                // Setup GameObjects
                CreateGameObjectAction createAction = new CreateGameObjectAction(null, dragObj);
                DropGameObjectInSceneAction dropAction = new DropGameObjectInSceneAction(dragObj, spaceCoord, this.CameraObj.Transform.Angle);
                UndoRedoManager.BeginMacro(dropAction.Name);
                UndoRedoManager.Do(createAction);
                UndoRedoManager.Do(dropAction);

                // Select them & begin action
                this.selBeforeDrag = DualityEditorApp.Selection;
                this.SelectObjects(createAction.Result.Select(g => new SelGameObj(g) as SelObj));
                this.BeginAction(ObjectAction.Move);

                // Get focused
                this.Focus();

                e.Effect = e.AllowedEffect;
            }
        }