Beispiel #1
0
        public PreviewMovingHandler(PreviewWindow parent, Control ctrl)
        {
            _Parent  = parent;
            _Control = ctrl;

            _PreviewX = ctrl.Width / 2;
            _PreviewY = ctrl.Height / 2;
            parent.Render.Transform.X = _PreviewX;
            parent.Render.Transform.Y = _PreviewY;

            MovablePreview              = new MouseMovable(ctrl, MouseButtons.Middle, _PreviewMovingX, _PreviewMovingY);
            MovablePreview.OnMovedDiff += delegate(int x, int y)
            {
                _PreviewMovingX = x;
                _PreviewMovingY = y;

                parent.Render.Transform.X = _PreviewX + _PreviewMovingX;
                parent.Render.Transform.Y = _PreviewY + _PreviewMovingY;

                OnSceneMoved();
            };
            MovablePreview.OnMoveFinished += delegate()
            {
                _PreviewX      += _PreviewMovingX;
                _PreviewY      += _PreviewMovingY;
                _PreviewMovingX = 0;
                _PreviewMovingY = 0;

                parent.Render.Transform.X = _PreviewX;
                parent.Render.Transform.Y = _PreviewY;

                OnSceneMoved();
            };

            //mouse wheel zoom in/out
            ctrl.FindForm().MouseWheel += _Control_MouseWheel;
            ctrl.MouseWheel += _Control_MouseWheel;
        }
Beispiel #2
0
        public SpriteMovingHandler(Editor editor, Control ctrl)
        {
            var window = editor.PreviewWindowUI;

            var move = new MouseMovable(ctrl, MouseButtons.Left, 0, 0);

            move.FilterMouseDown += window.GetFilterForEditMode(FrameEditMode.Move);
            move.OnMovedDiff     += delegate(int x, int y)
            {
                SpriteMovingX = (int)(-x / window.PreviewMoving.PreviewScale);
                SpriteMovingY = (int)(-y / window.PreviewMoving.PreviewScale);
            };
            move.OnMoveFinished += delegate()
            {
                var frame = editor.CurrentFrame;
                if (frame != null)
                {
                    frame.OriginX += SpriteMovingX;
                    frame.OriginY += SpriteMovingY;
                }
                SpriteMovingX = 0;
                SpriteMovingY = 0;
            };
        }