private void AddEvent(UndoEvent e)
 {
     if (this._events == null)
     {
         this._events = new ArrayList();
     }
     this._events.Add(e);
 }
Beispiel #2
0
 public void redo(DOCUMENT_TYPE currentState)
 {
     if (canRedo())
     {
         UndoEvent state = redoBuffer.Pop();
         undoBuffer.Push(new UndoEvent(state.actionName, currentState));
         onUndo((DOCUMENT_TYPE)state.obj.Clone());
     }
 }
Beispiel #3
0
        /// <summary>
        /// the undo uobject is only deserialized after an undo operation.
        /// </summary>
        public void OnAfterDeserialize()
        {
            if (null == serialized || Workspace == null)
            {
                return;
            }

            Workspace.Canvas.ForegroundColor = serialized.foregroundColor;
            Workspace.Canvas.BackgroundColor = serialized.backgroundColor;

            Workspace.Canvas.File.animations = serialized.animations.Select(a => new PAAnimation
            {
                name = a.name,
                id   = a.id
            }).ToList();

            Workspace.Canvas.File.layers = serialized.layers.Select(l => new PALayer(Workspace.Canvas.File)
            {
                id      = l.id,
                name    = l.name,
                opacity = l.opacity,
                order   = l.order,
                visible = l.visible,
            }).ToList();

            Workspace.Canvas.File.frames = serialized.frames.Select(f => new PAFrame(Workspace.Canvas.File)
            {
                id        = f.id,
                animation = Workspace.Canvas.File.FindAnimation(f.animation),
                order     = f.order
            }).ToList();

            Workspace.Canvas.File.images = serialized.images.Select(i => new PAImage
            {
                frame   = Workspace.Canvas.File.FindFrame(i.frame),
                layer   = Workspace.Canvas.File.FindLayer(i.layer),
                texture = i.texture
            }).ToList();

            Workspace.RefreshLayersList();
            Workspace.RefreshFrameList();
            Workspace.RefreshAnimationList();

            Workspace.Canvas.ActiveAnimation = Workspace.Canvas.File.FindAnimation(serialized.selectedAnimation);
            Workspace.Canvas.ActiveLayer     = Workspace.Canvas.File.FindLayer(serialized.selectedLayer);
            Workspace.Canvas.ActiveFrame     = Workspace.Canvas.File.FindFrame(serialized.selectedFrame);

            Workspace.Canvas.RefreshImage();

            serialized = null;

            UndoEvent?.Invoke();
        }
Beispiel #4
0
        public void Undo()
        {
            var eventToUndo = eventStore.LastOrDefault(o => o.Type != EventType.Undo);

            var undoEvent = new UndoEvent()
            {
                Id        = eventStore.Count,
                Type      = EventType.Undo,
                Data      = eventToUndo,
                TimeStamp = DateTime.Now
            };

            eventStore.Add(undoEvent);

            hanlder.Handle(undoEvent);
        }
Beispiel #5
0
        public void Undo()
        {
            if (!CanUndo)
            {
                return;
            }

            _strokeService.MoveStrokesEvent -= StrokeService_MoveStrokesEvent;

            var element = undoStack.Pop();

            element.ExecuteUndo();
            redoStack.Push(element);

            _strokeService.MoveStrokesEvent += StrokeService_MoveStrokesEvent;
            UndoEvent?.Invoke(this, EventArgs.Empty);
        }
Beispiel #6
0
        public void Attach([NotNull] Canvas canvas)
        {
            canvas.MouseLeftButtonDown += (sender, args) => {
                if (!_leftMouseDown)
                {
                    _lastPoint     = args.GetPosition(canvas);
                    MouseDownStart = _lastPoint.X;
                    _leftMouseDown = true;
                }
            };
            canvas.MouseMove += (sender, args) => {
                var now = DateTime.Now.Millisecond;
                if (now - _lastTime <= 100)
                {
                    return;
                }
                var point = args.GetPosition(canvas);
                FollowTraceEvent?.Invoke(_lastPoint, point, _leftMouseDown);
                _lastPoint = point;
            };
            canvas.MouseLeftButtonUp += (sender, args) => {
                if (!_leftMouseDown)
                {
                    return;
                }
                var zoomEnd = args.GetPosition(canvas).X;
                if (zoomEnd < MouseDownStart)
                {
                    var t = zoomEnd;
                    zoomEnd        = MouseDownStart;
                    MouseDownStart = t;
                }

                ZoomEvent?.Invoke(MouseDownStart, zoomEnd, !(zoomEnd - MouseDownStart <= 12));

                _leftMouseDown = false;
            };
            canvas.MouseRightButtonDown += (sender, args) => { UndoEvent?.Invoke(); };
            canvas.MouseDown            += (sender, args) => {
                if (args.ChangedButton == MouseButton.Middle)
                {
                    AdjustYAxisEvent?.Invoke();
                }
            };
        }
 private void AddEvent(UndoEvent e)
 {
     if (this._events == null)
     {
         this._events = new ArrayList();
     }
     this._events.Add(e);
 }
Beispiel #8
0
 private void OnUndoEvent(UndoEvent undoEvent)
 {
     selectedHero.UndoMovement();
 }