private void LoadItems() { foreach (var item in _rawItems) { item.OnBrowserClosed(); } _rawItems.Clear(); using (var db = new Database()) { var table = db.SelectDataTable("select * from img where location_id = @location_id", "@location_id", _loc.RowId); foreach (DataRow row in table.Rows) { var item = new LBItem(this, ImageRec.FromDataRow(row), _loc, _items.Count); _rawItems.Add(item); } } lock (_thumbnailLock) { _items = _rawItems.ToList(); ApplySort(); _itemLayoutUpdateRequired = true; RenumberItems(); RefreshStatusCounts(); UpdateScroll(); SetSelection(-1, -1); Invalidate(); } Global.FileDeleted += Global_FileDeleted; }
public LBItem(LocationBrowser lb, ImageRec img, Location loc, int index) { if (lb == null) { throw new ArgumentNullException(nameof(lb)); } if (img == null) { throw new ArgumentNullException(nameof(img)); } if (loc == null) { throw new ArgumentNullException(nameof(loc)); } if (index < 0) { throw new ArgumentOutOfRangeException(nameof(index)); } _lb = lb; _img = img; _index = index; _relativeLocation = img.Location; if (_relativeLocation.StartsWith(loc.Path, StringComparison.OrdinalIgnoreCase)) { var remove = loc.Path.Length; if (remove < _relativeLocation.Length && _relativeLocation[remove] == '\\') { remove++; } _relativeLocation = _relativeLocation.Substring(remove); } _img.RatingUpdated += Image_RatingUpdated; }
public void OnBrowserClosed() { _img.RatingUpdated -= Image_RatingUpdated; _img = null; }