From cd3b8d8cfc95e63f81ad84fb1765d2a8cea0191b Mon Sep 17 00:00:00 2001 From: deagahelio <16138291+deagahelio@users.noreply.github.com> Date: Thu, 15 Apr 2021 19:24:04 -0300 Subject: [PATCH] Display time relative to start of current index --- RedBookPlayer/Player.cs | 18 +++++++++++++++++- RedBookPlayer/PlayerView.xaml.cs | 16 +++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/RedBookPlayer/Player.cs b/RedBookPlayer/Player.cs index ee143f9..dee4b46 100644 --- a/RedBookPlayer/Player.cs +++ b/RedBookPlayer/Player.cs @@ -71,7 +71,22 @@ namespace RedBookPlayer } } } - public ushort CurrentIndex { get; private set; } = 1; + ushort currentIndex = 1; + public ushort CurrentIndex + { + get + { + return currentIndex; + } + + private set + { + currentIndex = value; + + Console.WriteLine("thing set"); + SectionStartSector = (ulong)Image.Tracks[CurrentTrack].Indexes[CurrentIndex]; + } + } private ulong currentSector = 0; private int currentSectorReadPosition = 0; public ulong CurrentSector @@ -116,6 +131,7 @@ namespace RedBookPlayer public bool ApplyDeEmphasis { get; private set; } = false; public bool CopyAllowed { get; private set; } = false; public TrackType? TrackType_ { get; private set; } + public ulong SectionStartSector { get; private set; } public int TotalTracks { get; private set; } = 0; public int TotalIndexes { get; private set; } = 0; public ulong TimeOffset { get; private set; } = 0; diff --git a/RedBookPlayer/PlayerView.xaml.cs b/RedBookPlayer/PlayerView.xaml.cs index 941e279..083c209 100644 --- a/RedBookPlayer/PlayerView.xaml.cs +++ b/RedBookPlayer/PlayerView.xaml.cs @@ -136,12 +136,22 @@ namespace RedBookPlayer { if (Player.Initialized) { + ulong sectorTime = Player.CurrentSector; + if (Player.SectionStartSector != 0) + { + sectorTime -= Player.SectionStartSector; + } + else + { + sectorTime += Player.TimeOffset; + } + int[] numbers = new int[]{ Player.CurrentTrack + 1, Player.CurrentIndex, - (int)((Player.CurrentSector + Player.TimeOffset) / (75 * 60)), - (int)(((Player.CurrentSector + Player.TimeOffset) / 75) % 60), - (int)((Player.CurrentSector + Player.TimeOffset) % 75), + (int)(sectorTime / (75 * 60)), + (int)((sectorTime / 75) % 60), + (int)(sectorTime % 75), Player.TotalTracks, Player.TotalIndexes, (int)(Player.TotalTime / (75 * 60)),