Example #1
0
        /// <summary>
        /// Return true if the element is the last in the queue
        /// </summary>
        /// <returns></returns>
        public void Undo()
        {
            if (_undoLines.Count != 0)
            {
                Tuple <ActionType, ILineModel> line = _undoLines.Pop();
                switch (line.Item1)
                {
                case ActionType.Add:
                    DeleteLine(line.Item2, false);
                    LineDeletedSignal.Dispatch(line.Item2.Guid);
                    break;

                case ActionType.Edit:
                    UpdateLine(line.Item2, false);
                    LineUpdatedSignal.Dispatch(line.Item2);
                    break;

                case ActionType.Delete:
                    CreateLine(line.Item2, false);
                    LineAddedSignal.Dispatch(line.Item2);
                    break;
                }
            }
            SaveAvailableSignal.Dispatch(_undoLines.Count != 0);
            UndoAvailableSignal.Dispatch(_undoLines.Count != 0);
        }
Example #2
0
 private void UpdateLine(ILineModel line, bool undo)
 {
     ProjectService.UpdateLine((LineModel)line);
     if (undo)
     {
         _undoLines.Push(new Tuple <ActionType, ILineModel>(ActionType.Edit, line));
         UndoAvailableSignal.Dispatch(true);
     }
     else
     {
         _redoLines.Push(new Tuple <ActionType, ILineModel>(ActionType.Edit, line));
         RedoAvailableSignal.Dispatch(true);
     }
 }
Example #3
0
 private void DeleteLine(ILineModel line, bool undo)
 {
     ProjectService.DeleteLine(line.Guid);
     if (undo)
     {
         _undoLines.Push(new Tuple <ActionType, ILineModel>(ActionType.Delete, line));
         UndoAvailableSignal.Dispatch(true);
     }
     else
     {
         _redoLines.Push(new Tuple <ActionType, ILineModel>(ActionType.Add, line));
         RedoAvailableSignal.Dispatch(true);
     }
 }
Example #4
0
 private void OnAddLineReceived(ILineModel line)
 {
     _undoLines.Push(new Tuple <ActionType, ILineModel>(ActionType.Add, line));
     UndoAvailableSignal.Dispatch(true);
     SaveAvailableSignal.Dispatch(true);
 }