コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public static void WriteBool(string key, bool value)
 {
     AppSettingsConnector.AddUpdateAppSettings(key, value);
 }
コード例 #4
0
 public static void WriteDouble(string key, double value)
 {
     AppSettingsConnector.AddUpdateAppSettings(key, value);
 }
コード例 #5
0
 public static void WriteInt(string key, int value)
 {
     AppSettingsConnector.AddUpdateAppSettings(key, value);
 }
コード例 #6
0
 public static void WriteString(string key, string value)
 {
     AppSettingsConnector.AddUpdateAppSettings(key, value);
 }