added control over maxitems

This commit is contained in:
John Jenko 2010-02-03 17:26:03 +00:00
parent 9712646a16
commit c0c5216d95

View File

@ -37,7 +37,8 @@ namespace Volian.Controls.Library
// Insert it in the first place in the list
Insert(0, myMRI);
// If more than MaxItems exist remove the items beyond MaxItems
while (Count > MaxItems) RemoveAt(MaxItems);
if (MaxItems > 0)
while (Count > MaxItems) RemoveAt(MaxItems);
myMRI.MyItemInfo.BeforeDelete += new ItemInfoEvent(MyItemInfo_BeforeDelete);
return myMRI;
}
@ -88,8 +89,14 @@ namespace Volian.Controls.Library
return null;
}
public static MostRecentItemList GetMRILst(System.Collections.Specialized.StringCollection list)
{
return GetMRILst(list, 10);
}
public static MostRecentItemList GetMRILst(System.Collections.Specialized.StringCollection list, int maxItems)
{
MostRecentItemList mril = new MostRecentItemList();
mril.MaxItems = maxItems;
if (list != null)
for (int i = list.Count - 1; i >= 0;i-- )// Add in reverse order so first is last and last is first
mril.Add(list[i]);