public bool Undo() { if (m_project.VoiceActorList.Actors.Any(a => a.Name == m_deletedActor.Name)) { return(false); } CharacterGroup assignedCharacterGroup = null; if (m_characterIdsOfAssignedGroup != null) { assignedCharacterGroup = GroupAssignedToActor; if (assignedCharacterGroup == null) { return(false); } } var replacementActor = m_deletedActor.MakeCopy(); while (m_project.VoiceActorList.Actors.Any(a => a.Id == replacementActor.Id)) { replacementActor.Id++; } m_project.VoiceActorList.Actors.Add(replacementActor); if (assignedCharacterGroup != null) { assignedCharacterGroup.AssignVoiceActor(replacementActor.Id); } return(true); }
public VoiceActorAddedUndoAction(Project project, int affectedActor) { m_addedActorInformation = project.VoiceActorList.GetVoiceActorById(affectedActor); if (m_addedActorInformation == null) { throw new ArgumentException("Affected actor must be in the project", "affectedActor"); } m_project = project; m_addedActorInformation = m_addedActorInformation.MakeCopy(); }
public bool Redo() { if (m_project.VoiceActorList.Actors.Any(a => a.Name == m_addedActorInformation.Name)) { return(false); } var replacementActor = m_addedActorInformation.MakeCopy(); while (m_project.VoiceActorList.Actors.Any(a => a.Id == replacementActor.Id)) { replacementActor.Id++; } m_project.VoiceActorList.Actors.Add(replacementActor); return(true); }
public bool Redo() { var affectedActor = m_project.VoiceActorList.GetVoiceActorById(m_previousActorInformation.Id); if (affectedActor == null || m_project.VoiceActorList.Actors.Any(a => !a.Equals(affectedActor) && a.Name == m_affectedActorInformation.Name)) { return(false); } var index = m_project.VoiceActorList.Actors.IndexOf(affectedActor); m_project.VoiceActorList.Actors.RemoveAt(index); m_project.VoiceActorList.Actors.Insert(index, m_affectedActorInformation.MakeCopy()); return(true); }