mirror of
https://github.com/aaru-dps/RedBookPlayer.git
synced 2025-12-16 19:24:41 +00:00
Make volume setting safer
This commit is contained in:
@@ -240,17 +240,9 @@ namespace RedBookPlayer.GUI
|
|||||||
|
|
||||||
public void RewindButton_Click(object sender, RoutedEventArgs e) => Player.Rewind();
|
public void RewindButton_Click(object sender, RoutedEventArgs e) => Player.Rewind();
|
||||||
|
|
||||||
public void VolumeUpButton_Click(object sender, RoutedEventArgs e)
|
public void VolumeUpButton_Click(object sender, RoutedEventArgs e) => App.Settings.Volume++;
|
||||||
{
|
|
||||||
if(App.Settings.Volume < 100)
|
|
||||||
App.Settings.Volume++;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void VolumeDownButton_Click(object sender, RoutedEventArgs e)
|
public void VolumeDownButton_Click(object sender, RoutedEventArgs e) => App.Settings.Volume--;
|
||||||
{
|
|
||||||
if(App.Settings.Volume > 0)
|
|
||||||
App.Settings.Volume--;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MuteToggleButton_Click(object sender, RoutedEventArgs e)
|
public void MuteToggleButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,7 +38,19 @@ namespace RedBookPlayer
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates the default playback volume
|
/// Indicates the default playback volume
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
/// Indicates the currently selected theme
|
/// Indicates the currently selected theme
|
||||||
@@ -126,6 +138,11 @@ namespace RedBookPlayer
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private string _filePath;
|
private string _filePath;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Internal value for the volume
|
||||||
|
/// </summary>
|
||||||
|
private int _volume = 100;
|
||||||
|
|
||||||
public Settings() {}
|
public Settings() {}
|
||||||
|
|
||||||
public Settings(string filePath) => _filePath = filePath;
|
public Settings(string filePath) => _filePath = filePath;
|
||||||
|
|||||||
Reference in New Issue
Block a user