From c0c5216d95d174ce30c99937d1fad42e3d9a0aa4 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 3 Feb 2010 17:26:03 +0000 Subject: [PATCH] added control over maxitems --- PROMS/Volian.Controls.Library/MostRecentItem.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/PROMS/Volian.Controls.Library/MostRecentItem.cs b/PROMS/Volian.Controls.Library/MostRecentItem.cs index b99f982e..624e6b01 100644 --- a/PROMS/Volian.Controls.Library/MostRecentItem.cs +++ b/PROMS/Volian.Controls.Library/MostRecentItem.cs @@ -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]);