diff --git a/AudioCuesheetEditor/Extensions/SessionStateContainer.cs b/AudioCuesheetEditor/Extensions/SessionStateContainer.cs index 179031cc..c5985c2f 100644 --- a/AudioCuesheetEditor/Extensions/SessionStateContainer.cs +++ b/AudioCuesheetEditor/Extensions/SessionStateContainer.cs @@ -141,8 +141,7 @@ public void StartImportCuesheet(ApplicationOptions applicationOptions) { if (ImportCuesheet != null) { - //TODO - //Cuesheet.Import(ImportCuesheet, applicationOptions, _traceChangeManager); + Cuesheet.Import(ImportCuesheet, applicationOptions, _traceChangeManager); ImportCuesheet = null; } ResetImport(); diff --git a/AudioCuesheetEditor/Model/AudioCuesheet/Cuesheet.cs b/AudioCuesheetEditor/Model/AudioCuesheet/Cuesheet.cs index 652e2cc2..59507b4f 100644 --- a/AudioCuesheetEditor/Model/AudioCuesheet/Cuesheet.cs +++ b/AudioCuesheetEditor/Model/AudioCuesheet/Cuesheet.cs @@ -394,7 +394,7 @@ public void MoveTrack(Track track, MoveDirection moveDirection) } } - public void Import(ImportCuesheet cuesheet, ApplicationOptions applicationOptions, TraceChangeManager? traceChangeManager = null) + public void Import(ICuesheet cuesheet, ApplicationOptions applicationOptions, TraceChangeManager? traceChangeManager = null) { //Since we use a stack for several changes we need to lock execution for everything else lock (syncLock) @@ -560,7 +560,7 @@ private void ReCalculateTrackProperties(Track trackToCalculate) /// /// Reference to import cuesheet /// Reference to application options - private void CopyValues(ImportCuesheet cuesheet, ApplicationOptions applicationOptions) + private void CopyValues(ICuesheet cuesheet, ApplicationOptions applicationOptions) { Artist = cuesheet.Artist; Title = cuesheet.Title; @@ -568,19 +568,34 @@ private void CopyValues(ImportCuesheet cuesheet, ApplicationOptions applicationO //Audiofile = cuesheet.Audiofile; //CDTextfile = cuesheet.CDTextfile; //Cataloguenumber = cuesheet.Cataloguenumber; - foreach (var importTrack in cuesheet.Tracks) + IEnumerable? tracks = null; + if (cuesheet is Cuesheet originCuesheet) { - //We don't want to copy the cuesheet reference since we are doing a copy and want to assign the track to this object - var track = new Track(importTrack, false); - AddTrack(track, applicationOptions); + tracks = originCuesheet.tracks; + // Copy sections + foreach (var section in originCuesheet.Sections) + { + var newSplitPoint = AddSection(); + newSplitPoint.CopyValues(section); + } + } + if (cuesheet is ImportCuesheet importCuesheet) + { + tracks = importCuesheet.Tracks; + } + if (tracks != null) + { + foreach (var importTrack in tracks) + { + //We don't want to copy the cuesheet reference since we are doing a copy and want to assign the track to this object + var track = new Track(importTrack, false); + AddTrack(track, applicationOptions); + } + } + else + { + throw new NullReferenceException(); } - //TODO - //// Copy sections - //foreach (var splitPoint in cuesheet.Sections) - //{ - // var newSplitPoint = AddSection(); - // newSplitPoint.CopyValues(splitPoint); - //} } private void Track_RankPropertyValueChanged(object? sender, string e) diff --git a/AudioCuesheetEditor/Model/AudioCuesheet/ICuesheet.cs b/AudioCuesheetEditor/Model/AudioCuesheet/ICuesheet.cs index 90d2adbf..dcdfa2f1 100644 --- a/AudioCuesheetEditor/Model/AudioCuesheet/ICuesheet.cs +++ b/AudioCuesheetEditor/Model/AudioCuesheet/ICuesheet.cs @@ -20,7 +20,7 @@ namespace AudioCuesheetEditor.Model.AudioCuesheet { public interface ICuesheet { - public String? Artist { get; set; } - public String? Title { get; set; } + string? Artist { get; set; } + string? Title { get; set; } } } diff --git a/AudioCuesheetEditor/Model/AudioCuesheet/Import/ImportCuesheet.cs b/AudioCuesheetEditor/Model/AudioCuesheet/Import/ImportCuesheet.cs index 001caa58..a22f3125 100644 --- a/AudioCuesheetEditor/Model/AudioCuesheet/Import/ImportCuesheet.cs +++ b/AudioCuesheetEditor/Model/AudioCuesheet/Import/ImportCuesheet.cs @@ -14,6 +14,7 @@ //along with Foobar. If not, see //. + namespace AudioCuesheetEditor.Model.AudioCuesheet.Import { public class ImportCuesheet : ICuesheet @@ -23,6 +24,7 @@ public class ImportCuesheet : ICuesheet //TODO Audiofile //TODO CDTextfile public string? Cataloguenumber { get; set; } - public ICollection Tracks { get; set; } = []; + + public ICollection Tracks { get; } = []; } } diff --git a/AudioCuesheetEditor/Model/AudioCuesheet/Track.cs b/AudioCuesheetEditor/Model/AudioCuesheet/Track.cs index 7cf70bc2..0484c67f 100644 --- a/AudioCuesheetEditor/Model/AudioCuesheet/Track.cs +++ b/AudioCuesheetEditor/Model/AudioCuesheet/Track.cs @@ -13,7 +13,6 @@ //You should have received a copy of the GNU General Public License //along with Foobar. If not, see //. -using AudioCuesheetEditor.Model.AudioCuesheet.Import; using AudioCuesheetEditor.Model.Entity; using AudioCuesheetEditor.Model.UI; using System.Text.Json.Serialization; @@ -55,19 +54,18 @@ public class Track : Validateable, ICuesheetEntity, ITraceable, ITrack /// public event EventHandler? TraceablePropertyChanged; + public Track() { } + /// /// Create object with copied values from input /// /// Object to copy values from /// /// Copy cuesheet reference from track also? - public Track(ITrack track, Boolean copyCuesheetReference = true) + public Track(ITrack track, Boolean copyCuesheetReference = true) : this() { CopyValues(track, copyCuesheetReference); } - public Track() - { - - } + public uint? Position { get => position;