private void events_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { // new cache is a subset of current cache if (cache != null && cacheStart <= e.StartIndex && cacheStart + cache.Count > e.EndIndex) { return; } cache = new List <ListViewItem>(logger.GetEventRange(e.StartIndex + 1, e.EndIndex + 1 - e.StartIndex).Select(ev => createItem(ev))); cacheStart = e.StartIndex; }
public void TestCacheVirtualItemsEventArgs() { int start = 7; int end = 26; CacheVirtualItemsEventArgs e = new CacheVirtualItemsEventArgs(start, end); Assert.AreEqual(start, e.StartIndex, "A1"); Assert.AreEqual(end, e.EndIndex, "A2"); }
private void listView2_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { if (_needRebuild2) { _cache2.Clear(); foreach (var item in _listItems2) { _cache2.Add(new ListViewItem(item.Text)); } _needRebuild2 = false; } }
private void listView2_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { //if (_needRebuild) { _cache2.Clear(); foreach (var item in _listItems2) { _cache2.Add(new ListViewItem(item.Name + " [" + item.TypeDesc + "]")); } //_needRebuild = false; } }
private void listView1_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { if (_needRebuild) { _cache.Clear(); foreach (var item in _listItems) { _cache.Add(new ListViewItem(item.AssemblyName)); } _needRebuild = false; } }
private void listViewThreads_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { for (int i = e.StartIndex; i <= e.EndIndex; i++) { ListViewItem item = virtualListViewItems[i]; if (item == null) { item = filteredBBSThreads[i].CreateListViewItem(); virtualListViewItems[i] = item; } } }
public void CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { //logger.Info("CacheViertualItems({0}, {1})", e.StartIndex, e.EndIndex); /* * int Count = e.EndIndex - e.StartIndex + 1; * TableCacheStartIndex = e.StartIndex; * TableCache = new ListViewItem[Count]; * if (m_Getter != null) * for (int i = 0; i < Count; i++) * TableCache[i] = m_Getter.GetListViewItemAt(TableCacheStartIndex + i); */ }
/// <summary> /// This function computes a width for each column /// so that both, the column title and the column values, /// are entirely displayed. /// </summary> protected virtual void assignDefaultColumnWidth() { // Read the first objects int endIndex = objectsCacheValue.CountEstimated; // Make ListViewItem objects for the first objects CacheVirtualItemsEventArgs e = new CacheVirtualItemsEventArgs(0, endIndex); OnCacheVirtualItems(e); // Any items?... if (itemCache != null) { // ... compute column widths // Array of column width int[] columnWidths = new int[Columns.Count]; // Initialize the array of column widths by the column title width. for (int i = 0; i < Columns.Count; i++) { columnWidths[i] = TextRenderer.MeasureText(Columns[i].Text, Font).Width; } // Loop over the cached items ... foreach (ListViewItem lv in itemCache) { // item might be null for the last item if (lv != null) { // compute text widths of the values for each column for (int i = 0; i < Columns.Count; i++) { String s = lv.SubItems[i].Text; int n = TextRenderer.MeasureText(s, Font).Width; columnWidths[i] = Math.Max(n, columnWidths[i]); } } } // Assign column widths for (int i = 0; i < Columns.Count; i++) { int offs = (i == 0) ? 22 : 10; if (Columns[i].Width != 0) // if visible { Columns[i].Width = columnWidths[i] + offs; } } } }
private void lvFiles_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { if (_cache.Length > 0) { int length = e.EndIndex - e.StartIndex + 1; for (int i = e.StartIndex; i < length; i++) { if (_cache[i] == null) { _cache[i] = _CreateListViewItem(GetResultItem(i)); } } } }
protected override void OnCacheVirtualItems(CacheVirtualItemsEventArgs e) { if (this.itemCache != null && e.StartIndex >= this.cacheOffset && e.EndIndex < this.cacheOffset + (int)this.itemCache.Length) { return; } int endIndex = e.EndIndex - e.StartIndex + 1; ListViewItem[] listViewItemArray = new ListViewItem[endIndex]; for (int i = 0; i < endIndex; i++) { listViewItemArray[i] = this.RetrieveVirtualItem(i + e.StartIndex); } this.itemCache = listViewItemArray; this.cacheOffset = e.StartIndex; }
private void ListCacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { int startIndex = e.StartIndex; if (_cache.ContainsKey(startIndex) && _cache.ContainsKey(e.EndIndex)) { return; } for (int i = 0; i < (e.EndIndex - startIndex + 1); ++i) { if (!_cache.ContainsKey(startIndex + i)) { _cache.Add((startIndex + i), Item(startIndex + i)); } } }
private void Browser_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { if (m_ListItemCache != null && e.StartIndex >= m_FirstItem && e.EndIndex <= m_FirstItem + m_ListItemCache.Length) { return; } m_FirstItem = e.StartIndex; int end = e.EndIndex; m_ListItemCache = new ListViewItem[end - m_FirstItem + 1]; int index = 0; for (int i = m_FirstItem; i <= end; i++) { m_ListItemCache[index++] = InitListviewItem(m_ShellItemInfo[i]); } }
private void lvHistory_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { if (listViewCache != null && e.StartIndex >= listViewCacheStartIndex && e.EndIndex <= listViewCacheStartIndex + listViewCache.Length) { return; } listViewCacheStartIndex = e.StartIndex; int length = e.EndIndex - e.StartIndex + 1; listViewCache = new ListViewItem[length]; for (int i = 0; i < length; i++) { listViewCache[i] = CreateListViewItem(e.StartIndex + i); } }
protected override void OnCacheVirtualItems(CacheVirtualItemsEventArgs e) { // Only recreate the cache if we need to. if (fCache != null && e.StartIndex >= fCacheFirstItem && e.EndIndex <= fCacheFirstItem + fCache.Length) { return; } fCacheFirstItem = e.StartIndex; int length = e.EndIndex - e.StartIndex + 1; fCache = new GKListItem[length]; for (int i = 0; i < length; i++) { fCache[i] = GetVirtualItem(fCacheFirstItem + i); } }
/// <summary> /// ListView virtual mode handler /// </summary> /// <param name="e">EventArgs object</param> protected override void OnCacheVirtualItems(CacheVirtualItemsEventArgs e) { base.OnCacheVirtualItems(e); // is the requested range already contained in the itemCache int itemCacheEndIndex = itemCacheStartIndex + (itemCache != null ? (itemCache.Length - 1) : 0); if (itemCacheStartIndex <= e.StartIndex && e.EndIndex <= itemCacheEndIndex) { // itemCache contains the requested items } else { // need to read the Sord objects from the cache and // create the ListViewItems //using(new Hourglass()) { itemCacheStartIndex = e.StartIndex; int n = e.EndIndex - e.StartIndex + 1; itemCache = new ListViewItem[n]; for (int i = 0; i < n; i++) { // get from cache int idx = i + itemCacheStartIndex; Object objT = objectsCacheValue[idx]; if (objT != null) { // make ListViewItem itemCache[i] = makeItem(objT); } } } } // Update the virtual list size: // The sordsCache will read the next portion of objects, // if e.EndIndex+1 is below the range of the contens. // Furthermore it updates its CountEstimated value which // becomes the exact value, if all objects are read. //using (new Hourglass(ShowHourglass)) { Object objT = objectsCacheValue[e.EndIndex + 1]; this.VirtualListSize = objectsCacheValue.CountEstimated; } }
/// <summary> /// Cache current view /// </summary> private void CacheVirtualItemsList(object sender, CacheVirtualItemsEventArgs e) { // Only recreate the cache if we need to. if (cache != null && e.StartIndex >= firstItem && e.EndIndex <= firstItem + cache.Length) { return; } firstItem = e.StartIndex; int length = e.EndIndex - e.StartIndex + 1; cache = new ListViewItem[length]; for (int i = 0; i < cache.Length; i++) { cache[i] = GetListItem(firstItem + i); } }
protected override void OnCacheVirtualItems(CacheVirtualItemsEventArgs e) { base.OnCacheVirtualItems(e); //We've gotten a request to refresh the cache. //First check if it's really necessary. if (myCache != null && e.StartIndex >= firstItem && e.EndIndex <= firstItem + myCache.Length) { //If the newly requested cache is a subset of the old cache, //no need to rebuild everything, so do nothing. return; } //Now we need to rebuild the cache. firstItem = e.StartIndex; int length = e.EndIndex - e.StartIndex + 1; //indexes are inclusive myCache = GetLVIENcodings(encodingInfos, firstItem, length); }
private void listView_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { int length = e.EndIndex - e.StartIndex; if (e.StartIndex >= firstCachedItemIndex && e.EndIndex < firstCachedItemIndex + cachedItems.Count) { return; } cachedItems.Clear(); firstCachedItemIndex = e.StartIndex; for (int i = 0; i < length; i++) { cachedItems.Add(GetItem(firstCachedItemIndex + i)); } }
void ViewCacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { // Only recreate the cache if we need to. if (_listViewItemCache != null && e.StartIndex >= _listViewItemCacheFirst && e.EndIndex <= _listViewItemCacheFirst + _listViewItemCache.Length) { return; } _listViewItemCacheFirst = e.StartIndex; int length = e.EndIndex - e.StartIndex + 1; _listViewItemCache = new ListViewItem[length]; for (int i = 0; i < _listViewItemCache.Length; i++) { _listViewItemCache[i] = GetListItem(_listViewItemCacheFirst + i); } }
private void lvMemory_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { do { if (null == this.Image) { break; } UInt32 tStartAddress = (UInt32)e.StartIndex * this.LineSize; Int32 tLength = (e.EndIndex - e.StartIndex + 1) * (Int32)this.LineSize; Byte[] tBuffer = null; if (!this.Image.Read(tStartAddress, ref tBuffer, tLength)) { break; } MemoryBlock tBlock = new MemoryBlock(tStartAddress, tBuffer); ListViewCacheLine tCacheLine = null; for (UInt32 tOffset = 0; tOffset < tBlock.Size; tOffset += this.LineSize) { Byte[] tTempLine = null; UInt32 wAddress = tStartAddress + tOffset; if (!tBlock.Read(wAddress, ref tTempLine, (Int32)this.LineSize)) { continue; } ListViewItem tItem = new ListViewItem(wAddress.ToString("X8")); tItem.SubItems.Add(HEX.HEXBuilder.ByteArrayToHEXString(tTempLine)); tItem.SubItems.Add(BuildDisplayString(tTempLine)); tCacheLine = new ListViewCacheLine(wAddress, tItem); m_ListViewCache.Add(tCacheLine); } m_ListViewCache.RemoveBefore(tStartAddress.ToString("X8")); m_ListViewCache.RemoveAfter(tCacheLine.ID); } while (false); }
private void listRecord_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { if (_itemCacheList != null && e.StartIndex >= _firstItem && e.EndIndex <= _firstItem + _itemCacheList.Count) { return; } _firstItem = e.StartIndex; int length = e.EndIndex - e.StartIndex + 1; _itemCacheList = new List <ListViewItem>(); for (int i = 0; i < length; i++) { var item = new ListViewItem(); var data = _codeRecords.Values[i + e.StartIndex]; item.Text = data.issue; item.SubItems.Add(string.Join(",", data.codes)); _itemCacheList.Add(item); } }
private void hexDumpListView_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { if (mItemCache != null && e.StartIndex >= mItemCacheFirst && e.EndIndex <= mItemCacheFirst + mItemCache.Length) { // Already have this span cached. return; } // Discard old cache, create new one, populate it. mItemCacheFirst = e.StartIndex; int len = e.EndIndex - e.StartIndex + 1; // end is inclusive mItemCache = new ListViewItem[len]; for (int i = 0; i < len; i++) { mItemCache[i] = CreateListViewItem(e.StartIndex + i); } }
// Вызывается непосредственно перед тем, как ListView выведет новую порцию элементов списка private void listView_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { _topIndex = e.StartIndex; // Выяснить, нужны ли еще элементы // (Обратите внимание, что мы никогда не делаем список короче; // это признак не самой эффективной реализации кэша) var needed = (e.EndIndex - e.StartIndex) + 1; if (_listViewItemCache.Capacity < needed) { var toGrow = needed - _listViewItemCache.Capacity; // Привести вместимость в соответствие с характеристиками цели _listViewItemCache.Capacity = needed; // Добавить новые кэшированные элементы for (var i = 0; i < toGrow; i++) { _listViewItemCache.Add(new ListViewItem()); } } }
/// <summary> /// 仮想リストビューのキャッシュを再構築する /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { if (_itemList == null) { Debug.WriteLine("CacheVirtualItems itemList not defined"); return; } if (_itemList.Count == 0) { Debug.WriteLine("CacheVirtualItems itemList.Count == 0"); return; } // Debug.WriteLine(string.Format("CacheVirtualImages start:{0} end:{1} first:{2}", // e.StartIndex, e.EndIndex, _firstItem)); if (_itemCache != null && e.StartIndex >= _firstItem && e.EndIndex <= _firstItem + _itemCache.Length) { return; } _firstItem = e.StartIndex; int cacheLength = e.EndIndex - e.StartIndex + 1; _itemCache = new ListViewItem[cacheLength]; int itemIndex = 0; lock (((ICollection)_itemList).SyncRoot) { for (int i = 0; i < cacheLength; i++) { itemIndex = (i + _firstItem); _itemCache[i] = _itemList[GetIndex(itemIndex)].CreateVirtualListViewItem(); } } }
private void listView1_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { if (_csv != null) { for (int c = e.StartIndex; c <= e.EndIndex; c++) { _csv.RowIndex = c; if (!_lviCache.ContainsKey(_csv.RowIndex)) { var rowData = _csv.Row; var row = new ListViewItem(); row.Tag = c; if (rowData.Count > 0) { row.Text = rowData[0]; } for (int i = 1; i < listView1.Columns.Count; i++) { if (i < rowData.Count) { row.SubItems.Add(rowData[i]); } else { row.SubItems.Add(""); } } if (c % 2 == 0) { row.BackColor = Color.FromArgb(255, 240, 240, 240); } _lviCache[c] = row; } } } }
// ******************************************************************************** /// <summary> /// /// </summary> /// <param name="e"></param> /// <returns></returns> /// <created>UPh,25.10.2015</created> /// <changed>UPh,25.10.2015</changed> // ******************************************************************************** protected override void OnCacheVirtualItems(CacheVirtualItemsEventArgs e) { //We've gotten a request to refresh the cache. //First check if it's really necessary. if (_LVICache != null && e.StartIndex >= _LVIFirstItem && e.EndIndex <= _LVIFirstItem + _LVICache.Length) { //If the newly requested cache is a subset of the old cache, //no need to rebuild everything, so do nothing. return; } //Now we need to rebuild the cache. _LVIFirstItem = e.StartIndex; int length = e.EndIndex - e.StartIndex + 1; //indexes are inclusive _LVICache = new ListViewItem[length]; //Fill the cache with the appropriate ListViewItems. for (int i = 0; i < length; i++) { _LVICache[i] = CreateLVItemAt(_LVIFirstItem + i); } }
protected override void OnCacheVirtualItems(CacheVirtualItemsEventArgs e) { // Only recreate the cache if we need to. if (!_itemCache.Any() || e.StartIndex < _firstItemIndex || e.EndIndex > _firstItemIndex + _itemCache.Count - 1) { bool newItem; List <ViewItem> newItems = new List <ViewItem>(e.EndIndex - e.StartIndex + 1); // Do not alter _itemCache or _firstItemIndex until we're done // calling GetListItem(), since it references them. // This may reuse some existing ViewItems in _itemCache. for (int i = e.StartIndex; i <= e.EndIndex; ++i) { newItems.Add(GetListItem(i, out newItem)); } _itemCache = newItems; _firstItemIndex = e.StartIndex; } base.OnCacheVirtualItems(e); // Probably unnecessary. }
/// <summary> /// Подписка на событие : listViewMessages : Необходимосто создания элементов в кэше хранения в виртуальном режиме. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void listViewMessages_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { topIndex = e.StartIndex; int needed = (e.EndIndex - e.StartIndex) + 1; if (listViewItemCache.Capacity < needed) { int toGrow = needed - listViewItemCache.Capacity; listViewItemCache.Capacity = needed; for (int ix = 0; ix < toGrow; ix++) { ListViewItem newItem = new ListViewItem(); newItem.Text = ""; for (int colIx = newItem.SubItems.Count; colIx < listViewMessages.Columns.Count; colIx++) { newItem.SubItems.Add(""); } listViewItemCache.Add(newItem); } } }
private void appListView_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { // Check if the cache needs to be refreshed. if (this.listViewCache != null && e.StartIndex >= this.cacheStartIndex && e.EndIndex <= this.cacheStartIndex + this.listViewCache.Length) { // If the newly requested cache is a subset of the old cache, // no need to rebuild everything, so do nothing. return; } this.cacheStartIndex = e.StartIndex; // The indexes are inclusive. int length = e.EndIndex - e.StartIndex + 1; this.listViewCache = new ListViewItem[length]; // Fill the cache with the appropriate ListViewItems. for (int i = 0; i < length; i++) { this.listViewCache[i] = new ListViewItem(this.applications[i + this.cacheStartIndex].Path); } }
void bucketsListView_CacheVirtualItems(object sender, CacheVirtualItemsEventArgs e) { BucketListView blv = (BucketListView)sender; blv.UpdateLviCache(); }