public void AddMostRecentlyUsedFile(string filePath) { if (!File.Exists(filePath) || this.MostRecentlyUsedFiles.Any(mruItem => mruItem.FullName.Equals(filePath, StringComparison.OrdinalIgnoreCase))) { return; } this.LastUsedFilePath = filePath; if (this.MostRecentlyUsedFiles.Count >= this.MostRecentlyUsedCount) { this.MostRecentlyUsedFiles.RemoveAt(0); } this.MostRecentlyUsedFiles.Add(new MostRecentlyUsedFileItem(new FileInfo(filePath))); string mruListString = string.Join(SettingsResources.MostRecentlyUsedStringSeparator, this.MostRecentlyUsedFiles.Select(mruItem => mruItem.FullName)); AppSettingsConnector.WriteString(SettingsResources.MostRecentlyUsed, mruListString); }
public MruManager() { if (!(AppSettingsConnector.TryReadString(SettingsResources.MaxRecentlyUsedCount, out string mruCount) && int.TryParse(mruCount, out this.mostRecentlyUsedCount))) { this.mostRecentlyUsedCount = 1; } if (!(AppSettingsConnector.TryReadString(SettingsResources.LastRecentUsedFile, out string filePath) && File.Exists(filePath))) { this.LastUsedFilePath = string.Empty; } IEnumerable <MostRecentlyUsedFileItem> mru = new List <MostRecentlyUsedFileItem>(); if (AppSettingsConnector.TryReadString(SettingsResources.MostRecentlyUsed, out string fileList)) { mru = fileList.Split(new[] { SettingsResources.MostRecentlyUsedStringSeparator }, StringSplitOptions.RemoveEmptyEntries) .Where(File.Exists) .Select(validPath => new MostRecentlyUsedFileItem(new FileInfo(validPath))); } this.MostRecentlyUsedFiles = new ObservableCollection <MostRecentlyUsedFileItem>(mru); }
public static void WriteBool(string key, bool value) { AppSettingsConnector.AddUpdateAppSettings(key, value); }
public static void WriteDouble(string key, double value) { AppSettingsConnector.AddUpdateAppSettings(key, value); }
public static void WriteInt(string key, int value) { AppSettingsConnector.AddUpdateAppSettings(key, value); }
public static void WriteString(string key, string value) { AppSettingsConnector.AddUpdateAppSettings(key, value); }