Add currently-unused player update from UI

This commit is contained in:
Matt Nadareski
2021-07-03 14:18:04 -07:00
parent c714abc946
commit f2053d5a44
2 changed files with 26 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
@@ -120,6 +121,7 @@ namespace RedBookPlayer.GUI
private void InitializeComponent(string xaml)
{
DataContext = new PlayerViewModel();
(DataContext as PlayerViewModel).PropertyChanged += UpdateModel;
// Load the theme
try
@@ -189,6 +191,17 @@ namespace RedBookPlayer.GUI
};
}
/// <summary>
/// Update the Player with the most recent information from the UI
/// </summary>
private void UpdateModel(object sender, PropertyChangedEventArgs e)
{
Dispatcher.UIThread.InvokeAsync(() =>
{
Player.UpdateModel(DataContext as PlayerViewModel);
});
}
/// <summary>
/// Update the UI with the most recent information from the Player
/// </summary>

View File

@@ -294,6 +294,19 @@ namespace RedBookPlayer.Hardware
}
}
/// <summary>
/// Update the internal values from the frontend
/// </summary>
/// <param name="dataContext">Data context to update from</param>
public void UpdateModel(PlayerViewModel dataContext)
{
if(!Initialized || dataContext == null)
return;
App.Settings.Volume = dataContext.Volume;
ToggleDeEmphasis(dataContext.ApplyDeEmphasis);
}
/// <summary>
/// Get current sector time, accounting for offsets
/// </summary>