/// <summary> /// Return true if the element is the last in the queue /// </summary> /// <returns></returns> public void Redo() { if (_redoLines.Count != 0) { Tuple <ActionType, ILineModel> line = _redoLines.Pop(); switch (line.Item1) { case ActionType.Add: CreateLine(line.Item2, true); LineAddedSignal.Dispatch(line.Item2); break; case ActionType.Edit: UpdateLine(line.Item2, true); LineUpdatedSignal.Dispatch(line.Item2); break; case ActionType.Delete: DeleteLine(line.Item2, true); LineDeletedSignal.Dispatch(line.Item2.Guid); break; } } SaveAvailableSignal.Dispatch(_redoLines.Count != 0); RedoAvailableSignal.Dispatch(_redoLines.Count != 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); } }
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); } }
public override void OnRemove() { base.OnRemove(); UndoAvailableSignal.RemoveListener(OnUndoAvailableReceived); RedoAvailableSignal.RemoveListener(OnRedoAvailableReceived); SaveAvailableSignal.RemoveListener(OnSaveAvailableReceived); FullCleanupSignal.RemoveListener(OnFullCleanupReceived); View.PointerInfoSignal.RemoveListener(OnPointerSignal); View.UndoSignal.RemoveListener(OnUndoRequested); View.RedoSignal.RemoveListener(OnRedoRequested); View.ToggleDrawModeSignal.RemoveListener(OnToggleDrawMode); View.SaveProjectSignal.RemoveListener(OnSaveRequested); View.SaveProjectAsSignal.RemoveListener(OnSaveAsRequested); View.LoadProjectSignal.RemoveListener(OnLoadRequested); View.NewProjectSignal.RemoveListener(OnNewRequested); }