/// <summary> /// Adds a new item to the recents list in the appropriate position. /// </summary> /// <param name="newRecent"></param> /// <param name="isLoading"></param> public void AddRecent(string newRecent, bool isLoading) { if (isLoading) { RecentPaths.Add(newRecent); //in order } else { // Remove the new recent from the list if it exists - as we will re-insert it (at the front) RecentPaths.ReplaceAll(RecentPaths.Where(x => !x.Equals(newRecent, StringComparison.InvariantCultureIgnoreCase)).ToList()); RecentPaths.Insert(0, newRecent); //put at front } while (RecentPaths.Count > 10) { RecentPaths.RemoveAt(10); //Just remove trailing items } RecentsMenu.IsEnabled = true; //An item exists in the menu if (!isLoading) { RefreshRecentsMenu(); SaveRecentList(true); } }
internal void InsertInRecentFilesList(string filePath) { RecentPaths.RemoveAll(s => s == filePath); RecentPaths.Insert(0, filePath); ShrinkList(); SaveRecentFilesList(); }
public void RememberRecentPath(string path, DisplayMode mode) { if (RecentPaths == null) { RecentPaths = new List <WordPath>(); } // 如果之前已經有存過了,就先刪掉. RemoveFromRecentPaths(path); // 最新的加在開頭 RecentPaths.Insert(0, new WordPath() { Path = path, PathMode = mode }); //如果已經記錄超過了最大限制,就刪掉最後一個(最不常開的) if (RecentPaths.Count > MaxRememberPathCount) { RecentPaths.RemoveAt(MaxRememberPathCount); } }