Make volume setting safer

This commit is contained in:
Matt Nadareski
2021-07-01 11:50:38 -07:00
parent fe6b3523c3
commit abd81d255b
2 changed files with 20 additions and 11 deletions

View File

@@ -240,17 +240,9 @@ namespace RedBookPlayer.GUI
public void RewindButton_Click(object sender, RoutedEventArgs e) => Player.Rewind();
public void VolumeUpButton_Click(object sender, RoutedEventArgs e)
{
if(App.Settings.Volume < 100)
App.Settings.Volume++;
}
public void VolumeUpButton_Click(object sender, RoutedEventArgs e) => App.Settings.Volume++;
public void VolumeDownButton_Click(object sender, RoutedEventArgs e)
{
if(App.Settings.Volume > 0)
App.Settings.Volume--;
}
public void VolumeDownButton_Click(object sender, RoutedEventArgs e) => App.Settings.Volume--;
public void MuteToggleButton_Click(object sender, RoutedEventArgs e)
{

View File

@@ -38,7 +38,19 @@ namespace RedBookPlayer
/// <summary>
/// Indicates the default playback volume
/// </summary>
public int Volume { get; set; } = 100;
public int Volume
{
get => _volume;
set
{
if(value > 100)
_volume = 100;
else if(value < 0)
_volume = 0;
else
_volume = value;
}
}
/// <summary>
/// Indicates the currently selected theme
@@ -126,6 +138,11 @@ namespace RedBookPlayer
/// </summary>
private string _filePath;
/// <summary>
/// Internal value for the volume
/// </summary>
private int _volume = 100;
public Settings() {}
public Settings(string filePath) => _filePath = filePath;