diff --git a/AudioCuesheetEditor/Model/Options/ApplicationOptions.cs b/AudioCuesheetEditor/Model/Options/ApplicationOptions.cs index 79f88022..7449b09e 100644 --- a/AudioCuesheetEditor/Model/Options/ApplicationOptions.cs +++ b/AudioCuesheetEditor/Model/Options/ApplicationOptions.cs @@ -92,6 +92,8 @@ public String? ViewModename public Boolean LinkTracksWithPreviousOne { get; set; } = true; public String? ProjectFilename { get; set; } = Projectfile.DefaultFilename; public TimeSpanFormat? TimeSpanFormat { get; set; } + public Boolean TracksTableSelectionVisible { get; set; } = false; + public Boolean TracksTableHeaderPinned { get; set; } = false; protected override ValidationResult Validate(string property) { diff --git a/AudioCuesheetEditor/Shared/TrackList/TrackList.razor b/AudioCuesheetEditor/Shared/TrackList/TrackList.razor index 763a8d3b..2112939c 100644 --- a/AudioCuesheetEditor/Shared/TrackList/TrackList.razor +++ b/AudioCuesheetEditor/Shared/TrackList/TrackList.razor @@ -47,14 +47,14 @@ along with Foobar. If not, see AddButtonClicked="OnAddTrackClicked" EditSelectedTracksClicked="EditSelectedTracksClicked" DeleteSelectedTracksClicked="DeleteSelectedTracksClicked" - DeleteAllTracksClicked="OnDeleteAllTracksClicked" - FixedTableHeader="fixedTableHeader" - FixedTableHeaderChanged="(newValue) => fixedTableHeader = newValue" + DeleteAllTracksClicked="OnDeleteAllTracksClicked" + FixedTableHeader="PinnedTableHeader" + FixedTableHeaderChanged="(newValue) => PinnedTableHeader = newValue" TrackSelectionVisible="TrackSelectionVisible" TrackSelectionVisibleChanged="(newValue) => TrackSelectionVisible = newValue" /> } - +
@if ((_sessionStateContainer.CurrentViewMode == ViewMode.ViewModeFull) && (TrackSelectionVisible)) @@ -99,15 +99,13 @@ along with Foobar. If not, see @code { - //TODO: Save trackselectionvisible and fixedheader to applicationOptions ModalDialog? modalDialog; EditTrackModal? modalTrackEdit; List selectedTracks = new(); - Boolean trackSelectionVisible = false; Validations? validations; Boolean revalidate = false; List TracksAttachedToValidateablePropertyChanged = new(); - Boolean fixedTableHeader = false; + ApplicationOptions? applicationOptions; [Parameter] public AudioPlayer? AudioPlayer { get; set; } @@ -132,14 +130,37 @@ along with Foobar. If not, see public Boolean TrackSelectionVisible { - get => trackSelectionVisible; + get + { + if (applicationOptions != null) + { + return applicationOptions.TracksTableSelectionVisible; + } + return false; + } set { - trackSelectionVisible = value; + _localStorageOptionsProvider.SaveOptionsValue(x => x.TracksTableSelectionVisible, value); selectedTracks = new(); } } + public Boolean PinnedTableHeader + { + get + { + if (applicationOptions != null) + { + return applicationOptions.TracksTableHeaderPinned; + } + return false; + } + set + { + _localStorageOptionsProvider.SaveOptionsValue(x => x.TracksTableHeaderPinned, value); + } + } + public void Dispose() { _localizationService.LocalizationChanged -= LocalizationService_LocalizationChanged; @@ -147,13 +168,14 @@ along with Foobar. If not, see _sessionStateContainer.ImportCuesheetChanged -= SessionStateContainer_ImportCuesheetChanged; _sessionStateContainer.Cuesheet.TracksRemoved -= Cuesheet_TracksRemoved; _sessionStateContainer.Cuesheet.TracksAdded -= Cuesheet_TracksAdded; + _localStorageOptionsProvider.OptionSaved -= LocalStorageOptionsProvider_OptionsSaved; DetachTrackFromValidateablePropertyChanged(); DetachCuesheetFromSplitPointsAddedRemoved(); } - protected override void OnInitialized() + protected override async Task OnInitializedAsync() { - base.OnInitialized(); + await base.OnInitializedAsync(); _localizationService.LocalizationChanged += LocalizationService_LocalizationChanged; @@ -165,6 +187,9 @@ along with Foobar. If not, see AttachTracksToValidateablePropertyChanged(); AttachCuesheetToSplitPointsAddedRemoved(); + + applicationOptions = await _localStorageOptionsProvider.GetOptions(); + _localStorageOptionsProvider.OptionSaved += LocalStorageOptionsProvider_OptionsSaved; } protected override async Task OnAfterRenderAsync(bool firstRender) @@ -178,9 +203,8 @@ along with Foobar. If not, see } } - async Task OnAddTrackClicked() + void OnAddTrackClicked() { - var applicationOptions = await _localStorageOptionsProvider.GetOptions(); var newTrack = new Track(); Cuesheet?.AddTrack(newTrack, applicationOptions); _traceChangeManager.TraceChanges(newTrack); @@ -404,4 +428,13 @@ along with Foobar. If not, see break; } } + + void LocalStorageOptionsProvider_OptionsSaved(object? sender, IOptions options) + { + if (options is ApplicationOptions applicationOption) + { + applicationOptions = applicationOption; + StateHasChanged(); + } + } }