private void UpdateFileItems()
{
// Presume we don't need these buttons
searchbuttonplaced = false;
searchbutton.Visible = false;
for(int i = 0; i < numbuttons; i++)
{
filebuttons[i].Text = "";
filebuttons[i].Visible = false;
}
// Determine if we are in the library root
bool inrootpath = (currentpath.Length == General.Settings.LibraryRoot.Length) && !searchresults;
// If we're in the library root, we want to use the large buttons! yay
if(inrootpath)
{
filebuttons[0] = largebutton0;
filebuttons[1] = largebutton1;
filebuttons[2] = largebutton2;
filebuttons[3] = largebutton3;
filebuttons[4] = largebutton4;
filebuttons[5] = largebutton5;
filebuttons[6] = largebutton6;
filebuttons[7] = largebutton7;
filebuttons[8] = largebutton8;
}
else
{
filebuttons[0] = filebutton0;
filebuttons[1] = filebutton1;
filebuttons[2] = filebutton2;
filebuttons[3] = filebutton3;
filebuttons[4] = filebutton4;
filebuttons[5] = filebutton5;
filebuttons[6] = filebutton6;
filebuttons[7] = filebutton7;
filebuttons[8] = filebutton8;
}
// Update buttons
int itemindex = listoffset;
for(int i = 0; i < numbuttons; i++)
{
if(itemindex < allitems.TotalCount)
{
DirectoryEntry de = allitems[itemindex];
filebuttons[i].Text = de.filetitle;
filebuttons[i].Tag = itemindex;
filebuttons[i].Clickable = true;
if(de.isdirectory)
filebuttons[i].ColorText = ColorIndex.InfoLight;
else
filebuttons[i].ColorText = ColorIndex.WindowText;
if(!itemselected[itemindex])
filebuttons[i].StopInfoFlash();
else
filebuttons[i].StartInfoFlash();
filebuttons[i].SetupColors(General.Colors);
filebuttons[i].Visible = true;
// In search results, we show the directory parts in the buttons next to the results
if(searchresults)
{
// Figure out path parts
string pathfromroot = de.path.Substring(General.Settings.LibraryRoot.Length);
pathfromroot.Trim(Path.DirectorySeparatorChar);
string[] pathparts;
string pathinfo = "";
if(pathfromroot.Length > 0)
pathparts = pathfromroot.Split(Path.DirectorySeparatorChar);
else
pathparts = new string[0];
// Make path info description
foreach(string pp in pathparts)
{
if(pathinfo.Length > 0)
pathinfo = pp + " - " + pathinfo;
else
pathinfo = pp;
}
int detailsindex = i + SINGLE_COL_NUM_BUTTONS;
filebuttons[detailsindex].Clickable = false;
filebuttons[detailsindex].ColorText = ColorIndex.ControlColor3;
filebuttons[detailsindex].Text = pathinfo;
filebuttons[detailsindex].Tag = -1;
filebuttons[detailsindex].SetupColors(General.Colors);
filebuttons[detailsindex].Visible = true;
}
}
else
{
filebuttons[i].Text = "";
filebuttons[i].Visible = false;
// If we're in the library root, we always want the search button shown on the first next unused place
if(inrootpath && !searchbuttonplaced)
{
searchbutton.Text = "Search";
searchbutton.StopInfoFlash();
searchbutton.ColorText = ColorIndex.WindowText;
searchbutton.SetupColors(General.Colors);
searchbutton.Location = filebuttons[i].Location;
searchbutton.Visible = true;
searchbuttonplaced = true;
}
}
itemindex++;
}
}