From e87abed4cc02b0c61720b738a9fab72dd9455c18 Mon Sep 17 00:00:00 2001 From: NeoCoderMatrix86 <40752681+NeoCoderMatrix86@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:34:57 +0200 Subject: [PATCH] Filecontent of textimportfile editable --- .../Model/IO/Import/TextImportfile.cs | 26 +++++++++++-------- .../Pages/ImportFileView.razor | 2 +- .../Services/IO/ImportManager.cs | 14 +++++++++- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/AudioCuesheetEditor/Model/IO/Import/TextImportfile.cs b/AudioCuesheetEditor/Model/IO/Import/TextImportfile.cs index 9cacc17f..f103295f 100644 --- a/AudioCuesheetEditor/Model/IO/Import/TextImportfile.cs +++ b/AudioCuesheetEditor/Model/IO/Import/TextImportfile.cs @@ -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 { @@ -38,12 +32,14 @@ public class TextImportfile : IDisposable private TextImportScheme textImportScheme; private TimeSpanFormat? timeSpanFormat; private bool disposedValue; + private IEnumerable 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 lines = []; while (reader.EndOfStream == false) { @@ -68,12 +64,20 @@ public TextImportfile(MemoryStream fileContent, ImportOptions? importOptions = n /// /// File content (each element is a file line) /// - public IReadOnlyCollection FileContent { get; private set; } + public IEnumerable FileContent + { + get => fileContent; + set + { + fileContent = value; + Analyse(); + } + } /// /// File content with marking which passages has been reconized by scheme /// - public IReadOnlyCollection? FileContentRecognized { get; private set; } + public IEnumerable? FileContentRecognized { get; private set; } public TextImportScheme TextImportScheme { diff --git a/AudioCuesheetEditor/Pages/ImportFileView.razor b/AudioCuesheetEditor/Pages/ImportFileView.razor index 60f7d8a7..c0ac3854 100644 --- a/AudioCuesheetEditor/Pages/ImportFileView.razor +++ b/AudioCuesheetEditor/Pages/ImportFileView.razor @@ -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; } } diff --git a/AudioCuesheetEditor/Services/IO/ImportManager.cs b/AudioCuesheetEditor/Services/IO/ImportManager.cs index 2caeac9e..be8e634b 100644 --- a/AudioCuesheetEditor/Services/IO/ImportManager.cs +++ b/AudioCuesheetEditor/Services/IO/ImportManager.cs @@ -30,7 +30,7 @@ public ImportManager(SessionStateContainer sessionStateContainer) _sessionStateContainer.ImportCuesheetChanged += SessionStateContainer_ImportCuesheetChanged; } - public IReadOnlyCollection? FileContentRecognized + public IEnumerable? FileContentRecognized { get { @@ -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()