using QuikDawEditor.EditingClasses; using System.Collections.Generic; using System.Windows; using static QuikDawEditor.EDITING.StaticProperties; using static QuikDawEditor.EDITING.MiscMethods; namespace QuikDawEditor.Undo; //Project level undo actions public class AutoPointAddedUndoClass : UndoClass { public string UndoMainValue { get { return "Remove autopoint index: " + AddedIndex.ToString(); } } int AddedIndex = -1; string UndoTrackID; int autoLaneIndex = 0; public AutoPointAddedUndoClass(string undoTrackID, int autolaneindex, int autopointIdx) { UndoTrackID = undoTrackID; autoLaneIndex = autolaneindex; AddedIndex = autopointIdx; } public override void Undo() {//master track trackno: -1 AutomationLane thisAutoLane; if (UndoTrackID == "MASTERTRACK") thisAutoLane = editingProject.MasterTrack.AutomationLanes[autoLaneIndex]; else thisAutoLane = GetTrackFromID(UndoTrackID).AutomationLanes[autoLaneIndex]; thisAutoLane.autoPoints.RemoveAt(AddedIndex); thisAutoLane.NotifyAutoPointsChanged(); } } public class AutoPointDeletedUndoClass : UndoClass { public string UndoMainValue { get { return "Add autopoint idx: " + DeletedIndex.ToString(); } } int DeletedIndex = -1; string UndoTrackID; int AutoLaneIndex = 0; AutoPoint RestoreAP; public AutoPointDeletedUndoClass(string undoTrackID, int autolaneindex, int autopointIdx, AutoPoint restoreAP) {UndoTrackID = undoTrackID; AutoLaneIndex = autolaneindex; DeletedIndex = autopointIdx; RestoreAP = restoreAP; } public override void Undo() {//master track trackno: -1 AutomationLane thisAutoLane; if (UndoTrackID == "MASTERTRACK") thisAutoLane = editingProject.MasterTrack.AutomationLanes[AutoLaneIndex]; else thisAutoLane = GetTrackFromID(UndoTrackID).AutomationLanes[AutoLaneIndex]; thisAutoLane.autoPoints.Insert(DeletedIndex, RestoreAP); thisAutoLane.NotifyAutoPointsChanged(); } } public class AutoPointMovedUndoClass : UndoClass { public string UndoMainValue { get { return "Move autopoint back: " + AutopointMs.ToString() + "::" + AutopointVal.ToString(); } } string UndoTrackID; int AutoLaneIndex = 0; int AutopointIdx = -1; double AutopointMs = 0; float AutopointVal = 0; public AutoPointMovedUndoClass(string undoTrackID, int autolaneindex, int autopointIdx, double autopointMs, float autopointVal) { UndoTrackID = undoTrackID; AutoLaneIndex = autolaneindex; AutopointIdx = autopointIdx; AutopointMs = autopointMs; AutopointVal = autopointVal; } public override void Undo() {//master track trackno: -1 AutomationLane thisAutoLane; if (UndoTrackID == "MASTERTRACK") thisAutoLane = editingProject.MasterTrack.AutomationLanes[AutoLaneIndex]; else thisAutoLane = GetTrackFromID(UndoTrackID).AutomationLanes[AutoLaneIndex]; thisAutoLane.autoPoints[AutopointIdx].sourcePointms = AutopointMs; thisAutoLane.autoPoints[AutopointIdx].AutoValue = AutopointVal; thisAutoLane.NotifyAutoPointsChanged(); } } public class AutoPointsClearedUndoClass : UndoClass { public string UndoMainValue { get { return "Restore cleared autopts: " + RestoreAutopoints.Count.ToString(); } } string UndoTrackID; int AutoLaneIndex = 0; List RestoreAutopoints; float ClipStartAPVal, ClipEndAPVal; public AutoPointsClearedUndoClass(string undoTrackID, int autolaneindex, List restoreAutoPoints, float clipStartAPVal, float clipEndAPVal) { UndoTrackID = undoTrackID; AutoLaneIndex = autolaneindex; RestoreAutopoints = restoreAutoPoints; ClipStartAPVal = clipStartAPVal; ClipEndAPVal = clipEndAPVal; } public override void Undo() {//master track trackno: -1 AutomationLane thisAutoLane; if (UndoTrackID == "MASTERTRACK") thisAutoLane = editingProject.MasterTrack.AutomationLanes[AutoLaneIndex]; else thisAutoLane = GetTrackFromID(UndoTrackID).AutomationLanes[AutoLaneIndex]; thisAutoLane.ClipStartAutoPoint.AutoValue = ClipStartAPVal; thisAutoLane.ClipEndAutoPoint.AutoValue = ClipEndAPVal; foreach (AutoPoint ap in RestoreAutopoints) thisAutoLane.autoPoints.Insert(1, ap); thisAutoLane.NotifyAutoPointsChanged(); } } public class AutoPointsFadeInUndoClass : UndoClass { public string UndoMainValue { get { return "Remove fadeIn at: " + insertedAutopointIndex.ToString(); } } string UndoTrackID; int AutoLaneIndex = 0; int insertedAutopointIndex = -1; List RestoreAutopoints; float ClipStartAPVal; public AutoPointsFadeInUndoClass(string undoTrackID, int autolaneindex, int insertAPIdx, List restoreAutoPoints, float clipStartAPVal) { UndoTrackID = undoTrackID; AutoLaneIndex = autolaneindex; insertedAutopointIndex = insertAPIdx; RestoreAutopoints = restoreAutoPoints; ClipStartAPVal = clipStartAPVal; } public override void Undo() {//master track trackno: -1 AutomationLane thisAutoLane; if (UndoTrackID == "MASTERTRACK") thisAutoLane = editingProject.MasterTrack.AutomationLanes[AutoLaneIndex]; else thisAutoLane = GetTrackFromID(UndoTrackID).AutomationLanes[AutoLaneIndex]; thisAutoLane.autoPoints.RemoveAt(insertedAutopointIndex); thisAutoLane.ClipStartAutoPoint.AutoValue = ClipStartAPVal; for (int restoreno = RestoreAutopoints.Count - 1; restoreno > -1; restoreno--) thisAutoLane.autoPoints.Insert(insertedAutopointIndex, RestoreAutopoints[restoreno]); thisAutoLane.NotifyAutoPointsChanged(); } } public class AutoPointsFadeOutUndoClass : UndoClass { public string UndoMainValue { get { return "Remove fadeOut at: " + insertedAutopointIndex.ToString(); } } string UndoTrackID; int AutoLaneIndex = 0; int insertedAutopointIndex = -1; List RestoreAutopoints; float ClipEndAPVal; public AutoPointsFadeOutUndoClass(string undoTrackID, int autolaneindex, int insertAPIdx, List restoreAutoPoints, float clipEndAPVal) { UndoTrackID = undoTrackID; AutoLaneIndex = autolaneindex; insertedAutopointIndex = insertAPIdx; RestoreAutopoints = restoreAutoPoints; ClipEndAPVal = clipEndAPVal; } public override void Undo() {//master track trackno: -1 AutomationLane thisAutoLane; if (UndoTrackID == "MASTERTRACK") thisAutoLane = editingProject.MasterTrack.AutomationLanes[AutoLaneIndex]; else thisAutoLane = GetTrackFromID(UndoTrackID).AutomationLanes[AutoLaneIndex]; thisAutoLane.autoPoints.RemoveAt(insertedAutopointIndex); thisAutoLane.ClipEndAutoPoint.AutoValue = ClipEndAPVal; for (int restoreno = RestoreAutopoints.Count - 1; restoreno > -1; restoreno--) thisAutoLane.autoPoints.Insert(insertedAutopointIndex, RestoreAutopoints[restoreno]); thisAutoLane.NotifyAutoPointsChanged(); } } public class AutoPointsSelectionClearedOrResetUndoClass : UndoClass { public string UndoMainValue { get { return "Restore cleared: " + RestoreAutopoints.Count.ToString(); } } string UndoTrackID; int AutoLaneIndex = 0; int ResetPointsIdx = -1; List RestoreAutopoints; bool EndsAdded = false; public AutoPointsSelectionClearedOrResetUndoClass(string undoTrackID, int autolaneindex, int resetPtsIdx, List restoreAutoPoints, bool endsadded) { UndoTrackID = undoTrackID; AutoLaneIndex = autolaneindex; ResetPointsIdx = resetPtsIdx; RestoreAutopoints = restoreAutoPoints; EndsAdded = endsadded; } public override void Undo() {//master track trackno: -1 AutomationLane thisAutoLane; if (UndoTrackID == "MASTERTRACK") thisAutoLane = editingProject.MasterTrack.AutomationLanes[AutoLaneIndex]; else thisAutoLane = GetTrackFromID(UndoTrackID).AutomationLanes[AutoLaneIndex]; if (EndsAdded) { thisAutoLane.autoPoints.RemoveAt(ResetPointsIdx); thisAutoLane.autoPoints.RemoveAt(ResetPointsIdx); } for (int restoreno = RestoreAutopoints.Count - 1; restoreno > -1; restoreno--) thisAutoLane.autoPoints.Insert(ResetPointsIdx, RestoreAutopoints[restoreno]); thisAutoLane.NotifyAutoPointsChanged(); } } public class AutoPointsSelectionMutedUndoClass: UndoClass { public string UndoMainValue { get { return "Restore mute cleared: " + RestoreAutopoints.Count.ToString(); } } string UndoTrackID; int AutoLaneIndex = 0; int ResetPointsIdx = -1; List RestoreAutopoints; public AutoPointsSelectionMutedUndoClass(string undoTrackID, int autolaneindex, int resetPtsIdx, List restoreAutoPoints) { UndoTrackID = undoTrackID; AutoLaneIndex = autolaneindex; ResetPointsIdx = resetPtsIdx; RestoreAutopoints = restoreAutoPoints; } public override void Undo() {//master track trackno: -1 AutomationLane thisAutoLane; if (UndoTrackID == "MASTERTRACK") thisAutoLane = editingProject.MasterTrack.AutomationLanes[AutoLaneIndex]; else thisAutoLane = GetTrackFromID(UndoTrackID).AutomationLanes[AutoLaneIndex]; for (int i = 0; i < 4; i++) thisAutoLane.autoPoints.RemoveAt(ResetPointsIdx); for (int restoreno = RestoreAutopoints.Count - 1; restoreno > -1; restoreno--) thisAutoLane.autoPoints.Insert(ResetPointsIdx, RestoreAutopoints[restoreno]); thisAutoLane.NotifyAutoPointsChanged(); } } public class AutomationSectionRecordedUndoClass : UndoClass { public string UndoMainValue { get { return "Automation delete recorded: " + AutoPointsCount.ToString(); } } string UndoTrackID; int AutoLaneIndex = 0; int AutoPointsInsertedIdx = -1; int AutoPointsCount = 0; List RemovedPoints; public AutomationSectionRecordedUndoClass(string undoTrackID, int autolaneindex, int resetPtsIdx, int autopointsCount, List removedPoints) { UndoTrackID = undoTrackID; AutoLaneIndex = autolaneindex; AutoPointsInsertedIdx = resetPtsIdx; AutoPointsCount = autopointsCount; RemovedPoints = removedPoints; } public override void Undo() {//master track trackno: -1 AutomationLane thisAutoLane; if (UndoTrackID == "MASTERTRACK") thisAutoLane = editingProject.MasterTrack.AutomationLanes[AutoLaneIndex]; else thisAutoLane = GetTrackFromID(UndoTrackID).AutomationLanes[AutoLaneIndex]; for (int i = 0; i < AutoPointsCount; i++) thisAutoLane.autoPoints.RemoveAt(AutoPointsInsertedIdx); for (int i = RemovedPoints.Count - 1; i >= 0; i--) thisAutoLane.autoPoints.Insert(AutoPointsInsertedIdx, RemovedPoints[i]); thisAutoLane.NotifyAutoPointsChanged(); } }