Skip to content

Commit

Permalink
Filecontent of textimportfile editable
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoCoderMatrix86 committed Jun 17, 2024
1 parent 97d27dc commit e87abed
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
26 changes: 15 additions & 11 deletions AudioCuesheetEditor/Model/IO/Import/TextImportfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@
using AudioCuesheetEditor.Model.IO.Audio;
using AudioCuesheetEditor.Model.Options;
using AudioCuesheetEditor.Model.Utility;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace AudioCuesheetEditor.Model.IO.Import
{
Expand All @@ -38,12 +32,14 @@ public class TextImportfile : IDisposable
private TextImportScheme textImportScheme;
private TimeSpanFormat? timeSpanFormat;
private bool disposedValue;
private IEnumerable<String?> fileContent;

public TextImportfile(MemoryStream fileContent, ImportOptions? importOptions = null)
public TextImportfile(MemoryStream fileContentStream, ImportOptions? importOptions = null)
{
textImportScheme = new TextImportScheme();
fileContent.Position = 0;
using var reader = new StreamReader(fileContent);
fileContent = [];
fileContentStream.Position = 0;
using var reader = new StreamReader(fileContentStream);
List<String?> lines = [];
while (reader.EndOfStream == false)
{
Expand All @@ -68,12 +64,20 @@ public TextImportfile(MemoryStream fileContent, ImportOptions? importOptions = n
/// <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 TextImportScheme TextImportScheme
{
Expand Down
2 changes: 1 addition & 1 deletion AudioCuesheetEditor/Pages/ImportFileView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ along with Foobar. If not, see

void FileContent_TextChanged(string text)
{
//TODO: Set the text to TextImportFile (or CuesheetImportFile) and Reanalyse
_importManager.FileContent = text;
}
}
14 changes: 13 additions & 1 deletion AudioCuesheetEditor/Services/IO/ImportManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ImportManager(SessionStateContainer sessionStateContainer)
_sessionStateContainer.ImportCuesheetChanged += SessionStateContainer_ImportCuesheetChanged;
}

public IReadOnlyCollection<String?>? FileContentRecognized
public IEnumerable<String?>? FileContentRecognized
{
get
{
Expand Down Expand Up @@ -60,6 +60,18 @@ public String? FileContent
}
return null;
}
set
{
var fileContentValue = value?.Split(Environment.NewLine);
if (fileContentValue != null)
{
if (_sessionStateContainer.TextImportFile != null)
{
_sessionStateContainer.TextImportFile.FileContent = fileContentValue;
}
//TODO: cuesheet!
}
}
}

public void Dispose()
Expand Down

0 comments on commit e87abed

Please sign in to comment.