Skip to content

Commit

Permalink
Merge pull request #363 from NeoCoderMatrix86/development
Browse files Browse the repository at this point in the history
Deploy v5.0
  • Loading branch information
NeoCoderMatrix86 authored Jun 4, 2024
2 parents fe83c2d + bfd6c45 commit a524cd8
Show file tree
Hide file tree
Showing 70 changed files with 973 additions and 1,307 deletions.
28 changes: 0 additions & 28 deletions .github/workflows/generateChangelog.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/run_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:
- uses: actions/[email protected]

# sets up .NET
# version can be found here https://dotnet.microsoft.com/en-us/download/dotnet/7.0
# version can be found here https://dotnet.microsoft.com/en-us/download/dotnet/8.0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7.0.101'
dotnet-version: '8.0.203'

- name: Install wasm-tools
run: dotnet workload install wasm-tools-net7
run: dotnet workload install wasm-tools

# Only publish when unit tests are ok
- name: Run Unit Tests
Expand Down
35 changes: 18 additions & 17 deletions AudioCuesheetEditor/AudioCuesheetEditor.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<PackageProjectUrl>https://github.com/NeoCoderMatrix86/AudioCuesheetEditor</PackageProjectUrl>
<RazorLangVersion>3.0</RazorLangVersion>
<Version>4.0.0</Version>
<Version>5.0.0</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<PublishTrimmed>true</PublishTrimmed>
<RunAOTCompilation>true</RunAOTCompilation>
</PropertyGroup>
Expand All @@ -21,8 +22,8 @@
<Content Remove="Resources\Localization\CatalogueNumber\en.json" />
<Content Remove="Resources\Localization\CuesheetData\de.json" />
<Content Remove="Resources\Localization\CuesheetData\en.json" />
<Content Remove="Resources\Localization\EditSplitpoints\de.json" />
<Content Remove="Resources\Localization\EditSplitpoints\en.json" />
<Content Remove="Resources\Localization\EditSections\de.json" />
<Content Remove="Resources\Localization\EditSections\en.json" />
<Content Remove="Resources\Localization\EditTrackModal\de.json" />
<Content Remove="Resources\Localization\EditTrackModal\en.json" />
<Content Remove="Resources\Localization\MainLayout\de.json" />
Expand Down Expand Up @@ -60,8 +61,8 @@
<EmbeddedResource Include="Resources\Localization\CatalogueNumber\de.json" />
<EmbeddedResource Include="Resources\Localization\CuesheetData\de.json" />
<EmbeddedResource Include="Resources\Localization\CuesheetData\en.json" />
<EmbeddedResource Include="Resources\Localization\EditSplitpoints\de.json" />
<EmbeddedResource Include="Resources\Localization\EditSplitpoints\en.json" />
<EmbeddedResource Include="Resources\Localization\EditSections\de.json" />
<EmbeddedResource Include="Resources\Localization\EditSections\en.json" />
<EmbeddedResource Include="Resources\Localization\EditTrackModal\de.json" />
<EmbeddedResource Include="Resources\Localization\EditTrackModal\en.json" />
<EmbeddedResource Include="Resources\Localization\MainLayout\en.json" />
Expand Down Expand Up @@ -96,19 +97,19 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Blazorise.Bootstrap5" Version="1.1.5" />
<PackageReference Include="MetaBrainz.MusicBrainz" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.1" PrivateAssets="all" />
<PackageReference Include="Blazorise.Bootstrap5" Version="1.5.2" />
<PackageReference Include="MetaBrainz.MusicBrainz" Version="6.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.4" PrivateAssets="all" />
<PackageReference Include="BlazorDownloadFile" Version="2.4.0.2" />
<PackageReference Include="Blazorise.Components" Version="1.1.5" />
<PackageReference Include="Blazorise.Components" Version="1.5.2" />
<PackageReference Include="Howler.Blazor" Version="0.9.8" />
<PackageReference Include="Markdig" Version="0.30.4" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="7.0.0" />
<PackageReference Include="System.Net.Http.Json" Version="7.0.0" />
<PackageReference Include="Toolbelt.Blazor.HotKeys2" Version="1.0.0" />
<PackageReference Include="z440.atl.core" Version="4.17.0" />
<PackageReference Include="Markdig" Version="0.37.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0" />
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
<PackageReference Include="Toolbelt.Blazor.HotKeys2" Version="4.1.0.1" />
<PackageReference Include="z440.atl.core" Version="5.22.0" />
</ItemGroup>

</Project>
119 changes: 44 additions & 75 deletions AudioCuesheetEditor/Model/AudioCuesheet/Cuesheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,72 +29,54 @@ public enum MoveDirection
Down
}

public class TrackAddRemoveEventArgs : EventArgs
public class TrackAddRemoveEventArgs(Track track) : EventArgs
{
public TrackAddRemoveEventArgs(Track track)
{
Track = track;
}

public Track Track { get; }
public Track Track { get; } = track;
}

