Skip to content

Commit

Permalink
Made cuesheet import editable
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoCoderMatrix86 committed Jun 17, 2024
1 parent e87abed commit 966a3a1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
42 changes: 32 additions & 10 deletions AudioCuesheetEditor/Model/IO/Import/CuesheetImportfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,48 @@ namespace AudioCuesheetEditor.Model.IO.Import
{
public class CuesheetImportfile
{
private IEnumerable<String?> fileContent;

/// <summary>
/// File content (each element is a file line)
/// </summary>
public IReadOnlyCollection<String?>? FileContent { get; private set; }
public IEnumerable<String?> FileContent
{
get => fileContent;
set
{
fileContent = value;
Analyse();
}
}

/// <summary>
/// File content with marking which passages has been reconized by scheme
/// </summary>
public IReadOnlyCollection<String?>? FileContentRecognized { get; private set; }
public IEnumerable<String?>? FileContentRecognized { get; private set; }
public Exception? AnalyseException { get; private set; }
public Cuesheet? Cuesheet { get; private set; }
public ApplicationOptions ApplicationOptions { get; private set; }

public CuesheetImportfile(MemoryStream fileContentStream, ApplicationOptions applicationOptions)
{
fileContentStream.Position = 0;
using var reader = new StreamReader(fileContentStream);
List<String?> lines = [];
while (reader.EndOfStream == false)
{
lines.Add(reader.ReadLine());
}
fileContent = lines.AsReadOnly();
ApplicationOptions = applicationOptions;
Analyse();
}

public CuesheetImportfile(MemoryStream fileContent, ApplicationOptions applicationOptions)
private void Analyse()
{
try
{
Cuesheet = new Cuesheet();
fileContent.Position = 0;
using var reader = new StreamReader(fileContent);
var cuesheetArtistGroupName = "CuesheetArtist";
var cuesheetTitleGroupName = "CuesheetTitle";
var cuesheetFileNameGroupName = "CuesheetFileName";
Expand All @@ -67,9 +90,8 @@ public CuesheetImportfile(MemoryStream fileContent, ApplicationOptions applicati
Track? track = null;
List<String?> lines = [];
List<String?>? recognizedLines = [];
while (reader.EndOfStream == false)
foreach (var line in FileContent)
{
var line = reader.ReadLine();
lines.Add(line);
String? recognizedLine = line;
if (String.IsNullOrEmpty(line) == false)
Expand Down Expand Up @@ -256,7 +278,7 @@ public CuesheetImportfile(MemoryStream fileContent, ApplicationOptions applicati
}
if (track != null)
{
Cuesheet.AddTrack(track, applicationOptions);
Cuesheet.AddTrack(track, ApplicationOptions);
}
else
{
Expand Down Expand Up @@ -290,10 +312,10 @@ public CuesheetImportfile(MemoryStream fileContent, ApplicationOptions applicati
}
recognizedLines.Add(recognizedLine);
}
FileContent = lines.AsReadOnly();
fileContent = lines.AsReadOnly();
FileContentRecognized = recognizedLines.AsReadOnly();
}
catch(Exception ex)
catch (Exception ex)
{
AnalyseException = ex;
Cuesheet = null;
Expand Down
3 changes: 3 additions & 0 deletions AudioCuesheetEditor/Pages/ImportFileView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ along with Foobar. If not, see

@code {
//TODO: FileContent height
//TODO: Enable input of tabs
//TODO: Changing a cuesheet doesn't work (the filecontent is not reanalysed)
String selectedTab = "recognizedFilecontent";

public void Dispose()
Expand Down
5 changes: 4 additions & 1 deletion AudioCuesheetEditor/Services/IO/ImportManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ public String? FileContent
{
_sessionStateContainer.TextImportFile.FileContent = fileContentValue;
}
//TODO: cuesheet!
if (_sessionStateContainer.CuesheetImportFile != null)
{
_sessionStateContainer.CuesheetImportFile.FileContent = fileContentValue;
}
}
}
}
Expand Down

0 comments on commit 966a3a1

Please sign in to comment.