/// <summary> /// Adds a map to the recent files list. If it already exists, the map is relocated at /// the top of the list. /// </summary> /// <param name="newFile">The new filename to add to the list</param> /// <remarks></remarks> private void UpdateRecentFiles(string newFile) { Prefs.RecentFile rf = null; bool alreadyExists = false; foreach (Prefs.RecentFile recentMap in Prefs.RecentOpenedMaps) { if (newFile == recentMap.Path) { rf = recentMap; alreadyExists = true; break; } } if (alreadyExists) { menuFile.DropDownItems.Remove(rf.MenuItem); Prefs.RecentOpenedMaps.Remove(rf); } else { rf = new Prefs.RecentFile(); rf.Path = newFile; } Prefs.RecentOpenedMaps.Insert(0, rf); if (Prefs.RecentOpenedMaps.Count > Prefs.MaxRecentFiles) { menuFile.DropDownItems.Remove(Prefs.RecentOpenedMaps[Prefs.RecentOpenedMaps.Count - 1].MenuItem); Prefs.RecentOpenedMaps.RemoveAt(Prefs.RecentOpenedMaps.Count - 1); } this.AddRecentFilesToMenu(); Prefs.Save(); }