Example #1
0
        public void Add(string file, bool update_menu)
        {
            // Validate the filepath
            if (string.IsNullOrEmpty(file))
            {
                throw new Exception("Invalid recent file path");
            }

            // Move the item matching 'file' to the front of the list
            Filepaths.RemoveAll(x => string.Equals(x, file, StringComparison.CurrentCultureIgnoreCase));
            Filepaths.Insert(0, file);

            // Cap the maximum number of recent files
            for (; Filepaths.Count > MaxCount;)
            {
                Filepaths.RemoveAt(Filepaths.Count - 1);
            }

            // Update the menu
            if (update_menu)
            {
                UpdateMenu();
            }

            // Notify recent files changed
            RecentFilesListChanged?.Invoke(this, EventArgs.Empty);
        }
Example #2
0
        /// <summary>Reset the recent files list</summary>
        public void Clear()
        {
            Filepaths.Clear();
            UpdateMenu();

            // Notify recent files changed
            RecentFilesListChanged?.Invoke(this, EventArgs.Empty);
        }
Example #3
0
        /// <summary>Remove a filepath from the recent files list</summary>
        public void Remove(string file, bool update_menu)
        {
            Filepaths.RemoveAll(x => string.Equals(x, file, StringComparison.CurrentCultureIgnoreCase));

            if (update_menu)
            {
                UpdateMenu();
            }

            // Notify recent files changed
            RecentFilesListChanged?.Invoke(this, EventArgs.Empty);
        }