コード例 #1
0
        private void SaveInternalMruListToSettingsFile()
        {
            string mruListString = string.Join(
                MruManager.MostRecentlyUsedKeyStringSeparator,
                this.InternalMostRecentlyUsedFiles.Select(mruItem => mruItem.FullName));

            AppSettingsConnector.WriteString(MruManager.MostRecentlyUsedKey, mruListString);
        }
コード例 #2
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public MruManager()
        {
            if (!(AppSettingsConnector.TryReadString(MruManager.MaxRecentlyUsedCountKey, out string mruCount) &&
                  int.TryParse(mruCount, out this.maxMostRecentlyUsedCount)))
            {
                this.maxMostRecentlyUsedCount = 10;
            }

            IEnumerable <MostRecentlyUsedFileItem> mru = new List <MostRecentlyUsedFileItem>();

            if (AppSettingsConnector.TryReadString(MruManager.MostRecentlyUsedKey, out string fileList))
            {
                mru = fileList.Split(
                    new[] { MruManager.MostRecentlyUsedKeyStringSeparator },
                    StringSplitOptions.RemoveEmptyEntries)
                      .Where(File.Exists)
                      .Select(validPath => new MostRecentlyUsedFileItem(new FileInfo(validPath)));
            }

            this.InternalMostRecentlyUsedFiles = new ObservableCollection <MostRecentlyUsedFileItem>(mru);
            this.MostRecentlyUsedFiles         = new ReadOnlyObservableCollection <MostRecentlyUsedFileItem>(this.InternalMostRecentlyUsedFiles);
            AddMostRecentlyUsedFile(this.InternalMostRecentlyUsedFiles.LastOrDefault()?.FullName ?? string.Empty);
        }
コード例 #3
0
 /// <summary>
 /// Writes a <see cref="int"/> value to the settings file which is stored using the specified lookup <paramref name="key"/>. If the <paramref name="key"/> already exists, the existing value will be overwritten.
 /// </summary>
 /// <param name="key">The lookup key for the <paramref name="value"/>.</param>
 /// <param name="value">The settings value to save to the file.</param>
 public static void WriteInt(string key, int value)
 {
     AppSettingsConnector.AddUpdateAppSettings(key, value);
 }
コード例 #4
0
 /// <summary>
 /// Writes a <see cref="string"/> value to the settings file which is stored using the specified lookup <paramref name="key"/>. If the <paramref name="key"/> already exists, the existing value will be overwritten.
 /// </summary>
 /// <param name="key">The lookup key for the <paramref name="value"/>.</param>
 /// <param name="value">The settings value to save to the file.</param>
 public static void WriteString(string key, string value)
 {
     AppSettingsConnector.AddUpdateAppSettings(key, value);
 }
コード例 #5
0
 /// <summary>
 /// Writes a <see cref="bool"/> value to the settings file which is stored using the specified lookup <paramref name="key"/>. If the <paramref name="key"/> already exists, the existing value will be overwritten.
 /// </summary>
 /// <param name="key">The lookup key for the <paramref name="value"/>.</param>
 /// <param name="value">The settings value to save to the file.</param>
 public static void WriteBool(string key, bool value)
 {
     AppSettingsConnector.AddUpdateAppSettings(key, value);
 }
コード例 #6
0
 /// <summary>
 /// Writes a <see cref="double"/> value to the settings file which is stored using the specified lookup <paramref name="key"/>. If the <paramref name="key"/> already exists, the existing value will be overwritten.
 /// </summary>
 /// <param name="key">The lookup key for the <paramref name="value"/>.</param>
 /// <param name="value">The settings value to save to the file.</param>
 public static void WriteDouble(string key, double value)
 {
     AppSettingsConnector.AddUpdateAppSettings(key, value);
 }