private OLVListSubItem MakeSubItem(object rowObject, OLVColumn column) { object cellValue = column.GetValue(rowObject); OLVListSubItem subItem = new OLVListSubItem(cellValue, column.ValueToString(cellValue), column.GetImage(rowObject)); if (this.UseHyperlinks && column.Hyperlink) { IsHyperlinkEventArgs args = new IsHyperlinkEventArgs(); args.ListView = this; args.Model = rowObject; args.Column = column; args.Text = subItem.Text; args.Url = subItem.Text; this.OnIsHyperlink(args); subItem.Url = args.Url; } return subItem; }
void tickler_ElapsedInThread() { // Handle death/destruction/hiding if (this.Column == null || this.ListView == null || this.ListView.IsDisposed || !this.Column.IsVisible || this.ListView.View != System.Windows.Forms.View.Details) { return; } Rectangle updateRect = new Rectangle(); List <object> objectsToRemove = new List <object>(); // Run through each visible row, checking to see if it should be animated int topIndex = this.ListView.TopItemIndex; int bottomIndex = topIndex + this.ListView.RowsPerPage; for (int i = topIndex; i <= bottomIndex; i++) { OLVListItem olvi = this.ListView.GetItem(i); if (olvi == null) { continue; } // Has this row been animating? object animatingModel = olvi.RowObject; if (!this.animationIndexMap.ContainsKey(olvi.RowObject)) { continue; } // Collect the area that must be redraw OLVListSubItem subItem = (OLVListSubItem)olvi.SubItems[this.Column.Index]; if (updateRect.IsEmpty) { updateRect = subItem.Bounds; } else { updateRect = Rectangle.Union(updateRect, subItem.Bounds); } // If it is still animating, advance to the next image, wrapping // at the end. If it is no longer animating, remove it. if (this.IsAnimating(animatingModel)) { int newIndex = this.GetAnimationIndex(animatingModel) + 1; if (newIndex >= this.ImageNames.Count - 1) { newIndex = 1; } this.animationIndexMap[animatingModel] = newIndex; // For virtual lists, it is enough to redraw the cell, // but for non-owner drawn, we have to be more forceful if (!this.ListView.VirtualMode) { subItem.ImageSelector = column.GetImage(animatingModel); this.ListView.SetSubItemImage(olvi.Index, this.Column.Index, subItem, false); } } else { objectsToRemove.Add(animatingModel); } } // Get rid of models that are no longer animating foreach (object key in objectsToRemove) { this.animationIndexMap.Remove(key); } // Force the listview to redraw the animated images if (!updateRect.IsEmpty) { this.ListView.Invalidate(updateRect); } }