Skip to content

Commit

Permalink
save UI settings
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoCoderMatrix86 committed Dec 16, 2024
1 parent ea5d893 commit 9e5f8c8
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 13 deletions.
2 changes: 2 additions & 0 deletions AudioCuesheetEditor/Model/Options/ApplicationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
59 changes: 46 additions & 13 deletions AudioCuesheetEditor/Shared/TrackList/TrackList.razor
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
}

<Table Bordered Resizable ResizeMode="TableResizeMode.Columns" Narrow FixedHeader="fixedTableHeader" FixedHeaderTableHeight="" FixedHeaderTableMaxHeight="70vh">
<Table Bordered Resizable ResizeMode="TableResizeMode.Columns" Narrow FixedHeader="PinnedTableHeader" FixedHeaderTableHeight="" FixedHeaderTableMaxHeight="70vh">
<TableHeader ThemeContrast="ThemeContrast.Light">
<TableRow>
@if ((_sessionStateContainer.CurrentViewMode == ViewMode.ViewModeFull) && (TrackSelectionVisible))
Expand Down Expand Up @@ -99,15 +99,13 @@ along with Foobar. If not, see
<EditTrackModal @ref="modalTrackEdit" SaveClicked="() => StateHasChanged()" />

@code {
//TODO: Save trackselectionvisible and fixedheader to applicationOptions
ModalDialog? modalDialog;
EditTrackModal? modalTrackEdit;
List<Track> selectedTracks = new();
Boolean trackSelectionVisible = false;
Validations? validations;
Boolean revalidate = false;
List<Track> TracksAttachedToValidateablePropertyChanged = new();
Boolean fixedTableHeader = false;
ApplicationOptions? applicationOptions;

[Parameter]
public AudioPlayer? AudioPlayer { get; set; }
Expand All @@ -132,28 +130,52 @@ 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<ApplicationOptions>(x => x.TracksTableSelectionVisible, value);
selectedTracks = new();
}
}

public Boolean PinnedTableHeader
{
get
{
if (applicationOptions != null)
{
return applicationOptions.TracksTableHeaderPinned;
}
return false;
}
set
{
_localStorageOptionsProvider.SaveOptionsValue<ApplicationOptions>(x => x.TracksTableHeaderPinned, value);
}
}

public void Dispose()
{
_localizationService.LocalizationChanged -= LocalizationService_LocalizationChanged;
_sessionStateContainer.CuesheetChanged -= SessionStateContainer_CuesheetChanged;
_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;

Expand All @@ -165,6 +187,9 @@ along with Foobar. If not, see

AttachTracksToValidateablePropertyChanged();
AttachCuesheetToSplitPointsAddedRemoved();

applicationOptions = await _localStorageOptionsProvider.GetOptions<ApplicationOptions>();
_localStorageOptionsProvider.OptionSaved += LocalStorageOptionsProvider_OptionsSaved;
}

protected override async Task OnAfterRenderAsync(bool firstRender)
Expand All @@ -178,9 +203,8 @@ along with Foobar. If not, see
}
}

async Task OnAddTrackClicked()
void OnAddTrackClicked()
{
var applicationOptions = await _localStorageOptionsProvider.GetOptions<ApplicationOptions>();
var newTrack = new Track();
Cuesheet?.AddTrack(newTrack, applicationOptions);
_traceChangeManager.TraceChanges(newTrack);
Expand Down Expand Up @@ -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();
}
}
}

0 comments on commit 9e5f8c8

Please sign in to comment.