public void StartUndoGroup() { if (undoGroup != null) { Log.Error("undoGroup already started"); EndUndoGroup(); } undoGroup = new UCommandGroup(); Log.Information("undoGroup started"); }
public void EndUndoGroup() { if (undoGroup == null) { Log.Error("No active undoGroup to end."); return; } if (undoGroup.Commands.Count > 0) { undoQueue.AddToBack(undoGroup); redoQueue.Clear(); } while (undoQueue.Count > Util.Preferences.Default.UndoLimit) { undoQueue.RemoveFromFront(); } undoGroup = null; Log.Information("undoGroup ended"); }
public void ExecuteCmd(UCommand cmd, bool quiet = false) { if (cmd is UNotification) { if (cmd is SaveProjectNotification) { var _cmd = cmd as SaveProjectNotification; if (undoQueue.Count > 0) savedPoint = undoQueue.Last(); if (_cmd.Path == "") OpenUtau.Core.Formats.USTx.Save(Project.FilePath, Project); else OpenUtau.Core.Formats.USTx.Save(_cmd.Path, Project); } else if (cmd is LoadProjectNotification) { undoQueue.Clear(); redoQueue.Clear(); undoGroup = null; savedPoint = null; this._project = ((LoadProjectNotification)cmd).project; this.playPosTick = 0; } else if (cmd is SetPlayPosTickNotification) { var _cmd = cmd as SetPlayPosTickNotification; this.playPosTick = _cmd.playPosTick; } Publish(cmd); if (!quiet) System.Diagnostics.Debug.WriteLine("Publish notification " + cmd.ToString()); return; } else if (undoGroup == null) { System.Diagnostics.Debug.WriteLine("Null undoGroup"); return; } else { undoGroup.Commands.Add(cmd); cmd.Execute(); Publish(cmd); } if (!quiet) System.Diagnostics.Debug.WriteLine("ExecuteCmd " + cmd.ToString()); }
public void ExecuteCmd(UCommand cmd) { if (cmd is UNotification) { if (cmd is SaveProjectNotification) { var _cmd = cmd as SaveProjectNotification; if (undoQueue.Count > 0) { savedPoint = undoQueue.Last(); } if (string.IsNullOrEmpty(_cmd.Path)) { Formats.Ustx.Save(Project.FilePath, Project); } else { Formats.Ustx.Save(_cmd.Path, Project); } } else if (cmd is LoadProjectNotification notification) { undoQueue.Clear(); redoQueue.Clear(); undoGroup = null; savedPoint = null; Project = notification.project; playPosTick = 0; } else if (cmd is SetPlayPosTickNotification) { var _cmd = cmd as SetPlayPosTickNotification; playPosTick = _cmd.playPosTick; } else if (cmd is SingersChangedNotification) { SearchAllSingers(); } Publish(cmd); if (!cmd.Silent) { Log.Information($"Publish notification {cmd}"); } return; } if (undoGroup == null) { Log.Error($"No active UndoGroup {cmd}"); return; } undoGroup.Commands.Add(cmd); lock (Project) { cmd.Execute(); } if (!cmd.Silent) { Log.Information($"ExecuteCmd {cmd}"); } Publish(cmd); Project.Validate(); }
public void EndUndoGroup() { if (undoGroup != null && undoGroup.Commands.Count > 0) { undoQueue.AddToBack(undoGroup); redoQueue.Clear(); } if (undoQueue.Count > Core.Util.Preferences.Default.UndoLimit) undoQueue.RemoveFromFront(); undoGroup = null; System.Diagnostics.Debug.WriteLine("undoGroup ended"); }
public void StartUndoGroup() { if (undoGroup != null) { System.Diagnostics.Debug.WriteLine("undoGroup already started"); EndUndoGroup(); } undoGroup = new UCommandGroup(); System.Diagnostics.Debug.WriteLine("undoGroup started"); }