mirror of
https://github.com/aaru-dps/RedBookPlayer.git
synced 2025-12-16 19:24:41 +00:00
Move methods to better locations
This commit is contained in:
@@ -31,7 +31,11 @@ namespace RedBookPlayer.Discs
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the sector starting the section
|
/// Represents the sector starting the section
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ulong SectionStartSector { get; protected set; }
|
public ulong SectionStartSector
|
||||||
|
{
|
||||||
|
get => _sectionStartSector;
|
||||||
|
protected set => this.RaiseAndSetIfChanged(ref _sectionStartSector, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of bytes per sector for the current track
|
/// Number of bytes per sector for the current track
|
||||||
@@ -68,6 +72,8 @@ namespace RedBookPlayer.Discs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ulong TotalTime { get; protected set; } = 0;
|
public ulong TotalTime { get; protected set; } = 0;
|
||||||
|
|
||||||
|
private ulong _sectionStartSector;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Protected State Variables
|
#region Protected State Variables
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using System.ComponentModel;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Timers;
|
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
@@ -25,9 +24,6 @@ namespace RedBookPlayer.GUI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set of images representing the digits for the UI
|
/// Set of images representing the digits for the UI
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
|
||||||
/// TODO: Does it make sense to have this as an array?
|
|
||||||
/// </remarks>
|
|
||||||
private Image[] _digits;
|
private Image[] _digits;
|
||||||
|
|
||||||
public PlayerView() => InitializeComponent(null);
|
public PlayerView() => InitializeComponent(null);
|
||||||
@@ -167,7 +163,7 @@ namespace RedBookPlayer.GUI
|
|||||||
{
|
{
|
||||||
Dispatcher.UIThread.InvokeAsync(() =>
|
Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
string digitString = PlayerViewModel.GenerateDigitString();
|
string digitString = GenerateDigitString();
|
||||||
for(int i = 0; i < _digits.Length; i++)
|
for(int i = 0; i < _digits.Length; i++)
|
||||||
{
|
{
|
||||||
if(_digits[i] != null)
|
if(_digits[i] != null)
|
||||||
@@ -176,6 +172,54 @@ namespace RedBookPlayer.GUI
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generate the digit string to be interpreted by the frontend
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>String representing the digits for the frontend</returns>
|
||||||
|
private string GenerateDigitString()
|
||||||
|
{
|
||||||
|
// If the disc isn't initialized, return all '-' characters
|
||||||
|
if(PlayerViewModel?.Initialized != true)
|
||||||
|
return string.Empty.PadLeft(20, '-');
|
||||||
|
|
||||||
|
// Otherwise, take the current time into account
|
||||||
|
ulong sectorTime = GetCurrentSectorTime();
|
||||||
|
|
||||||
|
int[] numbers = new int[]
|
||||||
|
{
|
||||||
|
PlayerViewModel.CurrentTrackNumber + 1,
|
||||||
|
PlayerViewModel.CurrentTrackIndex,
|
||||||
|
|
||||||
|
(int)(sectorTime / (75 * 60)),
|
||||||
|
(int)(sectorTime / 75 % 60),
|
||||||
|
(int)(sectorTime % 75),
|
||||||
|
|
||||||
|
PlayerViewModel.TotalTracks,
|
||||||
|
PlayerViewModel.TotalIndexes,
|
||||||
|
|
||||||
|
(int)(PlayerViewModel.TotalTime / (75 * 60)),
|
||||||
|
(int)(PlayerViewModel.TotalTime / 75 % 60),
|
||||||
|
(int)(PlayerViewModel.TotalTime % 75),
|
||||||
|
};
|
||||||
|
|
||||||
|
return string.Join("", numbers.Select(i => i.ToString().PadLeft(2, '0').Substring(0, 2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get current sector time, accounting for offsets
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>ulong representing the current sector time</returns>
|
||||||
|
private ulong GetCurrentSectorTime()
|
||||||
|
{
|
||||||
|
ulong sectorTime = PlayerViewModel.CurrentSector;
|
||||||
|
if(PlayerViewModel.SectionStartSector != 0)
|
||||||
|
sectorTime -= PlayerViewModel.SectionStartSector;
|
||||||
|
else
|
||||||
|
sectorTime += PlayerViewModel.TimeOffset;
|
||||||
|
|
||||||
|
return sectorTime;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Event Handlers
|
#region Event Handlers
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using RedBookPlayer.Hardware;
|
using RedBookPlayer.Hardware;
|
||||||
|
|
||||||
@@ -48,6 +47,15 @@ namespace RedBookPlayer.GUI
|
|||||||
private set => this.RaiseAndSetIfChanged(ref _currentSector, value);
|
private set => this.RaiseAndSetIfChanged(ref _currentSector, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the sector starting the section
|
||||||
|
/// </summary>
|
||||||
|
public ulong SectionStartSector
|
||||||
|
{
|
||||||
|
get => _sectionStartSector;
|
||||||
|
protected set => this.RaiseAndSetIfChanged(ref _sectionStartSector, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents if the disc has a hidden track
|
/// Represents if the disc has a hidden track
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -121,6 +129,7 @@ namespace RedBookPlayer.GUI
|
|||||||
private int _currentTrackNumber;
|
private int _currentTrackNumber;
|
||||||
private ushort _currentTrackIndex;
|
private ushort _currentTrackIndex;
|
||||||
private ulong _currentSector;
|
private ulong _currentSector;
|
||||||
|
private ulong _sectionStartSector;
|
||||||
|
|
||||||
private bool _hasHiddenTrack;
|
private bool _hasHiddenTrack;
|
||||||
private bool _quadChannel;
|
private bool _quadChannel;
|
||||||
@@ -245,42 +254,6 @@ namespace RedBookPlayer.GUI
|
|||||||
|
|
||||||
#region Helpers
|
#region Helpers
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Generate the digit string to be interpreted by the frontend
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>String representing the digits for the frontend</returns>
|
|
||||||
/// <remarks>
|
|
||||||
/// TODO: The model shouldn't care about this
|
|
||||||
/// </remarks>
|
|
||||||
public string GenerateDigitString()
|
|
||||||
{
|
|
||||||
// If the disc isn't initialized, return all '-' characters
|
|
||||||
if(_player?.Initialized != true)
|
|
||||||
return string.Empty.PadLeft(20, '-');
|
|
||||||
|
|
||||||
// Otherwise, take the current time into account
|
|
||||||
ulong sectorTime = _player.GetCurrentSectorTime();
|
|
||||||
|
|
||||||
int[] numbers = new int[]
|
|
||||||
{
|
|
||||||
_player.CurrentTrackNumber + 1,
|
|
||||||
_player.CurrentTrackIndex,
|
|
||||||
|
|
||||||
(int)(sectorTime / (75 * 60)),
|
|
||||||
(int)(sectorTime / 75 % 60),
|
|
||||||
(int)(sectorTime % 75),
|
|
||||||
|
|
||||||
_player.TotalTracks,
|
|
||||||
_player.TotalIndexes,
|
|
||||||
|
|
||||||
(int)(_player.TotalTime / (75 * 60)),
|
|
||||||
(int)(_player.TotalTime / 75 % 60),
|
|
||||||
(int)(_player.TotalTime % 75),
|
|
||||||
};
|
|
||||||
|
|
||||||
return string.Join("", numbers.Select(i => i.ToString().PadLeft(2, '0').Substring(0, 2)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set de-emphasis status
|
/// Set de-emphasis status
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -42,6 +42,15 @@ namespace RedBookPlayer.Hardware
|
|||||||
private set => this.RaiseAndSetIfChanged(ref _currentSector, value);
|
private set => this.RaiseAndSetIfChanged(ref _currentSector, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the sector starting the section
|
||||||
|
/// </summary>
|
||||||
|
public ulong SectionStartSector
|
||||||
|
{
|
||||||
|
get => _sectionStartSector;
|
||||||
|
protected set => this.RaiseAndSetIfChanged(ref _sectionStartSector, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents if the disc has a hidden track
|
/// Represents if the disc has a hidden track
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -115,6 +124,7 @@ namespace RedBookPlayer.Hardware
|
|||||||
private int _currentTrackNumber;
|
private int _currentTrackNumber;
|
||||||
private ushort _currentTrackIndex;
|
private ushort _currentTrackIndex;
|
||||||
private ulong _currentSector;
|
private ulong _currentSector;
|
||||||
|
private ulong _sectionStartSector;
|
||||||
|
|
||||||
private bool _hasHiddenTrack;
|
private bool _hasHiddenTrack;
|
||||||
private bool _quadChannel;
|
private bool _quadChannel;
|
||||||
@@ -371,21 +381,6 @@ namespace RedBookPlayer.Hardware
|
|||||||
|
|
||||||
#region Helpers
|
#region Helpers
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get current sector time, accounting for offsets
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>ulong representing the current sector time</returns>
|
|
||||||
public ulong GetCurrentSectorTime()
|
|
||||||
{
|
|
||||||
ulong sectorTime = _opticalDisc.CurrentSector;
|
|
||||||
if (_opticalDisc.SectionStartSector != 0)
|
|
||||||
sectorTime -= _opticalDisc.SectionStartSector;
|
|
||||||
else
|
|
||||||
sectorTime += _opticalDisc.TimeOffset;
|
|
||||||
|
|
||||||
return sectorTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set de-emphasis status
|
/// Set de-emphasis status
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -415,6 +410,7 @@ namespace RedBookPlayer.Hardware
|
|||||||
CurrentTrackNumber = _opticalDisc.CurrentTrackNumber;
|
CurrentTrackNumber = _opticalDisc.CurrentTrackNumber;
|
||||||
CurrentTrackIndex = _opticalDisc.CurrentTrackIndex;
|
CurrentTrackIndex = _opticalDisc.CurrentTrackIndex;
|
||||||
CurrentSector = _opticalDisc.CurrentSector;
|
CurrentSector = _opticalDisc.CurrentSector;
|
||||||
|
SectionStartSector = _opticalDisc.SectionStartSector;
|
||||||
|
|
||||||
HiddenTrack = TimeOffset > 150;
|
HiddenTrack = TimeOffset > 150;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user