/// <summary> /// Adds the given background to the song's background list if it doesn't already exist (can be undone). /// </summary> /// <param name="bg">The background to add.</param> /// <param name="forceAdd">if set to <c>true</c> the background will be added even if it already exists.</param> /// <returns> /// The index of the new background. /// </returns> public int AddBackground(SongBackground bg, bool forceAdd = false) { bool contains = !forceAdd && Backgrounds.Contains(bg); Action redo = () => { if (!contains) { backgrounds.Add(bg); } }; Action undo = () => { if (!contains) { backgrounds.Remove(bg); } }; Undo.ChangeFactory.OnChanging(this, undo, redo, "AddBackground"); if (contains) { return(Backgrounds.IndexOf(bg)); } else { backgrounds.Add(bg); return(Backgrounds.Count - 1); } }