public void Add(RecentFile recentFile) { var filenameEntry = _items.Find(x => x.FileInfo.FullName.Equals(recentFile.FileInfo.FullName)); if (filenameEntry != null) _items.Remove(filenameEntry); if (_items.Count == _maxItems) _items.Remove(_items.Last()); _items.Insert(0, recentFile); }
public void Add(RecentFile recentFile) { var filenameEntry = _items.Find(x => x.FileInfo.FullName.Equals(recentFile.FileInfo.FullName)); if (filenameEntry != null) { _items.Remove(filenameEntry); } if (_items.Count == _maxItems) { _items.Remove(_items.Last()); } _items.Insert(0, recentFile); }
public void Load() { _items.Clear(); using (var cmd = new SQLiteCommand(string.Format("SELECT * FROM {0} ORDER BY id DESC", TabsterDatabaseHelper.TableRecentFiles), _databaseHelper.GetConnection())) { using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { var filename = reader["filename"].ToString(); var file = _fileProcessor.Load(filename); if (file != null) { var r = new RecentFile(file, new FileInfo(filename)); _items.Add(r); } } } } }