public class SplitPointAddRemoveEventArgs : EventArgs
public class CuesheetSectionAddRemoveEventArgs(CuesheetSection section) : EventArgs
{
public SplitPointAddRemoveEventArgs(SplitPoint splitPoint)
{
SplitPoint = splitPoint;
}

public SplitPoint SplitPoint { get; }
public CuesheetSection Section { get; } = section;
}

public class Cuesheet : Validateable<Cuesheet>, ICuesheetEntity, ITraceable
public class Cuesheet(TraceChangeManager? traceChangeManager = null) : Validateable<Cuesheet>, ICuesheetEntity, ITraceable
{
public const String MimeType = "text/*";
public const String FileExtension = ".cue";

private readonly object syncLock = new();

private List<Track> tracks;
private List<Track> tracks = [];
private String? artist;
private String? title;
private Audiofile? audiofile;
private CDTextfile? cDTextfile;
private Cataloguenumber catalogueNumber;
private Cataloguenumber catalogueNumber = new();
private DateTime? recordingStart;
private readonly List<KeyValuePair<String, Track>> currentlyHandlingLinkedTrackPropertyChange = new();
private List<SplitPoint> splitPoints;
private readonly List<KeyValuePair<String, Track>> currentlyHandlingLinkedTrackPropertyChange = [];
private List<CuesheetSection> sections = [];

public event EventHandler? AudioFileChanged;
public event EventHandler<TraceablePropertiesChangedEventArgs>? TraceablePropertyChanged;
public event EventHandler<TrackAddRemoveEventArgs>? TrackAdded;
public event EventHandler<TrackAddRemoveEventArgs>? TrackRemoved;
public event EventHandler<SplitPointAddRemoveEventArgs>? SplitPointAdded;
public event EventHandler<SplitPointAddRemoveEventArgs>? SplitPointRemoved;
public event EventHandler<CuesheetSectionAddRemoveEventArgs>? SectionAdded;
public event EventHandler<CuesheetSectionAddRemoveEventArgs>? SectionRemoved;
public event EventHandler? CuesheetImported;

public Cuesheet(TraceChangeManager? traceChangeManager = null)
{
tracks = new();
catalogueNumber = new();
splitPoints = new();
TraceChangeManager = traceChangeManager;
}

[JsonInclude]
public IReadOnlyCollection<Track> Tracks
{
get { return tracks.AsReadOnly(); }
private set
get => tracks.AsReadOnly();
private set
{
foreach (var track in tracks)
{
track.RankPropertyValueChanged -= Track_RankPropertyValueChanged;
track.IsLinkedToPreviousTrackChanged -= Track_IsLinkedToPreviousTrackChanged;
track.Cuesheet = null;
}
tracks = value.ToList();
tracks = [.. value];
foreach (var track in tracks)
{
track.Cuesheet = this;
Expand All @@ -103,7 +85,7 @@ private set
}
}
}

public String? Artist
{
get => artist;
Expand Down Expand Up @@ -197,46 +179,45 @@ public TimeSpan? RecordingTime
public Boolean IsImporting { get; private set; }

[JsonInclude]
public IReadOnlyCollection<SplitPoint> SplitPoints
public IReadOnlyCollection<CuesheetSection> Sections
{
get => splitPoints;
get => sections;
private set
{
foreach(var splitpoint in value.Where(x => x.Cuesheet != this))
foreach(var section in value.Where(x => x.Cuesheet != this))
{
splitpoint.Cuesheet = this;
section.Cuesheet = this;
}
splitPoints = value.ToList();
sections = [.. value];
}
}

[JsonIgnore]
public TraceChangeManager? TraceChangeManager { get; }
public TraceChangeManager? TraceChangeManager { get; } = traceChangeManager;

public SplitPoint AddSplitPoint()
public CuesheetSection AddSection()
{
var previousValue = new List<SplitPoint>(splitPoints);
var splitPoint = new SplitPoint(this);
splitPoints.Add(splitPoint);
SplitPointAdded?.Invoke(this, new SplitPointAddRemoveEventArgs(splitPoint));
OnTraceablePropertyChanged(previousValue, nameof(SplitPoints));
return splitPoint;
var previousValue = new List<CuesheetSection>(sections);
var section = new CuesheetSection(this);
sections.Add(section);
SectionAdded?.Invoke(this, new CuesheetSectionAddRemoveEventArgs(section));
OnTraceablePropertyChanged(previousValue, nameof(Sections));
return section;
}

public void RemoveSplitPoint(SplitPoint splitPoint)
public void RemoveSection(CuesheetSection section)
{
var previousValue = new List<SplitPoint>(splitPoints);
if (splitPoints.Remove(splitPoint))
var previousValue = new List<CuesheetSection>(sections);
if (sections.Remove(section))
{
OnTraceablePropertyChanged(previousValue, nameof(SplitPoints));
SplitPointRemoved?.Invoke(this, new SplitPointAddRemoveEventArgs(splitPoint));
OnTraceablePropertyChanged(previousValue, nameof(Sections));
SectionRemoved?.Invoke(this, new CuesheetSectionAddRemoveEventArgs(section));
}
}

public SplitPoint? GetSplitPointAtTrack(Track track)
public CuesheetSection? GetSectionAtTrack(Track track)
{
SplitPoint? splitPointAtTrack = SplitPoints?.FirstOrDefault(x => track.Begin < x.Moment && track.End >= x.Moment);
return splitPointAtTrack;
return Sections?.FirstOrDefault(x => track.Begin < x.Begin && track.End >= x.Begin);
}

/// <summary>
Expand All @@ -247,10 +228,6 @@ public void RemoveSplitPoint(SplitPoint splitPoint)
public Track? GetPreviousLinkedTrack(Track track)
{
Track? previousLinkedTrack = null;
if (track == null)
{
throw new ArgumentNullException(nameof(track));
}
if (track.IsLinkedToPreviousTrack)
{
var index = tracks.IndexOf(track);
Expand Down Expand Up @@ -462,7 +439,7 @@ protected override ValidationResult Validate(string property)
validationStatus = ValidationStatus.Success;
if (Tracks.Count <= 0)
{
validationMessages ??= new();
validationMessages ??= [];
validationMessages.Add(new ValidationMessage("{0} has invalid Count ({1})!", nameof(Tracks), 0));
}
else
Expand All @@ -473,7 +450,7 @@ protected override ValidationResult Validate(string property)
.Where(grp => grp.Count() > 1);
if (tracksWithSamePosition.Any())
{
validationMessages ??= new();
validationMessages ??= [];
foreach (var track in tracksWithSamePosition)
{
foreach (var trackWithSamePosition in track)
Expand All @@ -489,7 +466,7 @@ protected override ValidationResult Validate(string property)
&& (x.Equals(track) == false));
if (tracksBetween.Any())
{
validationMessages ??= new();
validationMessages ??= [];
foreach (var trackBetween in tracksBetween)
{
validationMessages.Add(new ValidationMessage("{0}({1},{2},{3},{4},{5}) is overlapping with {0}({6},{7},{8},{9},{10}). Please make shure the timeinterval is only used once!", nameof(Track), track.Position != null ? track.Position : String.Empty, track.Artist ?? String.Empty, track.Title ?? String.Empty, track.Begin != null ? track.Begin : String.Empty, track.End != null ? track.End : String.Empty, trackBetween.Position != null ? trackBetween.Position : String.Empty, trackBetween.Artist ?? String.Empty, trackBetween.Title ?? String.Empty, trackBetween.Begin != null ? trackBetween.Begin : String.Empty, trackBetween.End != null ? trackBetween.End : String.Empty));
Expand All @@ -502,23 +479,23 @@ protected override ValidationResult Validate(string property)
validationStatus = ValidationStatus.Success;
if (Audiofile == null)
{
validationMessages ??= new();
validationMessages ??= [];
validationMessages.Add(new ValidationMessage("{0} has no value!", nameof(Audiofile)));
}
break;
case nameof(Artist):
validationStatus = ValidationStatus.Success;
if (String.IsNullOrEmpty(Artist))
{
validationMessages ??= new();
validationMessages ??= [];
validationMessages.Add(new ValidationMessage("{0} has no value!", nameof(Artist)));
}
break;
case nameof(Title):
validationStatus = ValidationStatus.Success;
if (String.IsNullOrEmpty(Title))
{
validationMessages ??= new();
validationMessages ??= [];
validationMessages.Add(new ValidationMessage("{0} has no value!", nameof(Title)));
}
break;
Expand Down Expand Up @@ -594,10 +571,10 @@ private void CopyValues(Cuesheet cuesheet, ApplicationOptions applicationOptions
var track = new Track(importTrack, false);
AddTrack(track, applicationOptions);
}
// Copy splitpoints
foreach (var splitPoint in cuesheet.SplitPoints)
// Copy sections
foreach (var splitPoint in cuesheet.Sections)
{
var newSplitPoint = AddSplitPoint();
var newSplitPoint = AddSection();
newSplitPoint.CopyValues(splitPoint);
}
}
Expand Down Expand Up @@ -701,14 +678,6 @@ private void Audiofile_ContentStreamLoaded(object? sender, EventArgs e)

private void SwitchTracks(Track track1, Track track2)
{
if (track1 == null)
{
throw new ArgumentNullException(nameof(track1));
}
if (track2 == null)
{
throw new ArgumentNullException(nameof(track2));
}
var indexTrack1 = tracks.IndexOf(track1);
var indexTrack2 = tracks.IndexOf(track2);
//Switch track positions in array
Expand Down
Loading

0 comments on commit a524cd8

Please sign in to comment.