WHATCH THE VIDEO:
http://youtu.be/LgWPce6FAUU
Hi,
this is my example the scenario:
I have 200 tracks in now playing and 50000 in the main track window.
The tracks in now playing are the recently added and I have to check them one per one if are ok with the other tracks in the main track window.
The problem was... when I use the Player.Next() the now playing window change the focus on the new track, but the main tracks window will remain focused on the old track untill I scroll to the new track or I use F5 (or refresh()) functionality.
I know that MainTracksWindow.Focused is what I need, in fact if I pass the correct Index to this property the main tracks Windows will focus to the right track.
THe problem now is: MainTracksWindow.Focused want a Index of AllVisibleSongList, that can have 10000+ of tracks. I can't find a way to have the index in a simple way, now I'm fetching all the AllVisibleSongList IDs and put them in an dictionary, and cache it for get fast the index of the Player.CurrentSong.ID in the Main track window. For fetch all the song it can take from 30sec to over ten minutes (!!!).
what is the right way for getting that index for use MainTracksWindow.Focused ?
Code: Select all
private IDictionary<int,int> _cachedIds;
private void btnNext_Click(object sender, EventArgs e)
{
using (var mm = new Biz.MM())
{
mm.App.Player.Next();
if (_cachedIds == null || mm.App.AllVisibleSongList.Count != _cachedIds.Count())
{
var count = mm.App.AllVisibleSongList.Count;
_cachedIds = new Dictionary<int, int>();
for (int i = 0; i < count; i++)
{
_cachedIds[i] = mm.App.AllVisibleSongList.get_Item(i).ID; //[color=#FF0000]THIS IS VERY SLOW[/color]
lblProgress.Text = string.Format("{0}/{1}", i, count);
}
lblProgress.Text = "";
}
var currentId = mm.App.Player.CurrentSong.ID;
var index = _cachedIds.Single(k => k.Value == currentId).Key;
mm.App.MainTracksWindow.Focused = index;
}
}