예제 #1
0
        /// <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);
            }
        }
예제 #2
0
        /// <summary>
        /// 從最近記錄檔中刪除指定的路徑(通常用於檔案或路徑已經不存在時)
        /// </summary>
        /// <param name="path"></param>
        public void RemoveFromRecentPaths(string path)
        {
            if (RecentPaths == null || !RecentPaths.Any())
            {
                return;
            }

            int pos = RecentPaths.FindIndex(x => x.Path == path);

            if (pos >= 0)
            {
                RecentPaths.RemoveAt(pos);
            }
        }
예제 #3
0
        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);
            }
        }