/// <summary> /// Replaces the line in the track, grid, and renderer. /// Updates extensions /// Notifies the undo/timeline managers /// </summary> public void ReplaceLine(GameLine oldline, GameLine newline) { if (oldline.ID != newline.ID) { throw new Exception("can only replace lines with the same id"); } RegisterUndoAction(oldline, newline); var std = oldline as StandardLine; if (std != null) { SaveCells(oldline.Position, oldline.Position2); SaveCells(newline.Position, newline.Position2); if (_updateextensions) { RemoveExtensions(std); } var newstd = (StandardLine)newline; using (Track.Grid.Sync.AcquireWrite()) { // this could be a moveline, i think. Track.Grid.RemoveLine(std); Track.Grid.AddLine(newstd); } if (_updateextensions) { AddExtensions(newstd); } } _editorcells.RemoveLine(oldline); _editorcells.AddLine(newline); Track.LineLookup[newline.ID] = newline; if (oldline.Type != newline.Type) { _renderer.RemoveLine(oldline); _renderer.AddLine(newline); } else { _renderer.RedrawLine(newline); } }
/// <summary> /// Removes the line from the track, grid, and renderer. /// Updates extensions /// Notifies the undo/timeline managers /// </summary> public void RemoveLine(GameLine line) { if (line is StandardLine std) { SaveCells(line.Position, line.Position2); if (_updateextensions) { RemoveExtensions(std); } } RegisterUndoAction(line, null); Track.RemoveLine(line); _editorcells.RemoveLine(line); _renderer.RemoveLine(line); }