Esempio n. 1
0
        /// <summary>
        /// Adds the given <paramref name="filename"/> to the recently used <see cref="StringCollection"/>.
        /// </summary>
        /// <param name="filename">The full path of the file to add.</param>
        public static void AddFile(string filename)
        {
            if (!string.IsNullOrEmpty(filename) && File.Exists(filename))
            {
                if (Settings.Default.MruManagerFiles == null)
                {
                    Settings.Default.MruManagerFiles = new StringCollection();
                }

                if (!Settings.Default.MruManagerFiles.Contains(filename))
                {
                    while (Settings.Default.MruManagerFiles.Count > MAX_MRU_FILE_COUNT)
                    {
                        // Ensure the maximum count of MRU file is not exceeded.
                        Settings.Default.MruManagerFiles.RemoveAt(Settings.Default.MruManagerFiles.Count - 1);
                    }

                    Settings.Default.MruManagerFiles.Add(filename);
                    Settings.Default.SaveSettings();
                }
                else
                {
                    // The file already exists. Move it to the last position.
                    Settings.Default.MruManagerFiles.Remove(filename);
                    Settings.Default.MruManagerFiles.Add(filename);
                    Settings.Default.SaveSettings();
                }

                MruListChanged?.Invoke(null, EventArgs.Empty);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Removes all recently used files from the <see cref="StringCollection"/>.
        /// </summary>
        public static void ClearFiles()
        {
            if (Settings.Default.MruManagerFiles == null)
            {
                return;
            }

            Settings.Default.MruManagerFiles.Clear();
            Settings.Default.SaveSettings();

            MruListChanged?.Invoke(null, EventArgs.Empty);
        }
Esempio n. 3
0
        /// <summary>
        /// Removes the given <paramref name="filename"/> from the <see cref="StringCollection"/>.
        /// </summary>
        /// <param name="filename">The full path of the file to remove.</param>
        public static void RemoveFile(string filename)
        {
            if (string.IsNullOrEmpty(filename) || Settings.Default.MruManagerFiles == null)
            {
                return;
            }

            if (Settings.Default.MruManagerFiles.Contains(filename))
            {
                Settings.Default.MruManagerFiles.Remove(filename);
                Settings.Default.SaveSettings();
            }

            MruListChanged?.Invoke(null, EventArgs.Empty);
        }